How do I point Apache document root to a specific

2020-03-01 08:34发布

问题:

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?

回答1:

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.



回答2:

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 :)



标签: apache ubuntu