一、实验准备环境
-rw-r--r-- 1 root root 1093896 May 8 2019 apr-1.7.0.tar.gz
-rw-r--r-- 1 root root 554301 May 8 2019 apr-util-1.6.1.tar.gz
-rw-r--r-- 1 root root 7030539 May 8 2019 httpd-2.4.39.tar.bz2
yum groupinstall 'Development Tools'
yum -y install pcre-devel openssl-devel expat-devel
# 解压apr 和 apr-util 源码到 httpd 的srclib 目录中
tar xf apr-1.7.0.tar.gz
tar xf apr-util-1.6.1.tar.gz
mv apr-1.7.0 httpd/srclib/apr
mv apr-util-1.7.0 httpd/srclib/apr-util
二、开始编译和安装
./configure \
--prefix=/data/httpd24 \
--enable-so --enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-included-apr \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork
- 执行编译和安装(编译出现错误必须 make clean 后重新编译)
make && make install
apachectl start
ss -tnl
vim /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
[Service]
Type=simple
EnvironmentFile=/data/httpd24/conf/httpd.conf
ExecStart=/data/httpd24/bin/httpd -k start -DFOREGROUND
ExecReload=/data/httpd24/bin/httpd -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
[Install]
WantedBy=multi-user.target
# 重新加载httpd服务
systemctl daemon-reload
systemctl start httpd
参考文章
- Centos 7 编译安装apache 并使用unit文件管理启动