centos安装httpd发布静态网页(一)
  DF5J4hb0hcmT 2023年11月19日 28 0

html网页发布到服务器上,需要安装httpd或者nginx之类。本文以apache httpd为例。

安装

[root@VM-0-5-centos zjd]# yum install httpd
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
docker-ce-stable                                                                                                                                              | 3.5 kB  00:00:00
epel                                                                                                                                                          | 4.7 kB  00:00:00
extras                                                                                                                                                        | 2.9 kB  00:00:00
os                                                                                                                                                            | 3.6 kB  00:00:00
updates                                                                                                                                                       | 2.9 kB  00:00:00
(1/3): docker-ce-stable/7/x86_64/primary_db                                                                                                                   | 118 kB  00:00:00
(2/3): epel/7/x86_64/primary_db                                                                                                                               | 7.0 MB  00:00:00
(3/3): epel/7/x86_64/updateinfo                                                                                                                               | 1.0 MB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-99.el7.centos.1 for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7_9.1 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 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-99.el7.centos.1                                 updates                                2.7 M
Installing for dependencies:
 apr                                        x86_64                                1.4.8-7.el7                                           os                                     104 k
 apr-util                                   x86_64                                1.5.2-6.el7_9.1                                       updates                                 92 k
 httpd-tools                                x86_64                                2.4.6-99.el7.centos.1                                 updates                                 94 k
 mailcap                                    noarch                                2.1.41-2.el7                                          os                                      31 k

Transaction Summary
=====================================================================================================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): apr-1.4.8-7.el7.x86_64.rpm                                                                                                                             | 104 kB  00:00:00
(2/5): apr-util-1.5.2-6.el7_9.1.x86_64.rpm                                                                                                                    |  92 kB  00:00:00
(3/5): httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm                                                                                                           |  94 kB  00:00:00
(4/5): httpd-2.4.6-99.el7.centos.1.x86_64.rpm                                                                                                                 | 2.7 MB  00:00:00
(5/5): mailcap-2.1.41-2.el7.noarch.rpm                                                                                                                        |  31 kB  00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                7.5 MB/s | 3.0 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-7.el7.x86_64                                                                                                                                            1/5
  Installing : apr-util-1.5.2-6.el7_9.1.x86_64                                                                                                                                   2/5
  Installing : httpd-tools-2.4.6-99.el7.centos.1.x86_64                                                                                                                          3/5
  Installing : mailcap-2.1.41-2.el7.noarch                                                                                                                                       4/5
  Installing : httpd-2.4.6-99.el7.centos.1.x86_64                                                                                                                                5/5
  Verifying  : httpd-2.4.6-99.el7.centos.1.x86_64                                                                                                                                1/5
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                                                                                       2/5
  Verifying  : apr-1.4.8-7.el7.x86_64                                                                                                                                            3/5
  Verifying  : httpd-tools-2.4.6-99.el7.centos.1.x86_64                                                                                                                          4/5
  Verifying  : apr-util-1.5.2-6.el7_9.1.x86_64                                                                                                                                   5/5

Installed:
  httpd.x86_64 0:2.4.6-99.el7.centos.1

Dependency Installed:
  apr.x86_64 0:1.4.8-7.el7             apr-util.x86_64 0:1.5.2-6.el7_9.1             httpd-tools.x86_64 0:2.4.6-99.el7.centos.1             mailcap.noarch 0:2.1.41-2.el7

Complete!

配置自动启动

[root@VM-0-5-centos zjd]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@VM-0-5-centos zjd]# systemctl is-enabled httpd.service
enabled
[root@VM-0-5-centos zjd]# systemctl start httpd.service
[root@VM-0-5-centos zjd]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2023-11-07 15:14:09 CST; 5s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 6407 (httpd)
   Status: "Processing requests..."
    Tasks: 6
   Memory: 2.8M
   CGroup: /system.slice/httpd.service
           ├─6407 /usr/sbin/httpd -DFOREGROUND
           ├─6408 /usr/sbin/httpd -DFOREGROUND
           ├─6409 /usr/sbin/httpd -DFOREGROUND
           ├─6410 /usr/sbin/httpd -DFOREGROUND
           ├─6411 /usr/sbin/httpd -DFOREGROUND
           └─6412 /usr/sbin/httpd -DFOREGROUND

Nov 07 15:14:09 VM-0-5-centos systemd[1]: Starting The Apache HTTP Server...
Nov 07 15:14:09 VM-0-5-centos httpd[6407]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' direc...his message
Nov 07 15:14:09 VM-0-5-centos systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

编写静态页面

[root@VM-0-5-centos zjd]# vi /var/www/
cgi-bin/ html/
[root@VM-0-5-centos zjd]# vi /var/www/html/index.html
[root@VM-0-5-centos zjd]# mkdir -p /var/www/html/zjd/
[root@VM-0-5-centos zjd]# vi /var/www/html/zjd/index.html

zjd/index.html内容如下

<!DOCTYPE html>
<html>
    <head>
        <title>sss</title>
    </head>
    <body>
        <h2>222</h2>
    </body>
</html>

centos安装httpd发布静态网页(一)_httpd

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月19日 0

暂无评论

推荐阅读
DF5J4hb0hcmT