在PHP用使用fopen的写入功能实,常会遇到诸如:
<VirtualHost 127.0.0.1:80>
ServerAdmin xqbumu@jx
DocumentRoot /opt/Workspace/PHP/jx
ServerName jx
ErrorLog logs/jx-error_log
CustomLog logs/jx-access_log common
<Directory "/opt/Workspace/PHP/jx/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
#Order allow,deny
#Allow from all
#Options None
Require all granted
</Directory>
</VirtualHost>
通过配置Selinux可以解决该问题。
本人所用shell命令如下:
semanage fcontext -a -t httpd_sys_rw_content_t '/opt/Workspace/PHP/jx/application/controllers/temp(/.*)?'
restorecon -v '/opt/Workspace/PHP/jx/application/controllers/temp/*'
这样就可以解决在/opt/Workspace/PHP/jx/application/controllers/temp/目录下的读写问题了。