菜鳥上路,apache安裝及報錯

1、源碼包的安裝過程:

(1).上網下載.gz後綴文件
(2).打開WinSCP連接Linux 和 win7,解壓縮源碼包:
tar -zxvf httpd-2.4.33.tar.gz
(3).進入解壓縮目錄 :cd httpd-2.4.33/
(4).輸入 ./configure --prefix=/usr/local/apache2 此時報錯:
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
解決辦法:
[[email protected] httpd-2.4.1]# yum -y install pcre-devel

./configure 軟件配置與檢查
定義需要的功能選項
檢查系統環境是否符合預裝要求
把定義好的功能選項和檢測系統環境的信息都寫入Makefile文件,用於後續的編輯

(5).編譯
make
make clean
make install 編譯安裝

此時報錯: mod_proxy_balancer.c:25:24: fatal error: apr_escape.h: No such file or directory
原因是 開始沒有編譯安裝apr和apr-util。
解決辦法有兩個。
第一個是禁止該模塊。(來自:http://www.wanjishu.com/p/zn6v8T180330.html
跳過該錯誤,後期指定該模塊,一般安裝不成功,推薦解決該問題;
或者編譯參數可以去掉該模塊,禁止該模塊,添加--disable-proxy;
更換軟件版本,考慮到操作系統和軟件兼容性問題;

第二個解決辦法就是編譯安裝apr和apr-util(原文地址:http://blog.51cto.com/11060853/2105497
上面使用的辦法,詳情:
http://www.mamicode.com/info-detail-2263097.html
結果使用這個方式時又報錯:
rm: cannot remove 'libtoolT': No such file or directory config.status: execu
編輯configure這個文件,將 $RM “$cfgfile” 那行註釋掉 ,然後重新編譯即可。
然而,等我解決完這些問題之後,再去編譯,同樣報哪個錯誤,遂用第一個方法,成功。
./configure --prefix=/usr/local/apache2 --disable-proxy

(6).運行httpd:
/usr/local/apache2/bin/apachectl start
報錯:httpd: Could not reliably determine the server's fully qualified domain name
[root@server httpd-2.2.4]# /usr/local/apache/bin/apachectl start

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

1)進入apache的安裝目錄:(視個人安裝情況而不同) [root@server ~]# cd /usr/local/apache/conf
2)編輯httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80
[root@server conf]# ls
extra httpd.conf magic mime.types original
[root@server conf]# vi httpd.conf
#ServerName www.example.com:80
ServerName localhost:80
3)再重新啓動apache 即可。
[root@server ~]# /usr/local/apache2/bin/apachectl start restart

(7).關閉防火牆
centos從7開始默認用的是firewalld,這個是基於iptables的,雖然有iptables的核心,但是iptables的服務是沒安裝的。所以你只要停止firewalld服務即可:
sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service
用瀏覽器打開虛擬機Linux系統地址,如果顯示It work!則成功

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