1.安装apache,安装步骤参考:http://enenxie.iteye.com/admin/blogs/1933395
2.拷贝htdocs文件夹并重命名到当前同一目录下,如mydocs
3.配置conf/httpd.conf
[*]增加监听端口
[*]配置虚拟host
修改默认Directory节点
4.测试:
在htdocs和mydocs目录下都存在index.php,内容如下:
启动apache, 在浏览器中分别访问80和8081服务端口服务
[b]有一个问题:不在本机访问8081端口的时候,默认跳转到DocumentRoot目录下的服务。解决办法:将<VirtualHost localhost:8081>中的localhost换成实际ip地址即可[/b]
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]