服务器环境:ubuntu_16, apache/2.4.18
域名为 www.aaa.com 和 www.bbb.com 的两个站点都部署上去
环境安装过程略
修改两处配置
1.apache配置文件位置 /etc/apache2/sites-available/000-default.conf(相当于本地wampinapacheapache2.4.18confextrahttpd-vhosts.conf)
打开

修改为
<VirtualHost *:80>
ServerAdmin xxx@xx.xxx
DocumentRoot 项目路径1
ServerName www.aaa.com
<Directory "项目路径1">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin xxx@xx.xxx
DocumentRoot 项目路径2
ServerName www.bbb.com
<Directory "项目路径2">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
设置不同的ServerName、DocumentRoot 和 Directory
2.打开查看 /etc/hosts 文件(相当于本地C:WindowsSystem32driversetchosts)
默认
127.0.0.1 localhost
加上
127.0.0.1 www.aaa.com
127.0.0.1 www.bbb.com
将项目代码放入对应的 项目路径1 和 项目路径2
重启apache
sudo service apache2 restart
完成,访问测试一下