0

I have a shared server for PHP and the user account under which the Apache webserver is running is nobody and the user for my ftp and cpanel is different lets say jokertec.

Now when my webserver creates any folder I have problems renaming/deleting/modifying that folder using cpanel and when my cpanel creates any folder the webserver has problems doing the same. This is due to the owners of both the folders being different I think.

What I want to ask is that Is this some kind of server misconfiguration and both the user under which apache runs and the cpanel username should be same? Or I am missing something here? As I think we cannot change the user under which php runs for creating folders dynamically.

1 Answer 1

0

This is a common issue in shared hosting environments, and doesn't relates only to cpanel, I know this used to happen in Plesk too. It is not a configuration error, you need to handle permissions by yourself. My workaround involves creating the folder and then changing the permissions and/or owner to the FTP user.

Changing the owner and permissions will depend on the scripting language you are using, for example in PHP you can refer to chown and chmod functions. This should give an idea of where to go.

Take into consideration that changing the user or permissions may create a security hole in your application, just try to stay away from 777. you should also consider a proper permission setting if you need to be able to edit files with both of your server and FTP user.

1
  • yes this is true but chown works only if run as root currently the php process is executed by nobody user thus that function to change the owner of the folder might fail. The FTP solution can work but then i need to route all folder creation and manipulation by ftp that's one overhead.
    – LoneWOLFs
    Oct 17, 2013 at 4:57

You must log in to answer this question.

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