0

I have some question about permission for my apache.

The following situation came in a test up: I want to install wordpress and the setup told me that he can not create the file wp-config.php. So I noticed that there is a permission problem. But how can I fix this?

All folders in var/www/html are owned by apache:apache and has 755 permissions (drwxr-xr-x).

What information you need to give me some suggestions?

4
  • I think apache runs as httpd user on centos, no ?
    – Kiwy
    Jun 6, 2018 at 9:51
  • I dunno know really. I installed apache with sudo yum -y apache
    – yfain
    Jun 6, 2018 at 9:55
  • what is the ouput of lsof -i TCP:80 edit your question so everybody knows also you should add the installation method to your question it could help Also did you created tha apache user ? if you did how did you ?
    – Kiwy
    Jun 6, 2018 at 10:19
  • lsof command not found
    – yfain
    Jun 6, 2018 at 11:11

2 Answers 2

0

You should allow the user on which privileges apache process is running to write to this file. To check the name of user used by apache process you can run ps -ef | grep httpd and then set the owner for wp-config.php file but after installation will be finished you should disallow apache to make changes on this file.

9
  • Thanks, but I need a solution that this will work for new folders and domains. I changed the owner to apache:apache for var/www/html/ and 755. But it is also not working.
    – yfain
    Jun 6, 2018 at 9:09
  • You changed permission for /var/www/html directory but what with files and sub-directories inside?
    – mariaczi
    Jun 6, 2018 at 9:13
  • Also changed to this.
    – yfain
    Jun 6, 2018 at 9:13
  • OK, you use mod_php with apache or php-fpm?
    – mariaczi
    Jun 6, 2018 at 9:14
  • I use CGI for PHP
    – yfain
    Jun 6, 2018 at 9:16
0

we need to temporarily grant httpd_sys_rw_content_t to the WordPress directory. This is to allow the initial wizard to create the wp-config.php file.

sudo chcon -t httpd_sys_rw_content_t /var/www/html/wordpress/

Now you can run the wizard and it will work properly.

Once your site is set up, restore the context to http_sys_content_t

sudo restorecon -v /var/www/html/wordpress/
2
  • Is there a way to enable this always?
    – yfain
    Jun 6, 2018 at 9:51
  • then don't restore the context.
    – Siva
    Jun 6, 2018 at 9:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .