
Windows下安装多个Apache服务:
1.安装好Apache以后,可以在浏览器中输入http://localhost测试;
2.更改第一个站点的根目录:在文件Apache2.2\conf\httpd.conf中查找 DocumentRoot 属性,将后面的路径改为你的主站点的路径,如:D:\www\web1
3.为第二个Apache服务建立配置文件:复制并重命名httpd.conf为web2.conf(举个例子而已,也可以叫my.conf等等),修改web2.conf中的Listen 8080(原来为80)、ServerName localhost:8080(原来为80)、DocumentRoot "D:/www/web2"(原来为web1)
3.添加第二个Apache服务:Apache安装目录的bin子目录下,使用如下命令将Apache安装为Windows NT服务:httpd.exe -k install -n "服务名" -f "d:\apache2.2\conf\web2.conf"
Linux系统下安装多个Apache服务:
1.完整安装一个apache到/usr/server/apache
cp /usr/server/apache /usr/server/apache1#复制其中一个Apache配置文件
#修改/usr/server/apache/conf/httpd.conf 监听192.168.1.100
#修改/usr/server/apache1/conf/httpd.conf 监听192.168.1.101 ServerRoot为/usr/server/apache1
vi /usr/server/apache1/bin/apachectl
#将里面所有的路径为apache的修改为apache1
vi /usr/server/apache1/bin/envvars
#将里面所有的路径为apache的修改为apache1
vi /usr/server/apache1/bin/envvars-std
#将里面所有的路径为apache的修改为apache1
2.创建系统启动文件
vi /usr/server/apache1/bin/apache.sysvinit#!/bin/sh
#
# This is a sample /etc/init.d file for apache
#
# chkconfig: 2345 80 30
# description: apache1 - WWW server
prefix=/usr/server/apache1
exec_prefix=/usr/server/apache1
bindir=${exec_prefix}/bin
sbindir=${exec_prefix}/sbin
case "$1" in
start)
echo -n "Starting apache1 WWW server:"
/usr/server/apache1/bin/apachectl -f /usr/server/apache1/conf/httpd.conf -k start
echo -n ""
stop)
echo -n "Stopping apache1 WWW server:"
/usr/server/apache1/bin/apachectl -f /usr/server/apache1/conf/httpd.conf -k stop
echo -n ""
restart)
$0 stop
$0 start
esac
exit 0
cp /usr/server/apache1/bin/apache.sysvinit /etc/rc.d/init.d/httpd1
chmod 755 /etc/rc.d/init.d/httpd1
chkconfig --add httpd1
3.测试Apache服务
/etc/init.d/httpd1 startnetstat -ant |grep LISTEN
/etc/init.d/httpd1 stop
我觉得你这样做不会成功,apache是一个服务,只有一个单一的pid,怎么可能会启动两个守护进程呢。在我记忆里只能启动一个守护进程,次之,你的做法不合理:在apache配置文件中可以设置服务器来监听多个端口:
code:
listen 80
listen 8080
再次之,你这是基于域名的虚拟主机了吧,配置<virtualhost>来跑在不同的端口。这样不就行了吗?
#
#Listen 12.34.56.78:80
Listen 80
listen 8080
<virtualhost www.80.com:80>
serveradmin venuslinux@gmail.com
servername www.80.com
documentroot /wz/80
errorlog logs/80_error.log
customlog logs/80_access.log common
directoryindex index.html
</virtualhost>
<virtualhost www.8080.com:8080>
serveradmin venuslinux@gmail.com
servername www.8080.com
documentroot /wz/8080
errorlog logs/8080_error.log
customlog logs/8080_access.log common
directoryindex index.html
</virtualhost>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)