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


最新文章

  1. 创建Mat对象的几种方法
  2. Android想服务器传图片,透过流的方式。还有读取服务器图片(文件),也通过流的方式。
  3. [转载]Vivado轻松实现IP封装
  4. 深入理解line-height与vertical-align
  5. JAVA面向对象程序设计——实验报告
  6. c++虚函数的作用是什么?
  7. (转载)SQL Server 2005 如何启用xp_cmdshell组件
  8. 看牙与IT项目
  9. bootstrap static popover
  10. java jfinal + ajaxfileupload.js 上传
  11. 小结JS中的OOP(上)
  12. remove方法
  13. Win7共享文件夹简单?这个共享问题可以难倒90%的人
  14. mysql 开发进阶篇系列 50 表的数据导入(load data infile,mysqlimport )
  15. mysql基础整理01
  16. UCML异常提示:无效URI
  17. linux source code search
  18. Oracle 报错:PLS-00201: 必须声明标识符
  19. 关于python最大递归深度 - 998
  20. input 数字输入控制(含小数)

热门文章

  1. [转]asp.net MVC helper 和自定义函数@functions小结
  2. vs2015如何添加webservice 的web服务引用
  3. 【数据分析 R语言实战】学习笔记 第三章 数据预处理 (下)
  4. win7 快捷键 收集
  5. SCCM大致安装过程,参考前辈教程完成部署
  6. AIX 10G HA RAC卸载
  7. cf536d——优先队列的运用
  8. js 零散知识
  9. shell 循环 read line
  10. 文件描述符 文件操作 &lt;&gt; open 文件句柄