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