Home  >  Article  >  Operation and Maintenance  >  How to configure multiple http ports in apache

How to configure multiple http ports in apache

王林
王林forward
2020-11-03 17:03:214610browse

How to configure multiple http ports in apache

Method 1: Use httpd-vhosts

(Related recommendations: apache)

Enter the apache configuration directory, such as/ usr/local/apache/conf/

Open the httpd.conf file

Configure multiple listening windows 81, 82

ServerName localhost:81  
# Listen 80
Listen 81  
Listen 82

Find #Include conf/extra/httpd-vhosts .conf, remove the # sign, uncomment

Enter the /usr/local/apache/conf/extra directory, open the httpd-vhosts.conf file

Configure NameVirtualHost *:81

<VirtualHost *:81>
    ServerAdmin host1.example.com
    DocumentRoot "/home/public/web/host1"
    ServerName localhost:81
    ServerAlias localhost:81
    ErrorLog "logs/host1.example.com-error_log"
   #CustomLog "logs/host1.example.com-access_log common"
</VirtualHost>
    
<VirtualHost *:82>
    ServerAdmin host2.example.com
    DocumentRoot "/home/public/web/host2"
    ServerName localhost:82
    ErrorLog "logs/host1.example.com-error_log"
   #CustomLog "logs/host1.example.com-access_log common"
</VirtualHost>

Method 2: Only modify httpd.conf

Enter the apache configuration directory, such as /usr/local/apache/conf/

Open the httpd.conf file

Configuration Multiple listening windows, 81, 82

Listen   81
Listen   82

and add the following content at the end of the file:

<VirtualHost *:81>
DocumentRoot /home/public/web/host1
ServerName localhost:81
</VirtualHost>

<Directory /home/public/web/host1>
 Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<VirtualHost *:82>
DocumentRoot /home/public/web/host2
ServerName localhost:82
</VirtualHost>

<Directory /home/public/web/host2>
 Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

apache directory permission settings for different versions

1, old use

Order allow,deny
Allow from all

2, new use

Require all granted

3, new example

#add for WWW
Listen 91
<VirtualHost *:91>
DocumentRoot  "D:/IDE/WWW"
ServerName localhost:91
</VirtualHost>

<Directory "D:/IDE/WWW">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

The above is the detailed content of How to configure multiple http ports in apache. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete