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 install and configure Apache virtual host on CentOS 8

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

How to install and configure Apache virtual host on CentOS 8, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

Apache server is an open source HTTP server developed and maintained by modern operating systems such as UNIX and Windows. Apache provides a secure, efficient and scalable server that provides HTTP services synchronized with the current HTTP standard.

Experimental environment

Operating system: Centos 8

Web application: apache

Private network IP:192.168.3.21

Shell execution: root

Log in as root or a user with sudo privileges to do the following.

Install the httpd service

[root@linuxcool ~] # yum install httpd-devel.x86_64 httpd.x86_64 httpd-tools.x86_64

Verify that httpd is installed successfully

[root@linuxcool] # httpd-v Server version: Apache/2.4.6 (CentOS) Server built: Apr 2 2020 13:13:23

Start the httpd service

[root@linuxcool ~] # systemctl start httpd.service [root@linuxcool ~] # systemctl status httpd.service ● httpd.service-The Apache HTTP Server Loaded: loaded (/ usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2020-05-22 12:23:03 CST; 25s ago Docs: man:httpd (8) man:apachectl (8) Main PID: 952 (httpd) Status: "Total requests: 0 Current requests/sec: 0 Current traffic: 0 B/sec "Tasks: 6 Memory: 3.6m CGroup: / system.slice/httpd.service ├─ 952 / usr/sbin/httpd-DFOREGROUND ├─ 953 / usr/sbin/httpd-DFOREGROUND ├─ 954 / usr/sbin/httpd-DFOREGROUND ├─ 955 / usr/sbin/httpd-DFOREGROUND ├─ 956 / usr/sbin/httpd-DFOREGROUND └─ 957 / usr/sbin/httpd-DFOREGROUND May 22 12:23:03 linuxcool systemd [1]: Starting The Apache HTTP Server... May 22 12:23:03 linuxcool httpd [952]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, u...message May 22 12:23:03 linuxcool systemd [1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use-l to show in full.

Apache installed successfully. Default web directory / var/www/

test

Http://192.168.3.21/

Installation successful!

Configure an apache virtual host to create a website directory

[root@linuxcool] # mkdir-p / var/www/web1 [root@linuxcool ~] # mkdir-p / var/www/web2

Web1 add index.html

[root@linuxcool ~] # vim / var/www/web1/index.html Welcome to Web1 Success! Web1 home page!

Web2 add index.html

[root@linuxcool ~] # vim / var/www/web2/index.html Welcome to Web1 Success! Web1 home page!

Authorize web directory permissions

[root@linuxcool ~] # chown-R apache: / var/www/web1/ [root@linuxcool ~] # chown-R apache: / var/www/web2/

Create a virtual host file

# web1

[root@linuxcool ~] # vim / etc/httpd/conf.d/web1.conf ServerName web1.com ServerAlias www.web1.com ServerAdmin webmaster@example.com DocumentRoot / var/www/web1 Options-Indexes + FollowSymLinks AllowOverride All ErrorLog / var/log/httpd/example.com-error.log CustomLog / var/log/httpd/example.com-access.log combined

# web2

[root@linuxcool ~] # vim / etc/httpd/conf.d/web2.conf ServerName web2.com ServerAlias www.web2.com ServerAdmin webmaster@example.com DocumentRoot / var/www/web2 Options-Indexes + FollowSymLinks AllowOverride All ErrorLog / var/log/httpd/example.com-error.log CustomLog / var/log/httpd/example.com-access.log combined

Restart the httpd service

[root@linuxcool ~] # systemctl restart httpd.service

Verify the httpd virtual host result

Http://www.web1.com

Http://www.web2.com

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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