在安装过程中需要提前安装apache需要的依赖关系服务分别是pcre、apr和apr-util,这里我们选择稳定版本进行安装,httpd选择2.4.18版本,具体如下
-
[root@xxt02 ~]# ll
-
apr-1.5.2.tar.gz
-
apr-util-1.5.4.tar.gz
-
httpd-2.4.18.tar.gz
-
pcre-8.36.tar.gz
1.apr安装,选择安装目录为/usr/local/apr。在安装过程中遇到 rm: cannot remove `libtoolT': No such file or directory 问题,通过修改configure文件的解决,方式: $RM "$cfgfile" 修改为 $RM -f "$cfgfile"
-
cd apr-1.5.2
-
./configure --prefix=/usr/local/apr
-
make
-
make install
-
2.apr-util安装,选择安装目录/usr/local/apr-util,指定apr
-
cd apr-util-1.5.4
-
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
-
make
-
make install
3.pce安装,选择安装目录/usr/local/pcre
-
cd pcre-8.37
-
./configure --prefix=/usr/local/pcre
-
make
-
make install
4.安装http服务,这是最关键的服务
-
cd httpd-2.4.18
-
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
-
make
-
make install
4.1修改httpd.conf 参数文件,修改ServerName参数
-
ServerName localhost:80 或是 ServerName 127.0.0.1:80
4.2添加服务启动脚本
-
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
-
chkconfig --add httpd
-
chkconfig httpd on
-
-
httpd服务管理
-
-
service httpd {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}
4.3 也可以把httpd服务添加到系统环境变量中,通过httpd命令管理服务
-
echo 'export PATH=$PATH:/usr/local/httpd/bin' >> /etc/profile.d/httpd.sh
-
chmod +x /etc/profile.d/httpd.sh
-
source /etc/profile.d/httpd.sh
-
----------------------
-
httpd -k start 启动
-
httpd -k restart 重启
-
httpd -k graceful 重读配置文件
-
httpd -k stop 停止
-
----------------------
5. 服务验证,打开浏览器显示 It's work! 表示成功。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27039319/viewspace-2107306/
,如需转载,请注明出处,否则将追究法律责任。