Does anyone know how to change the document root of the Apache server? I basically want localhost
to come from /users/spencer/projects
directory instead of /var/www
.
I ended up figuring it out. Some suggested I change the httpd.conf
file, but I ended up finding a file in /etc/apache2/sites-available/default
and changed the root directory from /var/www
to /home/myusername/projects_folder
and that worked.
Please note, that this only applies for Ubuntu 14.04 LTS and newer releases.
In my Ubuntu 14.04 LTS, the document root was set to /var/www/html
. It was configured in the following file:
/etc/apache2/sites-available/000-default.conf
So just do a
sudo nano /etc/apache2/sites-available/000-default.conf
and change the following line to what you want:
DocumentRoot /var/www/html
Also do a
sudo nano /etc/apache2/apache2.conf
and find this
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change /var/www/html
to your preferred directory
and save it.
After you saved your changes, just restart the apache2 webserver and you'll be done :)
sudo service apache2 restart
sudo nano
by a gksu gedit
.