分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

源码安装http

发布时间:2023-09-06 02:19责任编辑:胡小海关键词: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

原文地址:http://blog.51cto.com/13670314/2308293

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved