Php – Making Apache able to write to PHP files with PHP running as DSO

apache-2.2chmoddsoPHP

I have PHP running as a DSO. As such, my installer script (which writes to a config file) can't do any writing.

How do I give apache (user: nobody) the ability to write to the file?

Best Answer

I would only do this on a development server in a secured environment. Many PHP applications will generate the file to the screen so that it can be copied safely to the configuration directory.

The quick (and insecure) way to do this is to execute chmod 777 . from the directory where the file should go. Before doing this run ls -ld . to get the permissions you will be setting them back to. In some cases the required directory will not exist, so you will need to create it first. Immediately after the configuration file has been written, reset the directory to its original permissions. The correct command is likely chmod 755 . or chmod 750 . run from the directory. Verify with the ls command.

Change the permissions on the configuration file so that Apache can no longer write to it (chmod o-w configfile). Applications often come with example configuration files. Placing one of these in the configuration directory and editing may be a better approach. This requires that you learn and understand the configuration options. You may be able to use the online configuration script to assist your edits.