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

How to configure multiple http ports in apache

王林
Release: 2020-11-03 17:03:21
forward
4698 people have browsed it

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
Copy after login

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>
Copy after login

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
Copy after login

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>
Copy after login

apache directory permission settings for different versions

1, old use

Order allow,deny
Allow from all
Copy after login

2, new use

Require all granted
Copy after login

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>
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template