iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 11
0
自我挑戰組

30天學 LAMP 安裝系列 第 11

Day11 CentOS 7 安裝 Apache

  • 分享至 

  • xImage
  •  

參考資料

步驟

  1. 安裝 httpd 套件

     $ sudo yum install httpd -y
     Loaded plugins: fastestmirror
     Determining fastest mirrors
      * base: free.nchc.org.tw
      * extras: free.nchc.org.tw
      * updates: free.nchc.org.tw
     base                                                                                          | 3.6 kB  00:00:00
     extras                                                                                        | 3.4 kB  00:00:00
     updates                                                                                       | 3.4 kB  00:00:00
     (1/4): base/7/x86_64/group_gz                                                                 | 166 kB  00:00:00
     (2/4): extras/7/x86_64/primary_db                                                             | 215 kB  00:00:00
     (3/4): base/7/x86_64/primary_db                                                               | 6.0 MB  00:00:01
     (4/4): updates/7/x86_64/primary_db                                                            | 7.4 MB  00:00:01
     Resolving Dependencies
     --> Running transaction check
     ---> Package httpd.x86_64 0:2.4.6-89.el7.centos.1 will be installed
     --> Processing Dependency: httpd-tools = 2.4.6-89.el7.centos.1 for package: httpd-2.4.6-89.el7.centos.1.x86_64
     --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-89.el7.centos.1.x86_64
     --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-89.el7.centos.1.x86_64
     --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-89.el7.centos.1.x86_64
     --> Running transaction check
     ---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
     ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
     ---> Package httpd-tools.x86_64 0:2.4.6-89.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-89.el7.centos.1                 updates                2.7 M
     Installing for dependencies:
      apr                        x86_64                1.4.8-3.el7_4.1                       base                   103 k
      apr-util                   x86_64                1.5.2-6.el7                           base                    92 k
      httpd-tools                x86_64                2.4.6-89.el7.centos.1                 updates                 91 k
      mailcap                    noarch                2.1.41-2.el7                          base                    31 k
    
     Transaction Summary
     =====================================================================================================================
     Install  1 Package (+4 Dependent packages)
    
     Total download size: 3.0 M
     Installed size: 10 M
     Downloading packages:
     (1/5): apr-util-1.5.2-6.el7.x86_64.rpm                                                        |  92 kB  00:00:00
     (2/5): apr-1.4.8-3.el7_4.1.x86_64.rpm                                                         | 103 kB  00:00:00
     (3/5): mailcap-2.1.41-2.el7.noarch.rpm                                                        |  31 kB  00:00:00
     (4/5): httpd-tools-2.4.6-89.el7.centos.1.x86_64.rpm                                           |  91 kB  00:00:00
     (5/5): httpd-2.4.6-89.el7.centos.1.x86_64.rpm                                                 | 2.7 MB  00:00:00
     ---------------------------------------------------------------------------------------------------------------------
     Total                                                                                3.3 MB/s | 3.0 MB  00:00:00
     Running transaction check
     Running transaction test
     Transaction test succeeded
     Running transaction
       Installing : apr-1.4.8-3.el7_4.1.x86_64                                                                        1/5
       Installing : apr-util-1.5.2-6.el7.x86_64                                                                       2/5
       Installing : httpd-tools-2.4.6-89.el7.centos.1.x86_64                                                          3/5
       Installing : mailcap-2.1.41-2.el7.noarch                                                                       4/5
       Installing : httpd-2.4.6-89.el7.centos.1.x86_64                                                                5/5
       Verifying  : httpd-2.4.6-89.el7.centos.1.x86_64                                                                1/5
       Verifying  : mailcap-2.1.41-2.el7.noarch                                                                       2/5
       Verifying  : httpd-tools-2.4.6-89.el7.centos.1.x86_64                                                          3/5
       Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                       4/5
       Verifying  : apr-1.4.8-3.el7_4.1.x86_64                                                                        5/5
    
     Installed:
       httpd.x86_64 0:2.4.6-89.el7.centos.1
    
     Dependency Installed:
       apr.x86_64 0:1.4.8-3.el7_4.1      apr-util.x86_64 0:1.5.2-6.el7     httpd-tools.x86_64 0:2.4.6-89.el7.centos.1
       mailcap.noarch 0:2.1.41-2.el7
    
     Complete!
    
  2. 啟動 httpd 服務

     $ sudo systemctl start httpd
    
  3. 啟用 httpd 服務,讓 httpd 服務每次開機就會自動被帶起來

     $ sudo systemctl enable httpd
     Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
    
  4. 檢視 httpd 服務啟動狀態

     $ sudo systemctl status httpd
     ● httpd.service - The Apache HTTP Server
        Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
        Active: active (running) since Wed 2019-09-11 10:36:47 CST; 21s ago
          Docs: man:httpd(8)
                man:apachectl(8)
      Main PID: 1722 (httpd)
        Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
        CGroup: /system.slice/httpd.service
                ├─1722 /usr/sbin/httpd -DFOREGROUND
                ├─1723 /usr/sbin/httpd -DFOREGROUND
                ├─1724 /usr/sbin/httpd -DFOREGROUND
                ├─1725 /usr/sbin/httpd -DFOREGROUND
                ├─1726 /usr/sbin/httpd -DFOREGROUND
                └─1727 /usr/sbin/httpd -DFOREGROUND
    
     Sep 11 10:36:46 centos7-cli.lab.example.com systemd[1]: Starting The Apache HTTP Server...
     Sep 11 10:36:47 centos7-cli.lab.example.com systemd[1]: Started The Apache HTTP Server.
    
  5. 開通本機防火牆

     [doraemon@centos7-cli ~]$ sudo firewall-cmd --permanent --add-service=http
     success
     [doraemon@centos7-cli ~]$ sudo firewall-cmd --reload
     success
    
  6. 在其他台電腦開啟網頁測試 OK。

    https://ithelp.ithome.com.tw/upload/images/20190911/20119707qpQzin4NOS.png


上一篇
Day10 CentOS 7 安裝 MySQL 5.7/8.0
下一篇
Day12 CentOS 7 安裝 Nginx
系列文
30天學 LAMP 安裝33
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言