In many cases you might wish to use a specific folder as your web server’s document root. Here is how to configure it in your Apache server.
ALWAYS MAKE BACK UP BEFORE MAKING CHANGES!
1. Edit the httpd.conf file
If you are not sure where the httpd.conf file is located, click here for instruction on how to find out.
In the httpd.conf file you should be able to find out a the default DocumentRoot:
DocumentRoot "/*YOUR DEFAULT DOCUMENT ROOT*/" <Directory "/*YOUR DEFAULT DOCUMENT ROOT*/"> ... </Directory> ...
Comment this part out by putting # before each line, then insert the following code after it
<Directory "CUSTOM_DOCUMENT_ROOT_PATH"> AllowOverride All Options Indexes MultiViews FollowSymLinks Require all granted </Directory>
Where you will need to change
CUSTOM_DOCUMENT_ROOT_PATH to the path of your web root folder. For example (in Mac), if you have a Sites folder under your home directory, and your username is “sean”,
CUSTOM_DOCUMENT_ROOT_PATH can be set to
2. Restart Apache server
Open terminal and run this command to restart Apache server.
sudo apachectl restart
And now if you have a index page sitting in the Sites folder, http://localhost should display the page, or if you don’t have the index page, you should see the list of files you have under that directory.