CentOS 6.9
(1) Turn off SELinux
Note: If you do not turn off SELinux, there may be unpredictable problems such as forbidden when setting documentroot.
#sed -i ‘s/^SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config`
(2) Turn off iptables and add system users
You can also open port 80, which is directly closed for testing convenience
# /etc/init.d/iptables stop# groupadd -r apache# useradd -r -g apache apache
(3) Required dependency packages
# yum -y groupinstall "Development tools" "Server Platform Development"# yum -y install pcre-devel# yum -y install expat-devel
(4) Download the installation package
wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.29.tar.gz https://mirrors.aliyun.com/apache/apr/apr-1.6.3.tar.gz https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
(5) Install Apr
# tar xf apr-1.6.3.tar.gz# apr-1.6.3# ./configure --prefix=/usr/local/apr# make && make install
(6) Installation Apr-util
# tar xf apr-util-1.6.1.tar.gz # cd apr-util-1.6.1# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/# make && make install
(7) Installation httpd
# tar xf httpd-2.4.29.tar.gz # cd httpd-2.4.29# ./configure --prefix=/usr/local/apache --sysconf=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mem=event --libdir=/usr/lib64
(8) Adding environment variables
# echo "PATH=/usr/local/apache/bin/apachectl:$PATH" > /etc/profile.d/httpd.sh
(9) Start the HTTP service
# apachectl -k start
(10) Viewing the listening port
ss -tnl
Compiling and installing HTTPD 2.4