In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Deployment of virtual host function based on Apache service
If only one website can run on the server of each Linux system, this obviously results in a waste of hardware resources.
By using the virtual host function, a physical server can be divided into multiple "virtual servers" to save resources and avoid waste.
The virtual host function of Apache is based on different IP addresses, host domain names or port numbers requested by users to provide access services for multiple websites at the same time.
Let's explain the implementation method in detail.
This experiment is based on cenos7 to build Apache httpd-2.4.6.
Install first
[root@lin10 ~] # yum install httpd-y
Since I need to implement this experiment based on different IP, I added three different IP
The ens33 card of this linux was originally 172.16.16.1 IP 16, so add two other CPUs to implement three different CPUs.
[root@localhost ~] # ip addr add 172.16.16.2Universe 16 dev ens33
[root@localhost ~] # ip addr add 172.16.16.3 Universe 16 dev ens33
Turn off Firewall systemctl disable firewalld
Close selinux vi / etc/sysconfig/selinux
Modify SELINUX=enforcing to disabled
One based on IP address
1 create three directories to store the data of different websites in / opt/www, and write the home page file to them.
Mkdir-p / opt/www/1
Mkdir-p / opt/www/2
Mkdir-p / opt/www/3
Echo "172.16.16.1" > / opt/www/1/index.html
Echo "172.16.16.2" > / opt/www/2/index.html
Echo "172.16.16.3" > / opt/www/3/index.html
2 start at about 113th line in the configuration file of httpd service, append and write three virtual host website parameters based on IP address respectively, then save and exit. Remember that you need to restart the httpd service for these configurations to take effect.
Vim / etc/httpd/conf/httpd.conf
one hundred and thirteen
114 DocumentRoot / opt/www/1
115 ServerName www.wawa.com
one hundred and sixteen
117 AllowOverride None
118 Require all granted
one hundred and nineteen
one hundred and twenty
one hundred and twenty one
122 DocumentRoot / opt/www/2
123 ServerName bbs.wawa.com
one hundred and twenty four
125 AllowOverride None
126 Require all granted
one hundred and twenty seven
one hundred and twenty eight
one hundred and twenty nine
130 DocumentRoot / opt/www/3
131 ServerName test.wawa.com
one hundred and thirty two
133 AllowOverride None
134 Require all granted
one hundred and thirty five
one hundred and thirty six
Don't forget to monitor port 80.
At this point, the virtual host function based on IP can be implemented, start the service and verify.
Second, based on port number
I was lazy and directly modified the previous IP-based configuration file to achieve a virtual host based on the port number.
Based on the three ports 80 8080 and 6111
Vim / etc/httpd/conf/httpd.conf
Listening port needs to be adjusted
Verify:
Based on host domain name
Based on the fact that the host domain name requires dns resolution to achieve this operation, the specific actions are not listed here (click).
It's the same as usual. I'll use the previous file to modify it.
Change the listening port to 80
Vim / etc/httpd/conf/httpd.conf
Verify:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.