DocumentRoot location in CentOS

The default location for the document root is /var/www/html when you first install Apache® on CentOS®:

     ~]# httpd -S 2>1
     VirtualHost configuration:
     *:80          (/etc/httpd/conf.d/
     *:443                  is a NameVirtualHost
              default server (/etc/httpd/conf.d/
              port 443 namevhost (/etc/httpd/conf.d/
              port 443 namevhost (/etc/httpd/conf.d/ssl.conf:56)
     ServerRoot: "/etc/httpd"
     Main DocumentRoot: "/var/www/html" <---default location

Set this location in file /etc/httpd/conf/httpd.conf:

     ]# grep -i documentroot httpd.conf 

     #DocumentRoot: The directory out of which you will serve your
     DocumentRoot "/var/www/html"
         # access content that does not live under the DocumentRoot.

Note: You can choose another directory if desired, such as /home/

You can also set a document root for individual virtual hosts:

     <VirtualHost *:80>
         ServerAdmin [email protected]
         DocumentRoot /var/www/ <--set here
         ErrorLog logs/
         CustomLog logs/ common
            <Directory /var/www/>
              AllowOverride All

Note: The directories for the virtual hosts must be located under the main DocumentRoot. If your DocumentRoot is /var/www/,
then the directories are set under it, as shown in the following example:


If you change these files, restart Apache with the following commands:

     httpd -t
     service httpd reload

If you have multiple vhosts, organize and separate each document root, as shown in the folloiwng example: