码迷,mamicode.com
首页 > Web开发 > 详细

源码安装http

时间:2018-10-24 15:42:44      阅读:570      评论:0      收藏:0      [点我收藏+]

标签:follow   moved   pts   安装   apache2   tcp6   127.0.0.1   tables   link   

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

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

标签:follow   moved   pts   安装   apache2   tcp6   127.0.0.1   tables   link   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!