apache配置多端口访问的实例代码

发布时间:2020-06-21编辑:脚本学堂
为大家介绍一个apache配置多端口访问的例子,主要是配置与修改httpd.conf与httpd-vhosts.conf文件。有需要的朋友,可以参考学习下。

apache/install/ target=_blank class=infotextkey>apache配置多个端口访问,请参考如下配置步骤进行。

1、配置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 192.168.11.28:80
Listen 80
Listen 81
Listen 82
 

 
2、开启虚拟站点
 

复制代码 代码示例:
# Virtual hosts
#include conf/extra/httpd-vhosts.conf
#修改为
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

3、配置conf/extra/httpd-vhosts.conf
 

复制代码 代码示例:
<VirtualHost *:81>
    ServerAdmin webmaster@jbxue.localhost
    DocumentRoot "C:/PhpDocRoot/Site1"
    ServerName jb200.com
    Serveralias jb200.com
    ErrorLog "logs/jbxue.localhost-error.log"
    CustomLog "logs/jbxue.localhost-access.log" common
    <Directory "C:/PhpDocRoot/Site1">
      Options Indexes FollowSymLinks
        AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>
 

重启apache使生效。

此时访问站点出现:you don't have permission to access / on this server(Apache Server权限访问问题)错误,作如下的修改即可:
httpd.conf:
 

复制代码 代码示例:
<Directory/>
  Options FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
</Directory>
 

修改Deny from all 为 Allow from all。
重启apache使其生效。