作者小波/QQ463431476歡迎轉(zhuǎn)載!
redhat6采用centos yum源。
第一步下載apache依賴的軟件包并安裝
安裝 aPR下載地址:http://apr.apache.org/download.cgi
解壓包:tar -jxvf apr-1.5.0.tar.bz2 注意:這里的包的格式是tar.bz2格式,如果是.tar格式的用 tar -zxvf +包的名字 命令解壓。
進(jìn)入該包的文件夾內(nèi),依次執(zhí)行以下命令:
./configure --prefix=/work/installed/apr (注意:configure安裝的文件夾目錄可以自己定義)
make
make install
安裝 apr-util下載地址:http://apr.apache.org/download.cgi解壓包: tar -jxvfapr-util-1.5.3.tar.bz2
進(jìn)入該文件夾并依次執(zhí)行:
./configure --prefix=/work/installed/apr-util --with-apr=/work/installed/apr
make
make install
安裝 pcre 下載地址:http://pcre.org/解壓包:tar -jxvf pcre-8.35.tar.bz2
./configure --prefix=/work/installed/pcre
make
make install
注意:如果在安裝 pcre 時,遇到問題:configure: error: You need a C++ compiler for C++ support.Ubuntu的解決方法:sudo apt-get install build-essential
redhat6/centos6解決方法:yum安裝包即可:yum install gcc gcc-c++ kernel-devel第二步安裝Apache并配置:
安裝:
下載地址:http://httpd.apache.org/解壓:tar -jxvfhttpd-2.4.9.tar.bz2
進(jìn)入解壓后的文件內(nèi)并執(zhí)行:
./configure --prefix=/work/installed/apache --with-apr=/work/installed/apr --with-apr-util=/work/installed/apr-util --with- pcre=/work/installed/pcre --enable-module=shared
其中--enable-module=shared表示Apache可以動態(tài)的加載模塊,為以后安裝php鋪墊。
make
make install
注意:如果安裝錯誤,想重新裝的話,先刪除安裝的文件夾,然后在解壓后的文件夾內(nèi)執(zhí)行清除編譯:make clean all
第三步配置Apache:
修改配置文件,如果不修改的話就啟動了apache服務(wù)的話就會出現(xiàn)問題:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message解決方法:
在安裝的目錄下修改文件:
命令:vim/work/installed/apache/conf/httpd.conf 把: # ServerName www.example.com:80改為:ServerName localhost:80
然后也可以配置自己的發(fā)布主頁目錄:
同時也可以添加php的主頁:
如果 /etc/下有hosts文件的話修改:
修改文件: vi /etc/hosts
在后面輸入:192.168.8.119 server.example.com
ip地址改成自己的ip就行了。
啟動apache服務(wù):
輸入命令:/work/installed/apache/bin/apachectl start
開機自動啟動:vim etc/rc.local添加:/work/installed/apache/bin/apachectl start這里是apache的安裝目錄里面的配置文件,讓它開機自動啟動就行啦!
如果不行的話關(guān)閉防火墻:iptables -F
輸入IP地址可以看到:it works!
但是這種情況必須關(guān)閉防火墻,所以需要配置防火墻:
打開iptables的配置文件:vi /etc/sysconfig/iptables
添加一條80端口:(如果自己自定義端口的話,填寫自己的端口)
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
另外一篇yum安裝Apache以及Apache的配置,僅僅提供參考:
http://www.CUOXin.com/xiaobo-linux/p/4631675.html
新聞熱點
疑難解答