下载相关的软件包
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.29.tar.gz
安装APR
[root@mydb tmp]# tar -zxf apr-1.4.5.tar.gz [root@mydb tmp]# cd apr-1.4.5 [root@mydb apr-1.4.5]# ./configure --prefix=/usr/local/apr [root@mydb apr-1.4.5]# make && make install
安装APR-UTIL
[root@mydb tmp]# tar -zxf apr-util-1.3.12.tar.gz [root@mydb tmp]# cd apr-util-1.3.12 [root@mydb apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config --enable-utf8 [root@mydb apr-util-1.3.12]# make && make install
安装PCRE
[root@mydb tmp]#unzip -o pcre-8.10.zip [root@mydb tmp]#cd pcre-8.10 [root@mydb pcre-8.10]#./configure --prefix=/usr/local/pcre [root@mydb pcre-8.10]#make && make install
此时记得将上面的三个关联的软件包的路径在configure中指定。Apache2.4默认的安装路径是/usr/local/apache2。这里我指定到/u01/apache2.4目录。本次我把Apache的安装包放在/u01/soft/目录下。
创建APACHE程序存放的目录
[root@mydb soft]# mkdir /u01/apache2.4
开始安装
[root@mydb conf]# cd /u01/soft/ [root@mydb conf]# tar -zxf httpd-2.4.29.tar.gz [root@mydb soft]# cd httpd-2.4.29/ [root@mydb httpd-2.4.29]#./configure --prefix=/u01/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre [root@mydb httpd-2.4.29]#make && make install
修改httpd.conf的ServerName参数,新增一行ServerName localhost:80
[root@mydb conf]# cd /u01/apache2.4/conf
启动Apache
[root@mydb conf]# /usr/local/apache/bin/apachectl start
停止
[root@mydb conf]# /usr/local/apache/bin/apachectl -k stop
如果在安装之后,没有修改$PREFIX/conf/httpd.conf里面的ServerName,则会在启动和关闭报错:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.56.101. Set the 'ServerName' directive globally to suppress this message
修改/u01/apache2.4/conf/httpd.conf文件,搜索ServerName,新增一行ServerName
localhost:80。重启Apache即可。
测试访问Apache,出现”It works!”表示安装正常。
[root@mydb conf]# curl localhost:80 <html><body><h1>It works!</h1></body></html>