Red Hat Enterprise Linux 6下安裝Apache Httpd

1、進入Linux控制檯並下載相關軟件
2、解壓並進入安裝目錄
3、編譯與安裝

默認情況下apache會安裝在如下目錄中

/usr/local/apache2

4、啓動

# cd /usr/local/apache2/bin/

# ./apachectl start

如果你的主機名不是localhost的情況下,在啓動過程中可能會遇到如下問題:

httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName

修改apache的配置文件,/usr/local/apache2/conf下面

vi conf/httpd.conf

找到如下一下行:#ServerName www.example.com:80

在這行下面增加一行

ServerName localhost:80

重新啓動服務

# ./apachectl restart

查看服務有沒有啓動成功。

# ps -ef |grep httpd

Red Hat Enterprise Linux 6下安裝Apache Httpd - banbanaoxiang - banbanaoxiang的博客

服務已經啓動,接下來我們訪問一下:

Red Hat Enterprise Linux 6下安裝Apache Httpd - banbanaoxiang - banbanaoxiang的博客

很不幸的是我們無法訪問到,原因是RedHat默認開啓的防火牆規則裏不允許80端口訪問,修改防火牆配置即可

vi /etc/sysconfig/iptables

在裏面插入如下一行規則

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Red Hat Enterprise Linux 6下安裝Apache Httpd - banbanaoxiang - banbanaoxiang的博客

修改完之後重啓防火牆

/etc/init.d/iptables restart

Red Hat Enterprise Linux 6下安裝Apache Httpd - banbanaoxiang - banbanaoxiang的博客
重新訪問一下

Red Hat Enterprise Linux 6下安裝Apache Httpd - banbanaoxiang - banbanaoxiang的博客

 訪問成功

成功之後我們做一下基本的修改

把WebRoot指定到特定的物理目錄

Red Hat Enterprise Linux 6下安裝Apache Httpd - banbanaoxiang - banbanaoxiang的博客

 

Red Hat Enterprise Linux 6下安裝Apache Httpd - banbanaoxiang - banbanaoxiang的博客

重新啓動

/usr/local/apache2/bin/apachectl restart


Red Hat Enterprise Linux 6下安裝Apache Httpd - banbanaoxiang - banbanaoxiang的博客

OK安裝配置成功。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章