APR: Apache portable Run-time libraries , Apache portable runtime libraries, mainly to provide upper-level applications with a low-level support interface library that can be used across multiple operating system platforms.
Environmental preparation:
CentOS7
installation package preparation:
main package: httpd-2.4.46.tar.gz
dependent package: apr-1.7.0.tar.gz, apr-util-1.6.1.tar.gz
related installation packages
yum -y install gcc make pcre-devel openssl-devel expat-devel
Unzip the installation package to /usr/local
tar xf apr-1.7.0.tar.gz -C /usr/local/
tar xf apr-util-1.6.1.tar.gz -C /usr/local/
tar xf httpd-2.4.46.tar.gz -C /usr/local/
Merging the source code of apr and apr-util with the source code of httpd
cd /usr/local/
mv apr-1.7.0/ httpd-2.4.46/srclib/apr
mv apr-util-1.6.1/ httpd-2.4.46/srclib/apr-util
[root@centos7 ~]#ll /usr/local/httpd-2.4.46/srclib/
total 16
drwxr-xr-x. 28 1001 1001 4096 Jan 22 09:31 apr
drwxr-xr-x. 21 1001 1001 4096 Jan 22 09:31 apr-util
-rw-r--r--. 1 root 40 121 Feb 11 2005 Makefile.in
Compile and install the three together
cd httpd-2.4.46
./configure \
--prefix=/app/httpd24 \ #设置安装位置
--enable-so \ #让apache核心装载DSO
--enable-ssl \ #开启SSL功能
--enable-cgi \ #实现CGI
--enable-rewrite \ #开启重读功能
--with-zlib \ #指定zlib压缩
--with-pcre \ #指定prec库
--with-included-apr \ #指定APR库
--enable-modules=most \ #开启绝大多数模块
--enable-mpms-shared=all \
--with-mpm=prefork #工作模式:prefork
make -j '可根据自己PC CPU内核按需设置,加快编译速度' && make install
Create a dedicated user
useradd -s /sbin/nologin -r apache
Specify the user running httpd
vim /app/httpd24/conf/httpd
user apache
group apache
Configure environment variables
echo 'PATH=/app/httpd24/bin:$PATH' > /etc/profile.d/http24.sh
. /etc/profile.d/http24.sh
Create a service unit file and set it to boot
vim /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=forking
#EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/app/httpd24/bin/apachectl start
#ExecStart=/app/httpd24/bin/httpd $OPTIONS -k start
ExecReload=/app/httpd24/bin/apachectl graceful
#ExecReload=/app/httpd24/bin/httpd $OPTIONS -k graceful
ExecStop=/app/httpd24/bin/apachectl stop
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl enable --now httpd
Configure man help
vim /etc/man_db.conf
MANDATORY_MANPATH /app/httpd24/man