Centos – How to configure Apache document root

apache-2.2centosdocumentroot

I am in the process to migrate to a new web server and I would like to have a clean and safe file architecture for apache and my web application.

The server will serve one single php/mysql application. This application receive files from FTP and webservices and generate logs files.

The server OS is CentOS 5.4.

The default Apache document root is /var/www/html.

Should I put my web application directory under :

  • /var/www/html/myWebApp?
  • /www/myWebApp?
  • /home/www/myWebApp?
  • Somewhere else?

The application directory should be owned by the root user or apache user or an other user?

Thanks for your help.

Best Answer

Assuming you have SELinux enabled, not all of those options will work due to SELinux denying access to non-standard folders by the httpd process.

IIRC, the preferred method for manually adding web applications on CentOS (e.g. a mediawiki install) is to install them to /var/www/<myappname> and create an Alias in the /etc/httpd/conf/httpd.conf file that points to your app (I usually pattern mine to be similar to the existing alias for the /var/www/icons folder).

Typical file ownership for anything under /var/www on CentOS is root.