Apache配置多服务

1.安装apache,安装步骤参考:http://enenxie.iteye.com/admin/blogs/1933395
2.拷贝htdocs文件夹并重命名到当前同一目录下,如mydocs
3.配置conf/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 80
Listen 8081 #新增端口

[*]配置虚拟host

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

<VirtualHost localhost:8081>
ServerAdmin webmaster@enenxie-host.localhost
DocumentRoot "/usr/local/apache2/mydocs" #新增服务目录
ServerName localhost
ServerAlias localhost
ErrorLog "logs/enenxie-host.localhost-error.log"
CustomLog "logs/enenxie-host.localhost-access.log" common
<Directory "/usr/local/apache2/mydocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


修改默认Directory节点

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
# Require all denied
Require all granted
</Directory>


4.测试:
在htdocs和mydocs目录下都存在index.php,内容如下:

<?php phpinfo();?>

启动apache, 在浏览器中分别访问80和8081服务端口服务

[b]有一个问题:不在本机访问8081端口的时候,默认跳转到DocumentRoot目录下的服务。解决办法:将<VirtualHost localhost:8081>中的localhost换成实际ip地址即可[/b]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值