Linux operation and maintenance basics httpd static web page tutorial

Linux operation and maintenance basics httpd static web page tutorial

1. Use the warehouse to create the httpd lrzsz unzip file

1. Mount [root@clq0917 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected and will be mounted in read-only mode to write the configuration file [root@clq0917 ~]# vi /etc/yum.repos.d/aa.repo
[aa]
name=sssaaa
baseurl=file:///mnt
gpgcheck=0
enabled=1
 Press the ESC key and enter :x to save and clean up the warehouse [root@clq0917 ~]# yum clean all
 Metadata creation [root@clq0917 ~]# yum makecache
2.Install [root@clq0917 ~]# yum -y install httpd
[root@clq0917 ~]# yum -y install lrzsz 
[root@clq0917 ~]# yum -y install httpd
[root@clq0917 ~]# yum -y install unzip

2. Unzip the source code file

insert image description here

[root@clq0917 ~]# cd /var/www/html
Add file [root@clq0917 html]# rz
Unzip [root@clq0917 html]# unzip wangzhang.zip
mv (decoded data) + name (wangzhang)
[root@clq0917 html]# unzip zhishaizi.zip
mv (decoded data) + name (zhishaizi)
[root@clq0917 html]# unzip zhuawawa.zip
mv (decoded data) + name (zhuawawa)
Delete unused [root@clq0917 html]# rm -rf zhuawawa.zip
[root@clq0917 html]# rm -rf wangzhang.zip
[root@clq0917 html]# rm -rf zhishaizi.zip
Check:
[root@clq0917 html]# ls
wangzhang zhishaizi zhuawawa

3. 3 ways to configure httpd-vhosts.conf

1.[root@clq0917 html]# vi httpd-vhosts.conf 
Listen 98
<VirtualHost *:98>
    DocumentRoot "/var/www/html/wangzhang"
    ServerName wz.example.com
</VirtualHost>
Listen 99
<VirtualHost *:99>
    DocumentRoot "/var/www/html/zhuawawa"
    ServerName zww.example.com
</VirtualHost>
Listen 100
lHost *:100>
    DocumentRoot "/var/www/html/zhishaizi"
    ServerName zsz.example.com
</VirtualHost>
Refresh it:
[root@clq0917 html]# systemctl restart httpd
[root@qn conf.d]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port      
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*         
LISTEN 0 128 *:98 *:*         
LISTEN 0 128 *:99 *:*         
LISTEN 0 128 *:100 *:*         
LISTEN 0 128 [::]:22 [::]:*

Seeing port numbers 98, 99, and 100 indicates success.

Method 1: (same IP, different port number configuration)

1.[root@clq0917 html]# vi httpd-vhosts.conf 
Listen 98
<VirtualHost *:98>
    DocumentRoot "/var/www/html/wangzhang"
    ServerName wz.example.com
</VirtualHost>
Listen 99
<VirtualHost *:99>
    DocumentRoot "/var/www/html/zhuawawa"
    ServerName zww.example.com
</VirtualHost>
Listen 100
lHost *:100>
    DocumentRoot "/var/www/html/zhishaizi"
    ServerName zsz.example.com
</VirtualHost>
Refresh it:
[root@clq0917 html]# systemctl restart httpd
[root@qn conf.d]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port      
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*         
LISTEN 0 128 *:98 *:*         
LISTEN 0 128 *:99 *:*         
LISTEN 0 128 *:100 *:*         
LISTEN 0 128 [::]:22 [::]:*
Seeing port numbers 98, 99, and 100 indicates success.

Baidu search:

192.168.174.131:98
192.168.174.131:99
192.168.174.131:100

Effect picture:

insert image description here

insert image description here

insert image description here

Method 2: (different IP, same port number configuration)

1. Configure the IP address [root@clq0917 html]# ip addr add 192.168.174.175/24 dev ens33
[root@clq0917 html]# ip addr add 192.168.174.176/24 dev ens33
[root@clq0917 html]# vi httpd-vhosts.conf 
Listen 99
<VirtualHost 192.168.174.131:99>
    DocumentRoot "/var/www/html/wangzhang"
    ServerName wz.example.com
</VirtualHost>
<VirtualHost 192.168.174.175:99>
    DocumentRoot "/var/www/html/zhuawawa"
    ServerName zww.example.com
</VirtualHost>
lHost 192.168.174.176:99>
    DocumentRoot "/var/www/html/zhishaizi"
    ServerName zsz.example.com
</VirtualHost>
Refresh it:
[root@clq0917 html]# systemctl restart httpd
[root@qn conf.d]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port                   
LISTEN 0 128 *:99 *:*         
                          *:*         
LISTEN 0 128 [::]:22 [::]:*
Seeing port number 99 indicates success.

Baidu search:

192.168.174.131:99
192.168.174.175:99
192.168.174.176:99

Effect picture:

insert image description here

insert image description here

insert image description here

Method 3: (Same IP, same port number, different domain name)

1.[root@clq0917 html]# vi httpd-vhosts.conf 
Listen 80
<VirtualHost *:80>
    DocumentRoot "/var/www/html/wangzhang"
    ServerName wz.example.com
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "/var/www/html/zhuawawa"
    ServerName zww.example.com
</VirtualHost>
lHost *:80>
    DocumentRoot "/var/www/html/zhishaizi"
    ServerName zsz.example.com
</VirtualHost>
Refresh it:
[root@clq0917 html]# systemctl restart httpd
[root@qn conf.d]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port      
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*         
LISTEN 0 128 *:80 *:*         
Seeing port number 80 indicates success.
Go to C:\Windows\System32\drivers\etc on drive C, drag the hosts file to the desktop and open it with WordPad, add the following content and save it: 192.168.174.131 wz.example.com zww.example.com zsz.example.com
Drag the hosts file on the desktop back to the C:\Windows\System32\drivers\etc directory, open CMD, enter ping zww.example.com to see if it works, then use the domain name to access it in the browser

hosts:

insert image description here

insert image description here

cmd:

insert image description here

insert image description here

The above is the detailed content of the Linux operation and maintenance basic httpd static web page tutorial. For more information about Linux operation and maintenance httpd static web pages, please pay attention to other related articles on 123WORDPRESS.COM! Thanks for reading~

You may also be interested in:
  • Linux operation and maintenance basic swap partition and lvm management tutorial
  • Linux Operation and Maintenance Basic System Disk Management Tutorial
  • Linux operation and maintenance basic process management real-time monitoring and control
  • Linux operation and maintenance basic process management and environment composition analysis

<<:  How to design high-quality web pages Experience in designing high-quality web pages (pictures and text)

>>:  Detailed explanation of MySQL multi-table join query

Recommend

Use of CSS3's focus-within selector

Pseudo-elements and pseudo-classes Speaking of th...

How to use squid to build a proxy server for http and https

When we introduced nginx, we also used nginx to s...

Detailed explanation of how to use Vue to load weather components

This article shares with you how to use Vue to lo...

MySQL Learning: Three Paradigms for Beginners

Table of contents 1. Paradigm foundation 1.1 The ...

Vue component encapsulates sample code for uploading pictures and videos

First download the dependencies: cnpm i -S vue-uu...

Analyze how a SQL query statement is executed in MySQL

Table of contents 1. Overview of MySQL Logical Ar...

What does mysql database do

MySQL is a relational database management system ...

A brief discussion on how Tomcat breaks the parent delegation mechanism

Table of contents JVM Class Loader Tomcat class l...

A brief analysis of how to set the initial value of Linux root

Ubuntu does not allow root login by default, so t...

A brief discussion on the problem of forgotten mysql password and login error

If you forget your MySQL login password, the solu...

Detailed explanation of using split command to split Linux files

A few simple Linux commands let you split and rea...

Let's talk about the size and length limits of various objects in MySQL

Table of contents Identifier length limit Length ...

Detailed explanation of the concept of docker container layers

Table of contents 01 Container consistency 02 Con...

A brief talk about JavaScript Sandbox

Preface: Speaking of sandboxes, our minds may ref...

Vue.js handles Icon icons through components

Icon icon processing solution The goal of this re...