search
HomeOperation and MaintenanceApacheHow to configure multiple http ports in apache

How to configure multiple http ports in apache

Nov 03, 2020 pm 05:03 PM
apachehttpport

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. If there is any infringement, please contact admin@php.cn delete
Apache's Legacy: Impact on Web HostingApache's Legacy: Impact on Web HostingMay 06, 2025 am 12:03 AM

Apache's impact on Webhosting is mainly reflected in its open source features, powerful capabilities and flexibility. 1) Open source features lower the threshold for Webhosting. 2) Powerful features and flexibility make it the first choice for large websites and businesses. 3) The virtual host function saves costs. Although performance may decline in high concurrency conditions, Apache remains competitive through continuous optimization.

Apache: The History and Contributions to the WebApache: The History and Contributions to the WebMay 05, 2025 am 12:14 AM

Originally originated in 1995, Apache was created by a group of developers to improve the NCSAHTTPd server and become the most widely used web server in the world. 1. Originated in 1995, it aims to improve the NCSAHTTPd server. 2. Define the Web server standards and promote the development of the open source movement. 3. It has nurtured important sub-projects such as Tomcat and Kafka. 4. Facing the challenges of cloud computing and container technology, we will focus on integrating with cloud-native technologies in the future.

Apache's Impact: Shaping the InternetApache's Impact: Shaping the InternetMay 04, 2025 am 12:05 AM

Apache has shaped the Internet by providing a stable web server infrastructure, promoting open source culture and incubating important projects. 1) Apache provides a stable web server infrastructure and promotes innovation in web technology. 2) Apache has promoted the development of open source culture, and ASF has incubated important projects such as Hadoop and Kafka. 3) Despite the performance challenges, Apache's future is still full of hope, and ASF continues to launch new technologies.

The Legacy of Apache: A Look at Its Impact on Web ServersThe Legacy of Apache: A Look at Its Impact on Web ServersMay 03, 2025 am 12:03 AM

Since its creation by volunteers in 1995, ApacheHTTPServer has had a profound impact on the web server field. 1. It originates from dissatisfaction with NCSAHTTPd and provides more stable and reliable services. 2. The establishment of the Apache Software Foundation marks its transformation into an ecosystem. 3. Its modular design and security enhance the flexibility and security of the web server. 4. Despite the decline in market share, Apache is still closely linked to modern web technologies. 5. Through configuration optimization and caching, Apache improves performance. 6. Error logs and debug mode help solve common problems.

Apache's Purpose: Serving Web ContentApache's Purpose: Serving Web ContentMay 02, 2025 am 12:23 AM

ApacheHTTPServer continues to efficiently serve Web content in modern Internet environments through modular design, virtual hosting functions and performance optimization. 1) Modular design allows adding functions such as URL rewriting to improve website SEO performance. 2) Virtual hosting function hosts multiple websites on one server, saving costs and simplifying management. 3) Through multi-threading and caching optimization, Apache can handle a large number of concurrent connections, improving response speed and user experience.

Apache's Role in Web Development: Pioneering TechnologyApache's Role in Web Development: Pioneering TechnologyMay 01, 2025 am 12:12 AM

Apache's role in web development includes static website hosting, dynamic content services, reverse proxying and load balancing. 1. Static website hosting: Apache has simple configuration and is suitable for hosting static websites. 2. Dynamic content service: Provide dynamic content by combining it with PHP, etc. 3. Reverse proxy and load balancing: As a reverse proxy, it distributes requests to multiple backend servers to achieve load balancing.

Is Apache Dying? Debunking the MythsIs Apache Dying? Debunking the MythsApr 30, 2025 am 12:18 AM

Apache is not in decline. 1.Apache is still a stable and reliable choice, and continues to update performance optimization and security enhancement in version 2.4. 2. It supports extensive modular expansion, is simple to configure, but is not as efficient as Nginx when it is highly concurrency. 3. In actual applications, Apache improves SEO performance through modules such as mod_rewrite. 4. Apache can be integrated with modern technologies such as Docker to improve deployment and management efficiency. 5. Apache's performance can be significantly improved by tuning configuration and using optimization modules.

Apache: Configuring and Managing a Web ServerApache: Configuring and Managing a Web ServerApr 29, 2025 am 12:18 AM

The steps to configure and manage ApacheHTTPServer include: 1. Basic configuration: Set the server name, listening port, and document root directory. 2. Advanced configuration: Set up virtual host, enable SSL encryption and URL rewriting. 3. Performance optimization: Adjust KeepAlive settings and use cache. 4. Solve FAQs: Check configuration file syntax and optimize server parameters. Through these steps, you can ensure that the Apache server runs stably and optimize its performance.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor