Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure a virtual host by apache

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Apache

Apache HTTP Server (abbreviated as Apache) is an open source web server of the Apache Software Foundation, which can run in most computer operating systems. Because of its multi-platform and security, it is one of the most popular Web server-side software. It is fast, reliable and can compile interpreters such as Perl/Python into the server through a simple API extension.

Apache HTTP server is a modular server, derived from NCSAhttpd server, after many modifications, it has become the number one Web server software in the world.

Apache source code installation depends on apr

Apr update

1. Backup

Mv / etc/yum.repos.d/CentOS-Base.repo / etc/yum.repos.d/CentOS-Base.repo.backup

2. Download CentOS-Base.repo to / etc/yum.repos.d/

Cd / etc/yum.repos.d/

Wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

3. Generate cache

Yum clean all

Yum makecache

4. Update the system

Yum update

Install apr and other library files

Yum install apr*

There are three ways to realize Apache virtual host.

Virtual Host based on IP

Port-based virtual host

Virtual host based on domain name

Disable the default host mode

Comment on the following line

# DocumentRoot "/ var/www/html"

1. Virtual host configuration based on IP

Add multiple IP for the host

Ip addr add 192.168.137.201/24 dev eth0

Add virtual host profile

Vim / etc/httpd/conf/extra/httpd-vhost.conf

DocumentRoot "/ var/www/test200"

ServerName www.test200.com

DocumentRoot "/ var/www/test201"

ServerName www.test201.com

Create a directory test200 test201 under / var/www/

Create a home page with IP 200,201

2. Port-based virtual host configuration

Based on the original line Listen 80, add one line

Listen 8080

DocumentRoot "/ var/www/test200"

ServerName www.test200.com

# the following is added on the basis of the above configuration.

DocumentRoot "/ var/www/test200-8080"

ServerName www.test200-8080.com

Create a directory under / var/www/ test200-8080

Create a home page with an IP of 200-8080

3. Virtual host configuration based on domain name

DocumentRoot "/ var/www/html/kgccom"

ServerName www.kgc.com

ErrorLog "logs/www.kgc.com.error_log"

CustomLog "logs/www.kgc.com.access_log" common

< Directory "/var/www/html" >

Require all granted

DocumentRoot "/ var/www/html/kccecom"

ServerName www.kcce.com

Note: refer to the vhost.conf configuration file and uncomment in the main configuration file

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report