1. 程式人生 > >Linux伺服器---安裝apache

Linux伺服器---安裝apache

Apache安裝   

1、安裝Apache,使用命令“yum install httpd -y

[[email protected] ~]# yum install httpd -y

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

base                                                    | 4.0 kB     00:00 ... 

Setting up Install Process

 

2、啟動apache

[[email protected] ~]# service httpd start

正在啟動 httpdhttpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

                                                          [

確定]

[[email protected] ~]#

 

3、設定apache開機自啟

[[email protected] ~]# chkconfig --level 5 httpd on 

[[email protected] ~]# chkconfig --list httpd

httpd          0:關閉  1:關閉  2:關閉  3:

關閉  4:關閉  5:啟用  6:關閉

[[email protected] ~]# 

 

4、修改防火牆

想要其他機器訪問到該主機的apache,要麼關閉防火牆,要麼就修改防火牆的配置

1)關閉防火牆,

在終端輸入setup命令

[[email protected] ~]# setup

彈出視窗,選擇防火牆

     

     彈出視窗,用空格關閉防火牆,儲存退出(有*是啟動)

     

     2)修改防火牆配置,

     在終端輸入命令“setup”,在彈出的框中選擇“防火牆”,接著選擇“定製”

      

     使用空格鍵選中“http“、”https“,接著選擇“轉發”

      

     選擇“新增“

      

     新增埠80,協議tcp,然後確定

      

     回到最初的介面,“確定”

      

重啟防火牆

[[email protected] ~]# service iptables restart

iptables:將鏈設定為政策 ACCEPTfilter nat                [確定]

iptables:清除防火牆規則:                                 [確定]

iptables:正在解除安裝模組:                                   [確定]

iptables:應用防火牆規則:                                 [確定]

[[email protected] ~]#

重啟apache

[[email protected] ~]# service httpd restart

停止 httpd                                              [確定]

正在啟動 httpdhttpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

                                                          [確定]

[[email protected] ~]# 

 

 

5、測試,在其他區域網電腦輸入本機的ip地址,看到如下介面代表apache安裝成功