2
votes

I've moved my wordpress installation from a managed VPS to a new centos server. Now I've a problem with writing to files directly from the wordpress admin panel.

Folders/files are set with 755/644. User owner is "wwwuser", group is "apache" (I use this one to access to the documentroot via ftp).

I think that the problem is that in /etc/httpd/conf/http.conf I've user and group setted both to "apache", in fact everything works if I change permissions to 775/664, which should mean that when the group owner is setted to apache everything work, right?

So my question is, should I change all permissions to 775 or there's another solution, which doesn't lead to security issues? Is it safe to make all folders and files 775 and 664? What if I change "apache" to "wwwuser" from /etc/httpd/conf/http.conf?

Edit: is it possible that the problem is that in phpinfo, environment pwd is set to /home/wwwuser/test and not to /home/wwwuser/?

2

2 Answers

3
votes

I would advise to not change the user Apache is running under (to not edit the Apache config file) but to set apache as the owner of the files. chown -R apache /path/to/your/app/files

I think it's the easiest solution. If you choose to change the permissions, you shouldn't have to change the permissions for everyone (other): you could change to 774 but I don't see why 775.

By default Apache is running under the apache user on CentOS.

1
votes

This is a very common problem you are facing right now. Some times files/directories created/uploaded with FTP may have been assign a different users/usergroup. As @Céline Aussourd stated, if you have installed plugin from WordPress then all files and directories will get the default user/usergroup.

Now easiest way to identify which user should be assigned to your files is create a single test file using CPanel file manager called "test.php" and access it from web if it is working then check its user/usergroup and change all your setup files to that user/usergroup all together with

chown -R {user} /path/to/your/worpress/root

Replace {user} with apache web user.

UPDATE: (To install plugin without FTP details)

Please add following line to your wp-config.php after define('WP_DEBUG', false); line.

define('FS_METHOD', direct);

Remove plugin and re-install it, this time it wont ask you for FTP details and will write files directly.