Linux服務器---安裝apache


Apache安裝   

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

[root@localhost ~]# 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

[root@localhost ~]# service httpd start

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

                                                          [確定]

[root@localhost ~]#

 

3、設置apache開機自啟

[root@localhost ~]# chkconfig --level 5 httpd on 

[root@localhost ~]# chkconfig --list httpd

httpd          0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:啟用  6:關閉

[root@localhost ~]# 

 

4、修改防火牆

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

     1)關閉防火牆,

     在終端輸入setup命令

[root@localhost ~]# setup

     彈出窗口,選擇防火牆

     

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

     

     2)修改防火牆配置,

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

      

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

      

     選擇“添加“

      

     添加端口80,協議tcp,然后確定

      

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

      

     重啟防火牆

[root@localhost ~]# service iptables restart

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

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

iptables:正在卸載模塊:                                   [確定]

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

[root@localhost ~]#

     重啟apache

[root@localhost ~]# service httpd restart

停止 httpd                                              [確定]

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

                                                          [確定]

[root@localhost ~]# 

 

 

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

      

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM