您的位置:首页 > 其它

step by step入门LAMP配置

2013-01-07 19:13 471 查看
安装apache2参见《step by step学习LAMP配置》一文。

环境:

虚拟机上安装的debian系统

apache2

python2.6

mysql5.5

一、入门:搭建一个简单的网页“Welcome to my blog~”

该部分介绍如何在apache上搭建一个简单web应用,会搭建两个虚拟机,分别对应不同的port,共享一个ip。

1.编写虚拟机配置文件

cp /etc/apache2/sites-avaliable/default /etc/apache2/sites-avaliable/blog.mytest.com

cp /etc/apache2/sites-avaliable/default /etc/apache2/sites-avaliable/cici.com

default文件是apache自带的虚拟机配置文件,因此这里不用自己编写,拷贝两份修改就ok了~

2.编辑虚拟机配置文件

vim /etc/apache2/sites-avaliable/blog.mytest.com

修改 <VirtualHost *:80>为 <VirtualHost *:8080>

DocumentRoot改为需要将网页源文件保持的路径:eg:DocumentRoot /home/cici/www/blog.mytest.com/

修改相应的: <Directory /home/cici/www/blog.mytest.com/>

然后vim /etc/apache2/sites-avaliable/cici.com做类似的修改,但是该虚拟机的port设置为8081,路径也需要更改为期望指定的路径

3.执行

ln -s /etc/apache2/sites-avaliable/blog.mytest.com /etc/apache2/sites-enabled/blog.mytest.com

ln -s /etc/apache2/sites-avaliable/cici.com /etc/apache2/sites-enabled/cici.com

在sites-available里面的文件是有效的虚拟主机配置,只要将其连接到site-enabled目录下才能真正生效;

4.执行

vim /etc/apache2/httpd.conf

添加语句ServerName localhost

5.执行vim /etc/apache2/ports.conf配置server的监听端口

添加Listen 8080和Listen 8081

6.执行service apache 2 restart

7.在/home/cici/www/blog.mytest.com/目录下创建一个index.html文件

<h1>Welcome to my blog~</h1>

8.在可以互相通讯的client上,用浏览器访问server_ip:8080,就能看到页面打印出“Welcome to my blog~”信息了~!

9.此外可以用a2ensite cici.com或是a2dissite cici.com激活或是注销某个虚拟机。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐