CentOS 6.4部署LAMP(多站点环境)(3)

五、配置apache
vi /usr/local/apache/conf/httpd.conf

Listen 80
Listen 8080  #增加8080端口,可增加多个端口
ServerName :80    #去掉前面的#号
DirectoryIndex index.html index.htm default.htm default.html index.php index.php3 index.jsp
Include conf/extra/httpd-vhosts.conf  #去掉前面的#号
#增加以下两行
AddType application/x-httpd-php .php .phtml .php3 .inc
AddType application/x-httpd-php-source .phps

vi /usr/local/apache/conf/extra/httpd-vhosts.conf

#按如下配置修改,创建两个虚拟站点,可创建多个站点
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/apache/htdocs/linuxidc"
ServerName
ServerAlias
ErrorLog "logs/www.linuxidc.com-error_log"
CustomLog "logs/www.linuxidc.com-access_log" common
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/apache/htdocs/mycode"
ServerName localhost:8080
ServerAlias mycode
ErrorLog "logs/mycode-error_log"
CustomLog "logs/mycode-access_log" common
</VirtualHost>

#创建两个站点目录
mkdir /usr/local/apache/htdocs/linuxidc
mkdir /usr/local/apache/htdocs/mycode
/usr/local/apache/bin/apachectl start  #启动apache

#修改防火墙配置
vi /etc/sysconfig/iptables

#加入已经两条规则
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT

1 service iptables restart

六、测试
1.创建php测试页
vi /usr/local/apache/htdocs/linuxidc/test.php
vi /usr/local/apache/htdocs/mycode/test.php

#分别创建两个站点的测试页,内容如下
<?php
phpinfo();
?>

2.测试
打开浏览器输入和:8080/test.php,看到如下页面则表示OK。

编辑本地hosts文件,添加如下内容
192.168.0.3

CentOS 6.4部署LAMP(多站点环境)

打开浏览器输入,看到以上页面则表示OK。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/1256d02da1ff5747ee1575008d989b4d.html