
正文
Ubuntu 12.04 之 虚拟主机的配置
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
Ubuntu 12.04 之 虚拟主机的配置
(1)打开etc/hosts文件
增加:
127.0.0.1 study.ubuntu.com
127.0.0.1 hello.ubuntu.com
127.0.0.1 test.ubuntu.com
(2)建立三个项目目录
sudo mkdir -p /wwwroot/{study,hello,test}
在每个项目里都建立一个Index.html
(3)配置apache的虚拟主机
切换到apache的配置目录:
cd /etc/apache2/sites-available/
复制三份配置文件:
sudo cp default study
sudo cp default hello
sudo cp default test
修改配置文件:
vim hello
内容:
ServerName hello.ubuntu.com 添加
DocumentRoot /wwwroot/hello 修改
<Directory /wwwroot/hello/> 修改
启动配置文件:
test@localhost:/etc/apache2/sites-available$ cd ../sites-enabled/
test@localhost:/etc/apache2/sites-enabled$ ll
ls: 初始化月份字符串出错
总用量
drwxr-xr-x root root 7Ղ : ./
drwxr-xr-x root root 7Ղ : ../
lrwxrwxrwx root root 7Ղ : -default -> ../sites-available/default
test@localhost:/etc/apache2/sites-enabled$
需要分别创建三个软连接,分别指向刚才复制的三个配置文件。
sudo ln -s ../sites-available/hello hello
sudo ln -s ../sites-available/test test
sudo ln -s ../sites-available/study study
重启apache:sudo service apache2 restart
然后就可以访问
hello.ubuntu.com
study.ubuntu.com
test.ubuntu.com





