Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I point Apache document root to a specific folder in Ubuntu?

Tags:

apache

ubuntu

I have a site that the root points to /var/www I have set up two folders under /var/www

  1. /var/www/old
  2. /var/www/new

for the old folder, I have used the following to deny any access:

touch /var/www/old/.htaccess && echo deny from all >> /var/www/old/.htaccess

I now want the server to point the root to /var/www/new so that when people visit http://example.com the content in /var/www/new will serve, what should I do?

like image 419
Chris Yeung Avatar asked Feb 19 '13 16:02

Chris Yeung


People also ask

Where is Apache root directory Ubuntu?

On Ubuntu, the Apache web server serves documents stored in the var/www/html directory by default. This directory is referred to as the document root.

How do I find Apache root directory?

If we have a multiple site which configured and enabled in the Virtual Host of the Apache, we can search for the document root in the /etc/apache2/sites-enabled folder.

Which directory stores the Apache configuration files?

All the configuration files for Apache are located in /etc/httpd/conf and /etc/httpd/conf.

What is Apache document root?

The document root is a directory (a folder) that is stored on your host's servers and that is designated for holding web pages.


2 Answers

In Ubuntu the Apache configuration is located at /etc/apache2. There should be two folders, sites-available and sites-enabled. Inside sites-enabled are symlinks to config files in sites-available.

You simply have to change the document root in your activated configuration. Thats probably /etc/apache2/sites-enabled/000-default

Have a look for DocumentRoot and change it to /var/www/new, then reload your apache.

like image 186
Ben Avatar answered Oct 22 '22 03:10

Ben


depends a LOT on how your apache server is configured.

I don't have an Ubuntu machine around, but what you're looking for is the DocumentRoot directive. On RedHat based machines it's normally in /etc/httpd/conf/httpd.conf but if memory serves Debian based systems use apache instead of httpd.

If that doesn't work be sure to check in /etc/httpd/conf.d since the files there are loaded dynamically.

Hope this helps :)

like image 37
Nick Andriopoulos Avatar answered Oct 22 '22 03:10

Nick Andriopoulos