学习慕课网笔记
- Ubuntu 16.04 LTS
- Apache24
设置三台主机名为bbs.imooc.com, video.imooc.com, oa.imooc.com
- 创建目录,在/var/www/wwwroot/下新建bbs, video, oa三个文件,每个里面添加一个index.html文件显示页面
- /etc/apache2/sites-available下复制000-default.conf
三份,改名为bbs.conf,oa.conf,video.conf,修改:
bbs.conf
<VirtualHost *:80>
ServerName bbs.imooc.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/wwwroot/bbs
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
oa.conf
<VirtualHost *:80>
ServerName oa.imooc.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/wwwroot/oa
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
video.conf
<VirtualHost *:80>
ServerName video.imooc.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/wwwroot/video
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- 使配置生效
sudo a2ensite bbs.conf
sudo a2ensite oa.conf
sudo a2ensite video.conf
- 修改hosts文件
/etc/hosts里添加
127.0.0.1 bbs.imooc.com
127.0.0.1 oa.imooc.com
127.0.0.1 video.imooc.com
- 重启服务器
sudo service apache2 restart
- 打开浏览器访问
bbs.imooc.com
oa.imooc.com
video.imooc.com
参考:
https://linux.cn/article-3164-1.html
https://segmentfault.com/a/1190000002517469