HTML静态页面配置到服务器
心血来潮,想要把HTML页面以最简单的方式布置到服务器上
一、首先安装httpd
[root@hadoop_zxy ~]# yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-97.el7.centos.2 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-97.el7.centos.2 for package: httpd-2.4.6-97.el7.centos.2.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-97.el7.centos.2.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-97.el7.centos.2 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing:
httpd x86_64 2.4.6-97.el7.centos.2 updates 2.7 M
Installing for dependencies:
httpd-tools x86_64 2.4.6-97.el7.centos.2 updates 94 k
mailcap noarch 2.1.41-2.el7 os 31 k
Transaction Summary
=====================================================================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 2.8 M
Installed size: 9.6 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00
(2/3): httpd-tools-2.4.6-97.el7.centos.2.x86_64.rpm | 94 kB 00:00:00
(3/3): httpd-2.4.6-97.el7.centos.2.x86_64.rpm | 2.7 MB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------
Total 4.8 MB/s | 2.8 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : httpd-tools-2.4.6-97.el7.centos.2.x86_64 1/3
Installing : mailcap-2.1.41-2.el7.noarch 2/3
Installing : httpd-2.4.6-97.el7.centos.2.x86_64 3/3
Verifying : httpd-2.4.6-97.el7.centos.2.x86_64 1/3
Verifying : mailcap-2.1.41-2.el7.noarch 2/3
Verifying : httpd-tools-2.4.6-97.el7.centos.2.x86_64 3/3
Installed:
httpd.x86_64 0:2.4.6-97.el7.centos.2
Dependency Installed:
httpd-tools.x86_64 0:2.4.6-97.el7.centos.2 mailcap.noarch 0:2.1.41-2.el7
Complete!
二、启动Httpd
[root@hadoop_zxy ~]# systemctl enable httpd.service #开机自启
[root@hadoop_zxy ~]# systemctl is-enabled httpd.service
abled
[root@hadoop_zxy ~]# systemctl start httpd.service
[root@hadoop_zxy ~]# 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 Tue 2021-12-28 12:38:24 CST; 25s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 14017 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─14017 /usr/sbin/httpd -DFOREGROUND
├─14018 /usr/sbin/httpd -DFOREGROUND
├─14019 /usr/sbin/httpd -DFOREGROUND
├─14020 /usr/sbin/httpd -DFOREGROUND
├─14021 /usr/sbin/httpd -DFOREGROUND
└─14022 /usr/sbin/httpd -DFOREGROUND
Dec 28 12:38:24 hadoop_zxy systemd[1]: Starting The Apache HTTP Server...
Dec 28 12:38:24 hadoop_zxy httpd[14017]: AH00558: httpd: Could not reliably determine the server's fully qualified domain n...message
Dec 28 12:38:24 hadoop_zxy systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
三、修改端口
[root@hadoop_zxy conf]# vim /etc/httpd/conf/httpd.conf
[root@hadoop_zxy conf]# systemctl restart httpd.service
四、测试页面
五、将HTML页面防止在/var/www/html目录下
[root@hadoop_zxy conf]# cd /var/www/html/
[root@hadoop_zxy html]# ls
index.html
[root@hadoop_zxy html]#