源码安装http

我们需要先下载三个源码包

wget http://httpd.apache.org/download.cgi/httpd-2.4.37.tar.gz
wget http://archive.apache.org/dist/apr/apr-1.5.0.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz

然后安装编译时需要用到的环境

yum install -y gcc gcc-c++ cmake

解压http源码包

tar -zxvf httpd-2.4.37.tar.gz

如果出现以下错误

[root@localhost httpd-2.4.37]# ./configure --prefix=/usr/local/apache24
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.

需要先安装apr

[root@localhost aprl-1.5.0]tar -zxvf apr-1.5.0.tar.gz

进入apr-1.5.0目录

./configure --prefix=/usr/local/apr/
make&&make install

解压apr-util

tar -zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4

配置apr-util

[root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util/
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.5.4
checking for chosen layout... apr-util
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
Applying apr-util hints file rules for x86_64-unknown-linux-gnu
checking for APR... no
configure: error: APR could not be located. Please use the --with-apr option.

报错了我们就按照错误指示重新配置

./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
make && make install

切换到http源的文件下

./configure --prefix=/usr/local/apache24/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/

又有新的错误

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org
/
下载pcre源码包

wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz
tar -zxvf pcre-8.42.tar.gz
cd pcre-8.42/
./configure --prefix=/usr/local/pcre/
make && make install

切换到http目录下

./configure --prefix=/usr/local/apache24/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
make && make install

关闭防火墙

[root@localhost httpd-2.4.37]# systemctl stop firewalld.service
[root@localhost httpd-2.4.37]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

启动apache服务

cd /usr/local/apache24/bin/

[root@localhost bin]# ./apachectl start
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

但是当我们查看端口时显示80已经启动了

[root@localhost bin]# netstat -napt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0: LISTEN 679/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:
LISTEN 1020/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0: LISTEN 1199/master
tcp 0 0 192.168.142.150:22 192.168.142.1:3295 ESTABLISHED 2111/sshd: root@pts
tcp 0 0 192.168.142.150:22 192.168.142.1:2396 ESTABLISHED 15748/sshd: root@pt
tcp6 0 0 :::111 :::
LISTEN 679/rpcbind
tcp6 0 0 :::80 ::: LISTEN 51813/httpd
tcp6 0 0 :::22 :::
LISTEN 1020/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1199/master

原因是服务器不能完全确认域名
解决方法:

vi /usr/local/apache24/conf/http.conf

把ServerName localhost:80前面的#去掉,保存退出即可。
杀死httpd进程,发现杀不死,于是重启虚拟机,开机后查看进程发现httpd没有启动
再次启动httpd进程的时候就不会出现不能确认域名的信息了。got it!
(后来发现用ps -aux查看http进程号,kill -9 进程id就可以成功杀死)
源码安装http

转载于:https://blog.51cto.com/13670314/2308293

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值