一. 首先安装编译工具:
// yum install gcc
//yum install gcc-c++
//yum install gcc-g77
二. 前往官方站点下载源码包。
// 到/usr/local/src下进行下载
// wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.41.tar.gz 下载源码包。
// tar -zxvf httpd-2.4.41.tar.gz 将压缩包解压。
三. 按照编译安装程序源码包的步骤进行安装。
步骤:
- ./configure --prefix=安装路径–>指定安装路径
- –with- =安装路径 -->关联其他软件。
- make 配置文件配置文件。
- make install 安装
- 启动。
具体安装过程。
- 到 /usr/local/ httpd-2.4.41下执行 ./configure --prefix=/usr/local/apache
[root@fei httpd-2.4.41]# ./configure --prefix=/usr/local/apache
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /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。
将apr下载到/usr/local/src下,进入安装apr
[root@fei src]# ls
apr-1.7.0 httpd-2.4.41
apr-1.7.0.tar.gz httpd-2.4.41.tar.gz
[root@fei apr-1.7.0]# ./configure --prefix=/usr/local/apr //安装apr
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
.
.
.
config.status: executing libtool commands
rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands
config.status: include/apr.h is unchanged
config.status: include/arch/unix/apr_private.h is unchanged
//并且没有报错。
[root@fei apr-1.7.0]# make && make install //开始安装
make[1]: Entering directory `/usr/local/src/apr-1.7.0'
.
.
.
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
//太好了,居然没有报错
-
返回到 /usr/local/ httpd-2.4.41下执行./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/
- 将 apache和apr关联
[root@fei httpd-2.4.41]# ./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr/
checking for chosen layout... Apache
checking for working mkdir -p... yes
.
.
.
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
- 通过最后一行错误提示,需要安装APR-util。
将apr-util下载到/usr/local/src下解压,进入安装apr-util
[root@fei src]# ls
apr-1.7.0 apr-util-1.6.1 httpd-2.4.41
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.41.tar.gz
[root@fei apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
.
.
.
config.status: creating include/private/apu_config.h
config.status: include/private/apu_config.h is unchanged
config.status: executing default commands //没有出错,可以安装了。
[root@fei apr-util-1.6.1]# make && make install
make[1]: Entering directory `/usr/local/src/apr-util-1.6.1'
.
.
.
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr/bin/apu-1-config
//没有出错,安装成功。
-
再次返回到 /usr/local/ httpd-2.4.41下执行./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
- 将 apache,apr,apr-util三者关联
[root@fei httpd-2.4.41]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
checking for chosen layout... Apache
.
.
.
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
//通过最后一行错误提示,需要安装pcre。
将pcre下载到/usr/local/src下解压,进入安装pcre
- 将pcre下载到/usr/local/src下解压,进入安装pcre,安装步骤与之前相同。
- 安装pcre前需要下载expat-devel
[root@fei pcre-8.44]# ./configure --prefix=/usr/local/pcre
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
.
.
.
Link pcretest with libreadline .. : no
Valgrind support ................ : no
Code coverage ................... : no
//并没有报错,可以安装了。
[root@fei pcre-8.44]# make && make install
rm -f pcre_chartables.c
ln -s ./pcre_chartables.c.dist pcre_chartables.c
.
.
.
make[3]: Leaving directory `/usr/local/src/pcre-8.44'
make[2]: Leaving directory `/usr/local/src/pcre-8.44'
make[1]: Leaving directory `/usr/local/src/pcre-8.44'
//没有报错,安装完成。
-
现在再次返回到 /usr/local/ httpd-2.4.41下执行./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
- apache,apr, apr-util,pcre关联
[root@fei httpd-2.4.41]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with--prefix=/usr/local/pcre/
checking for chosen layout... Apache
.
.
.
LDFLAGS:
LIBS:
C preprocessor: gcc -E
//通过最后结果发现,终于不报错了。可以安装了
[root@fei httpd-2.4.41]# make && make install
Making all in srclib
.
.
.
mkdir /usr/local/apache/manual
make[1]: Leaving directory `/usr/local/src/httpd-2.4.41'
//没有报错,安装完成。
- 这时在/usr/local下可以看到安装的软件
[root@fei local]# ls
apache apr apr-util bin etc games include lib lib64 libexec pcre sbin share src
- 现在前往开始apache/bin启动
- 网卡启动 ./apachectl start
- 网卡关闭 ./apachectl stop
[root@fei bin]# ./apachectl start //网卡启动
AH00557: httpd: apr_sockaddr_info_get() failed for fei
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[root@fei bin]# ps -ef |grep httpd //网卡已经启动
root 1771 1 0 23:24 ? 00:00:00 /usr/local/apache/bin/httpd -k start
root 1773 1443 0 23:24 pts/0 00:00:00 grep httpd
//网卡已经启动
- 编辑 /etc/hosts -->127.0.0.1 主机名.example.com
[root@fei bin]# curl 192.168.126.132 / /打开网页显示It works!
<html><body><h1>It works!</h1></body></html>
- 发现连接失败
- 更改端口:iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -j ACCEPT或者关闭防火墙iptables -F
- 重新启动
现在看来是连接成功了