编译安装Apach
需要源码编译安装的软件包
httpd-2.4.41.tar.gz
apr-1.7.0.tar.gz
apr-util-1.6.1.tar.gz
pcre-8.44.tar.gz
首先下载最新的源码包
安装之前请先安装yum install openssl-devel make gcc gcc-c++ openssl expat-devel等编译工具和开发包
[root@apache-web apr-1.7.0]# yum -y install gcc make openssl gcc-c++
下载源码安装包
http://apache.website-solution.net//httpd/httpd-2.4.41.tar.gz
http://ftp.twaren.net/Unix/Web/apache//apr/apr-1.7.0.tar.gz
http://ftp.twaren.net/Unix/Web/apache//apr/apr-util-1.6.1.tar.gz
https://sourceforge.net/projects/pcre/files/pcre/8.43/pcre-8.43.tar.gz/download
[root@apache-web tools]# ll total 12712 -rw-r--r-- 1 root root 1093896 Feb 23 23:34 apr-1.7.0.tar.gz -rw-r--r-- 1 root root 554301 Feb 23 23:34 apr-util-1.6.1.tar.gz -rw-r--r-- 1 root root 9267917 Feb 23 23:34 httpd-2.4.41.tar.gz -rw-r--r-- 1 root root 2090750 Feb 23 23:34 pcre-8.44.tar.gz
源码安装的顺序:(要是哪个环境出现问题,不要复制粘贴手动敲,100%成功)
- apr-1.7.0.tar.gz
[root@apache-web tools]# tar xf apr-1.7.0.tar.gz [root@apache-web tools]# cd apr-1.7.0/ [root@apache-web apr-1.7.0]# ./configure --prefix=/usr/local/apr [root@apache-web apr-1.7.0]# make -j4 && make install [root@apache-web apr-1.7.0]# echo $? 0
- apr-util-1.6.1.tar.gz
[root@apache-web tools]# tar xf apr-util-1.6.1.tar.gz [root@apache-web apr-util-1.6.1]# cd apr-util-1.6.1/ 反斜杠 "\"表示一行没有写完,另起一行 [root@apache-web apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ [root@apache-web apr-util-1.6.1]# make -j4 && make install [root@apache-web apr-util-1.6.1]# echo $? 0
出现make[1]: Leaving directory `/server/tools/apr-util-1.6.1',只要目录在不用管
- pcre-8.44.tar.gz
[root@apache-web tools]# tar xf pcre-8.44.tar.gz
[root@apache-web tools]# cd pcre-8.44/
[root@apache-web pcre-8.44]# ./configure --prefix=/usr/local/pcre
[root@apache-web pcre-8.43]# make -j4 && make install
[root@apache-web pcre-8.43]# echo $?
0
出现,只要目录在不用管
make[3]: Leaving directory `/server/tools/pcre-8.43'
make[2]: Leaving directory `/server/tools/pcre-8.43'
make[1]: Leaving directory `/server/tools/pcre-8.43'
- httpd-2.4.41.tar.gz
[root@apache-web tools]# tar xf httpd-2.4.41.tar.gz
[root@apache-web tools]# cd httpd-2.4.41/
[root@apache-web httpd-2.4.41]# ./configure --prefix=/usr/local/apache
--enable-so
--enable-rewrite
--enable-ssl
--with-apr=/usr/local/apr/
--with-apr-util=/usr/local/apr-util/
--with-pcre=/usr/local/pcre/
[root@apache-web httpd-2.4.41]# make -j4 && make install
[root@apache-web httpd-2.4.41]# echo $?
0
--enable-so 支持动态加载模块
--enable-rewrite 支持网站地址重写
--enable-ssl 支持ssl加密
--with-apr=/usr/local/apr/ 关联apr
--with-apr-util=/usr/local/apr-util/ 关联apr-util
--with-pcre=/usr/local/pcre/ 关联pcre
编译安装,网站的站点目录/htdocs/
安装好,手动生成启动脚本
[root@apache-web apache]# cp -a bin/apachectl /etc/init .d [root@apache-web apache]# chmod +x /etc/init.d/apachectl 添加两行内容 [root@apache-web apache]#vim /etc/init.d/apachectl # chkconfig: 1345 64 36 # description: rm apache server
添加服务启动项目chkconfig
添加apachectl到服务启动项 [root@apache-web apache]# chkconfig --add apachectl 开启系统启动级别状态 [root@apache-web apache]# chkconfig apachectl on 查看apachectl状态 [root@apache-web apache]# chkconfig --list apachectl Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. apachectl 0:off 1:on 2:on 3:on 4:on 5:on 6:off
启动服务
[root@apache-web apache]# systemctl start apachectl [root@apache-web apache]# systemctl status apachectl ● apachectl.service - SYSV: rm apache server Loaded: loaded (/etc/rc.d/init.d/apachectl; bad; vendor preset: disabled) Active: active (exited) since Tue 2020-02-25 19:39:21 CST; 3s ago Docs: man:systemd-sysv-generator(8) Process: 20289 ExecStart=/etc/rc.d/init.d/apachectl start (code=exited, status=0/SUCCESS) Feb 25 19:38:55 apache-web systemd[1]: Starting SYSV: rm apache server... Feb 25 19:39:21 apache-web apachectl[20289]: AH00558: httpd: Could not reliably determine the server...sage Feb 25 19:39:21 apache-web apachectl[20289]: httpd (pid 20188) already running Feb 25 19:39:21 apache-web systemd[1]: Started SYSV: rm apache server. Hint: Some lines were ellipsized, use -l to show in full.
进行测试

评论