Example of creating a virtual host based on Apache port

Example of creating a virtual host based on Apache port

apache: create virtual host based on port

Take creating virtual hosts (a, b, c) as an example

1) 2.1.2 Disable the default host mode

[root@localhost httpd]# vim /etc/httpd/conf/httpd.conf
Comment out the following line in the main configuration file #DocumentRoot "/var/www/html"

2) Add the listening port in the main configuration file

Find the Listen line and add a line Listen 8080 based on the original line Listen 80 
Listen 81

3) Add port configuration virtual

[root@localhost httpd]#vim /etc/httpd/conf.d/virtualhost.conf
<VirtualHost 192.168.87.131:80>
  DocumentRoot "/var/www/a"
  ServerName www.a.com
</VirtualHost>
<VirtualHost 192.168.87.131:8080>
  DocumentRoot "/var/www/b"
  ServerName www.b.com
</VirtualHost>
<VirtualHost 192.168.87.131:81
  DocumentRoot "/var/www/c"
  ServerName www.c.com
</VirtualHost>

4) Create a new directory

[root@localhost conf.d]# cd /var/www 
[root@localhost www]# mkdir abc
[root@localhost www]# echo welcome to www.a.com >> ./a/index.html
[root@localhost www]# echo welcome to www.b.com >> ./b/index.html
[root@localhost www]# echo welcome to www.c.com >> ./c/index.html

5) Restart httpd

[root@localhost ~]#systemctl restart httpd

Note: Be sure to restart httpd!!!

Final result:

insert image description here

This is the end of this article about examples of creating virtual hosts based on Apache ports. For more information about creating virtual hosts based on Apache ports, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to add ports to Apache virtual hosts
  • Apache configuration multi-port multi-virtual host LAN access example
  • In-depth introduction to the method of configuring virtual hosts for Apache multi-port in Linux environment
  • Windows Apache multi-port virtual host configuration method

<<:  CSS Reset style reset implementation example

>>:  Vue multi-page configuration details

Recommend

Design reference WordPress website building success case

Each of these 16 sites is worth reading carefully,...

Practice of realizing Echarts chart width and height adaptation in Vue

Table of contents 1. Install and import 2. Define...

MySQL scheduled database backup operation example

This article describes the example of MySQL sched...

Detailed explanation on how to modify the default port of nginx

First find out where the configuration file is wh...

10 SQL statement optimization techniques to improve MYSQL query efficiency

The execution efficiency of MySQL database has a ...

How to use Javascript to generate smooth curves

Table of contents Preface Introduction to Bezier ...

How to install Docker on Raspberry Pi

Because the Raspberry Pi is based on ARM architec...

html option disable select select disable option example

Copy code The code is as follows: <select> ...

Detailed example of Linux all-round system monitoring tool dstat

All-round system monitoring tool dstat dstat is a...