How can I 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.
You need to change the DocumentRoot
setting in your httpd.conf
file. Chances are it will be under something like /etc/apache2/conf/httpd.conf
.
Use your favourite editor (I recommend Vim) and look for the DocumentRoot
and change it to /users/spencer/projects
. Also look a little further down for a setting that looks like this:
<Directory "/var/www">
You will also want to change what is in the quotes to your new directory. This gives Apache access to read from that directory when a user makes a request that call on it.
Now restart your Apache service (httpd -k restart
) and you should be good to go.
Apache 2 site configuration files are now typically kept in /etc/apache2/sites-available/
(Debian, Ubuntu, etc.).