Apache多站点配置

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

DNS解析

windows

在C:\Windows\System32\drivers\etc\hosts文件中:

192.168.33.10 martist.cn

linux/unix

在 /etc/hosts文件中:

127.0.0.1 martist.cn

站点配置

apache的配置文件都分割成目录存在,更易于管理和理解。现在我们敲命令,跳转到apache的虚拟站点配置目录:

cd /etc/apache2/sites-available/

ls浏览一下:

root@vagrant-ubuntu-trusty-64:/etc/apache2/sites-available# ls
default.conf  //这里显示ubuntu系统Apache默认配置的虚拟站点

复制默认配置文件,在其基础上修改得到一个新配置文件:

cp default.conf maritst.conf
vi martist.conf

在文件里修改内容:

//站点名字
ServerName martist.cn
//指向站点的项目目录
DocumentRoot /vagrant/martist/public 

最后软连接,把需要的配置文件映射到apache.conf包含的目录里面:

ln -s /etc/apache2/sites-available/martist.conf /etc/apache2/sites-enabled/

重启apache:

service apache2 restart

注意

配置apache工作目录,开启重写(在apache.conf最下面):

<Directory /vagrant/>
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
</Directory>

猜你喜欢

转载自blog.csdn.net/QinDaBao_/article/details/88352841
今日推荐