Apache 多端口多站点配置方法
程序员文章站
2022-06-27 21:19:17
配置httpd.conf 监听多个端口 复制代码 代码如下: # listen: allows you to bind apache to specific ip addr...
配置httpd.conf
监听多个端口
# listen: allows you to bind apache to specific ip addresses and/or
# ports, instead of the default. see also the <virtualhost>
# directive.
#
# change this to listen on specific ip addresses as shown below to
# prevent apache from glomming onto all bound ip addresses.
#
#listen 12.34.56.78:80
listen 8081
listen 8082
listen 8083
#增加监听端口
等以下内容都设置以后,可以通过netstat -n -a查看端口是否开启
开启虚拟站点
# virtual hosts
#include conf/extra/httpd-vhosts.conf
#修改为
# virtual hosts
include conf/extra/httpd-vhosts.conf
配置php模块
加载php模块,php5apache2_2代表使用的是apache2.2或以上版本
loadmodule php5_module "c:/php/php5apache2_2.dll"
phpinidir "c:/php"
配置php文件类型映射
addtype application/x-httpd-php .php
配置conf/extra/httpd-vhosts.conf
<virtualhost *:8082>
serveradmin webmaster@dummy-host.localhost
documentroot "c:/phpdocroot/site1"
servername localhost
serveralias localhost
errorlog "logs/dummy-host.localhost-error.log"
customlog "logs/dummy-host.localhost-access.log" common
<directory "c:/phpdocroot/site1">
options indexes followsymlinks
allowoverride none
order allow,deny
allow from all
</directory>
</virtualhost>
<virtualhost *:8083>
serveradmin webmaster@dummy-host2.localhost
documentroot "c:/phpdocroot/site2"
servername localhost
errorlog "logs/dummy-host2.localhost-error.log"
customlog "logs/dummy-host2.localhost-access.log" common
<directory "c:/phpdocroot/site2">
options indexes followsymlinks
allowoverride none
order allow,deny
allow from all
</directory>
</virtualhost>
<directory...>...</directory>
一定不能少
重新启动apache试一下,如果出错,查看一下logs下面的log文件还有windows的事件查看器记录的错误日志。
监听多个端口
复制代码 代码如下:
# listen: allows you to bind apache to specific ip addresses and/or
# ports, instead of the default. see also the <virtualhost>
# directive.
#
# change this to listen on specific ip addresses as shown below to
# prevent apache from glomming onto all bound ip addresses.
#
#listen 12.34.56.78:80
listen 8081
listen 8082
listen 8083
#增加监听端口
等以下内容都设置以后,可以通过netstat -n -a查看端口是否开启
开启虚拟站点
复制代码 代码如下:
# virtual hosts
#include conf/extra/httpd-vhosts.conf
#修改为
# virtual hosts
include conf/extra/httpd-vhosts.conf
配置php模块
加载php模块,php5apache2_2代表使用的是apache2.2或以上版本
loadmodule php5_module "c:/php/php5apache2_2.dll"
phpinidir "c:/php"
配置php文件类型映射
addtype application/x-httpd-php .php
配置conf/extra/httpd-vhosts.conf
复制代码 代码如下:
<virtualhost *:8082>
serveradmin webmaster@dummy-host.localhost
documentroot "c:/phpdocroot/site1"
servername localhost
serveralias localhost
errorlog "logs/dummy-host.localhost-error.log"
customlog "logs/dummy-host.localhost-access.log" common
<directory "c:/phpdocroot/site1">
options indexes followsymlinks
allowoverride none
order allow,deny
allow from all
</directory>
</virtualhost>
<virtualhost *:8083>
serveradmin webmaster@dummy-host2.localhost
documentroot "c:/phpdocroot/site2"
servername localhost
errorlog "logs/dummy-host2.localhost-error.log"
customlog "logs/dummy-host2.localhost-access.log" common
<directory "c:/phpdocroot/site2">
options indexes followsymlinks
allowoverride none
order allow,deny
allow from all
</directory>
</virtualhost>
<directory...>...</directory>
一定不能少
重新启动apache试一下,如果出错,查看一下logs下面的log文件还有windows的事件查看器记录的错误日志。