版权声明:版权归作者所有 https://blog.csdn.net/qq_36772866/article/details/82805734
前方高能预警
遇到的坑真多啊,
这坑虐我千百遍,还是要把它折腾一遍
1。获取apache
在Apache的官方站http://httpd.apache.org可以获取软件源码的下载地址
在这里我下载的是
httpd-2.4.34.tar.gz
需要注意的是
Apache2.4
它需要依赖库
ARP(Apache Portable Runtime)和 ARP-util(Apache Portable Runtime Utility),
其下载地址为 https://arp.apache.org
我这里下载的版本为
arp-1.6.5.tar.gz
arp-util-1.6.1.tar.gz
[root@localhost~]# tar -zxvf httpd-2.4.34.tar.gz
[root@localhost~]# tar -zxvf arp-1.6.5.tar.gz
[root@localhost~]# tar -zxvf arp-util-1.6.1.tar.gz
[root@localhost~]# mv arp-1.6.5 httpd-2.4.34/srclib/arp
[root@localhost~]# mv arp-util-1.6.1 httpd-2.4.34/srclib/arp-util
接下来可进来 Apache 源代码的解压目录查看文件列表
[root@localhost~]# cd httpd-2.4.34
[root@localhost httpd-2.4.34]# ls
[结果如下]
ABOUT_APACHE config.layout INSTALL NOTICE
acinclude.m4 config.log InstallBin.dsp NWGNUmakefile
Apache-apr2.dsw config.nice LAYOUT os
Apache.dsw config.status libhttpd.dep README
apache_probes.d configure libhttpd.dsp README.cmake
ap.d configure.in libhttpd.mak README.platforms
apr-util docs LICENSE ROADMAP
build emacs-style Makefile server
BuildAll.dsp httpd Makefile.in srclib
BuildBin.dsp httpd.dep Makefile.win support
buildconf httpd.dsp modules test
buildmark.o httpd.mak modules.c VERSIONING
CHANGES httpd.spec modules.lo
CMakeLists.txt include modules.o
Apache 提供了 ./configure --help 提供安装帮助
--prefix=path 安装路劲
--enable-so 开启DSO支持
--enable-deflate 开启压缩支持
--enable-ssl 开启 ssl 支持
等等还有很多参数,这里就不一一列举了
安装gcc等编译用的基础依赖及工具
yum install gcc gcc-c++ glibc glibc-devel gd gd-devel zlib zlib-devel libtool-ltdl-devel flex autoconf automake unzip wget -y
开始配置 apache 的安装路径
[root@localhost~]# cd httpd-2.4.34
[root@localhost httpd-2.4.34]# ./configure --prefix=/usr/local/apache24 --enable-so --enable-deflate --enable-ssl
[root@localhost httpd-2.4.34]# make && make install
这个时候会报错了
就是那两个我们准备的依赖库,没派上用场
这下就要用到了,
报错信息如下
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory `/usr/local/httpd-2.4.34/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/httpd-2.4.34/support'
make: *** [all-recursive] Error 1
这个时候我们要编译安装前面那两个依赖库了
[root@localhost~]# cd arp-1.6.5
[root@localhost arp-1.6.5]# ./configure --prefix=/usr/local/arp
[root@localhost arp-1.6.5]# make && make install
[root@localhost~]# cd arp-util-1.6.1
[root@localhost arp-util-1.6.1]# ./configure --prefix=/usr/local/arp-util --with-arp=/usr/local/arp/bin/arp-1-config
[root@localhost arp-util-1.6.1]# make && make install
wget -c https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
tar -xf pcre-8.41
cd pcre-8.41
./configure --prefix=/usr/local/pcre
make && make install
这样还不行哦,可能还会报错
还需要一下操作
[root@localhost~]# mv arp-1.6.5 httpd-2.4.34/srclib/arp
[root@localhost~]# mv arp-util-1.6.1 http-2.4.34/srclib/arp-util
[root@localhost~]# cd http-2.4.34
[root@localhost http-2.4.34]# cd srclib
[root@localhost srclib]# ls
[结果]
apr apr-util Makefile Makefile.in
然后开始重新配置安装路劲
[root@localhost~]# cd httpd-2.4.34
[root@localhost httpd-2.4.34]# ./configure --prefix=/usr/local/apache24 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-mods-shared=most --enable-so --with-included-apr --enable-so --enable-deflate --enable-ssl
[root@localhost httpd-2.4.34]# make && make install
祝你好运吧,希望你能踏过此坑,就会轻松了
最后编译安装完成之后
mkdir /usr/local/apache24/conf
mkdir /usr/local/apache24/conf/extra
mkdir /usr/local/apache24/conf/original
mkdir /usr/local/apache24/conf/original/extra
Installing HTML documents
mkdir /usr/local/apache24/htdocs
Installing error documents
mkdir /usr/local/apache24/error
Installing icons
mkdir /usr/local/apache24/icons
mkdir /usr/local/apache24/logs
Installing CGIs
mkdir /usr/local/apache24/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /usr/local/apache24/man
mkdir /usr/local/apache24/man/man1
mkdir /usr/local/apache24/man/man8
mkdir /usr/local/apache24/manual
make[1]: Leaving directory `/root/httpd-2.4.34'
当了看到这里的时候,意味着可能安装成功了
[root@localhost ~]# cd /usr/local/apache24
[root@localhost apache24]# ls
[结果]
bin cgi-bin error icons lib man modules
build conf htdocs include logs manual
- 后续配置
在安装完成 Apache 之后,为了方便,我们可以在service服务启动
[root@localhost ~]# vi /etc/init.d/http.d
找到下面文本
#!/bin/bash
#chkconfig: _ 85 15
添加 脚本
/usr/local/apache24/bin/apachectl $1
保存 htpd 脚本,为该文件添加可以执行的权限
chmod +x /etc/init.d/httpd
接下来就是 实现 停止,启动,
[root@localhost ~]# service httpd start
[root@localhost ~]# service httpd stop
[root@localhost ~]# service httpd restart
到此完美收工