开发者

PHP Write Permission - FC13

开发者 https://www.devze.com 2023-01-17 23:48 出处:网络
I have recently installed FC13 and am attempting to write a mechanism in my PHP code that caches gathered data into a specific directory 开发者_StackOverflow(for our purposes here, let\'s call it /var

I have recently installed FC13 and am attempting to write a mechanism in my PHP code that caches gathered data into a specific directory 开发者_StackOverflow(for our purposes here, let's call it /var/www/html/_php_resources/cache).

I copy my files over to the /var/www/html directory and then run chown -R apache:apache /var/www/html/* and chmod a+w /var/www/html/_php_resources/cache on the new data. For right now I am just using the global write permission for convenience. I will tweak the permissions later.

When I attempt to use the chmod or mkdir PHP functions I wind up with:

Warning: chmod(): Permission denied in /var/www/html/_include/php/CacheInit.php

or

Warning: mkdir(): Permission denied in /var/www/html/_include/php/CacheInit.php

Now, when I disable SELinux everything works just fine. The problem is that I would prefer not to disable SELinux and actually get the permissions set up correctly so that I can port it over to servers where someone does not have such explicit control.

As an example: my personal site host allows me to set read/write permissions on directories but will not allow for SELinux policy changes.


FYI:

  • uname -r = 2.6.34.7-56.fc13
  • *php -version * = PHP 5.3.3
  • rpm -qa | grep httpd = httpd-2.2.16-1.fc13

Does anyone have any suggestions?


I had the same problem, trying to mkdir from php. Not so much information on google but this is what I found and I guess this is the correct solution. One have to label the dir in which apache should create directories.

Label should be "httpd_sys_script_rw_t" and I found that info here: http://docs.fedoraproject.org/en-US/Fedora_Core/5/html/SELinux_FAQ/index.html#id672528

Here's how to label the dir: chcon -R -t httpd_sys_script_rw_t <dir> Reference somewhere here: http://www.centos.org/docs/5/html/Deployment_Guide-en-US/rhlcommon-chapter-0017.html

Hope this help someone out there.

0

精彩评论

暂无评论...
验证码 换一张
取 消