Apache httpd 2.4 源代碼安裝
這裏選用Apache2.4版本。
Apache2.4依賴包:
apr-1.6.5.tar.gz 下載:wget
http://mirrors.shu.edu.cn/apache//apr/apr-1.6.5.tar.gz
apr-util-1.6.1.tar.gz 下載:wget
http://mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
pcre-8.42.tar.gz 下載:wget
https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz
apache2.4 下載:wget
http://apache.fayea.com//httpd/httpd-2.4.27.tar.gz
安裝apr:
#tar -zxvf apr-1.46.tar.gz
#cd apr-1.46
#./configure --prefix=/usr/local/apr
#make
#make install
安裝apr-util:
#tar -zxvf apr-util-1.5.1.tar.gz
#cd apr-util-1.5.1
#./configure --with-apr=/usr/local/apr
#make
#make install
問題:
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
yum install expat-devel
安裝pcre:
#tar -zxvf pcre-8.32.tar.gz
#cd pcre-8.32
#./configure --prefix=/usr/local/pcre(此處出現configure: error: You need a C++ compiler for C++ support
#sudo yum install gcc-c++)
#make
#make install
安裝apache2.4:
#tar -zxvf httpd-2.4.37.tar.gz
#cd httpd-2.4.37
#./configure --prefix=/usr/local/apache24 --enable-so --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr/ --with-pcre=/usr/local/pcre/
#make
#make install
問題:
configure: error: Did not find pcre-config script at /usr/local/pcre/
在./configure 時添加 --with-pcre=/usr/local/pcre/bin/pcre-config
cannot find -lexpat
通常出現 cannot find -l****, 是由於相應的 相應爲庫有問題,因此要安裝該庫 或者 更新版本。
yum install -y expat*
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
緣由:該錯誤是由於缺乏了xml相關的庫,致使reference無效
解決方法:
①安裝libxml2-devel
[root@test_01 ~]# yum install -y libxml2-devel
②刪除apr-util目錄而且從新編譯安裝
③從新編譯安裝httpd,成功解決。
配置文件:
問題:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
vim /usr/local/apache/conf/httpd.conf
在「#ServerName
www.example.com:80」下面添加一行以下:
ServerName localhost:80
啓動服務:
usr/local/apache/bin/apachectl start
瀏覽器輸入localhost,顯示"It works!"
或 curl
http://localhost:80
(
注:實體機不能訪問虛擬機web服務器,能夠輸入
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save
service iptables restart
(將此處的80改成本身的web服務器的端口號)
)
或
firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl restart firewalld.service
firewall-cmd --reload
firewall-cmd --list-ports
firewall-cmd --remove-posr=8080/tcp