1. 程式人生 > >編譯安裝httpd 2.4

編譯安裝httpd 2.4

profile http服務 tool modules lock 查看 apachectl mirror pac

CentOS 6.9

(1)關閉SELINUX

Note:如果不關閉SELINUX,在設置DocumentRoot的時候可能會出現Forbidden等各種不可預知的問題

#sed  -i ‘s/^SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config`

(2)關閉IPTABLES和添加系統用戶

也可以打開80端口,這裏為了測試方便就直接關閉

# /etc/init.d/iptables stop
# groupadd -r apache
# useradd -r -g apache apache

(3)需要的依賴包

# yum -y groupinstall "Development tools" "Server Platform Development"
# yum -y install pcre-devel
# yum -y install expat-devel

(4)下載安裝包

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)安裝apr

# tar xf apr-1.6.3.tar.gz
# apr-1.6.3
# ./configure --prefix=/usr/local/apr
# make && make install

(6)安裝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)安裝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)添加環境變量

# echo "PATH=/usr/local/apache/bin/apachectl:$PATH" > /etc/profile.d/httpd.sh

(9)啟動http服務

# apachectl -k start

(10)查看監聽端口

ss -tnl

編譯安裝httpd 2.4