0

I'm learning about servers, and I'm configuring Nginx, MySQL, PHP, and WordPress. the server distro is Debian 6.

I created a new user and I want each user to be the owner of the site folder /var/www/site.one, so I run the command chown -R kossel:kossel site.one

My problem is, my WordPress only works if I chmod 644 wp-config.php, which all can read wordpress site suggest that file should be 640.

My question is, when someone opens mydomain.com, WordPress has to access the wp-config.php file, but which user is it actually using to "read" that file? The root user? User kossel? Anyone else? How can I properly give it permission or ownership?

1

I created a new user and I wish each user is the owner of the site folder /var/www/site.one so I chown -R kossel:kossel site.one

Why do you want to do that? The document root (/var/www/site.one) should owned by the user that the web server is running as (www-data on the Debian based, apache on the Red Hat based).

my problem is, my wordpress only work if I chmod 644 wp-config.php, which all can read [wordpress site suggest][1] that file should be 640.

Because you did wrong in the above step.

and my question is: when someone open mydomain.com, wordpress has to access wp-config.php file, but which user is it actually using to "read" that file? root? user kossel? anyone else?

As I said above, that is www-data user. You can check this by running ps -ef | grep nginx.

how can I properly give it permission or owner?

chown -R www-data:www-data /var/www/site.one
chmod -R 755 /var/www/site.one
  • thanks for the answer! I did ps -ef | grep httpd and how the user is root instead of www-data?? root 32216 32202 0 04:13 pts/0 00:00:00 grep httpd I installed nginx using root account with this script: lowendtalk.com/discussion/3965/… – Yichaoz Sep 13 '12 at 13:17
  • ps -ef | grep nginx? – quanta Sep 13 '12 at 13:23
  • root 18290 1 0 Sep12 ? 00:00:00 nginx: master process /usr/sbin/nginx www-data 18291 18290 0 Sep12 ? 00:00:00 nginx: worker process root 32234 32202 0 04:24 pts/0 00:00:00 grep nginx, I think this is ok. I did what you do and everything works fine now. thanks – Yichaoz Sep 13 '12 at 13:25
  • You webserver (Nginx) is running as www-data user. – quanta Sep 13 '12 at 13:26
  • IMHO it should be chown -R www-data:www-data /var/www/site.one. And chmod -R 755 /var/www/site.one is dirty : php files and images have no need to be executable. – user130370 Sep 13 '12 at 13:31
1

In Debian (most of the time) web server runs by 'www-data' user. If you want your website to work, its files should be readable (or executable) by www-user. So your wp-config.php is must be readable by the www-data user. In order to fix your problem you can do several things,

  1. Add www-data to the group the site is owned
  2. change the group ownership of the folder to www-data

By doing one of the above changes you can keep wp-connfig.php 640.

0

Check out apache-mod-mpm-itk with it you can run all websites (virtualhosts) in the name of it's owners. So 640 will be ok for wp-config.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.