简体   繁体   中英

Enable multiple webroot for apache2 on Ubuntu

I'm using apache2 on my ubuntu 13.10 machine, I have added another config file named paul under /etc/apache2/sites-available directory to make my file under /home/paul/public_html/ accessible on internet:

root@localhost:/etc/apache2/sites-available# ls -ltr
-rw-r--r-- 1 root root  950 Feb  7  2012 default
-rw-r--r-- 1 root root  978 Jun 23 10:54 paul

After than changes, my files under /var/www is not accessible on URL anymore, unless I change DocumentRoot from / home/paul/public_html to /var/www , but that would disable accessibility for /home/paul/public_html/

/etc/apache2/sites-available/paul :

    DocumentRoot /home/paul/public_html
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

Is there any way of configuration to enable /var/www and /home/paul/pubilc_html as webroot at the same time? Is it required any setting on /etc/apache2/apache2.conf ? Any ideas would be appreciated, thanks.

You can accomplish this easily with an alias directive . In /etc/apache2/sites-available/default just add an Alias for the URL.

<VirtualHost *:80>
        ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/

        Alias /paul /home/paul/public_html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now the contents of /home/paul/public_html should be available at www.example.com/paul

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM