ubuntu12.04设置虚拟目录和虚拟域名

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dingxiaowang2014/article/details/48032681

一、虚拟目录

现场模拟:

本来的访问路径为:localhost/demo/demo1

想把访问路径改为:localhost:701/demo1

1、找到sites-available目录

cd /etc/apache2/sites-available

2、创建一个文档demo,把default文档的内容拷贝过去

default文档内容如下(需要修改的地方用红色标记):

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
 

3、修改

<VirtualHost *:80>改为<VirtualHost *:701>

DocumentRoot /var/www修改成DocumentRoot /var/www/demo

<Directory /var/www/>修改成

猜你喜欢

转载自blog.csdn.net/dingxiaowang2014/article/details/48032681
今日推荐