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:214462browse

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


    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"

    

    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"

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:


DocumentRoot /home/public/web/host1
ServerName localhost:81



 Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all



DocumentRoot /home/public/web/host2
ServerName localhost:82



 Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

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

DocumentRoot  "D:/IDE/WWW"
ServerName localhost:91



    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted

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