httpd需要依賴APR 、APR-Util和PCRE,各軟體下載下傳位址:
Apache HTTP Server http://httpd.apache.org/download.cgi#apache24
APR、APR-Util http://apr.apache.org/download.cgi
PCRE https://sourceforge.net/projects/pcre/files/pcre/
gcc(編譯C語言軟體)環境安裝
檢視gcc是否安裝
gcc -v
安裝gcc
yum install gcc-c++
expat(解析xml)環境安裝
yum install expat-devel
apr安裝
tar -zxvf apr-1.7.0.tar.gz
cd apr-1.7.0/
./configure --prefix=/usr/local/apr
make && make install
apr-util安裝
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make && make install
pcre安裝
tar -zxvf pcre-8.43.tar.gz
cd pcre-8.43/
./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config
make && make install
httpd安裝
tar -zxvf httpd-2.4.41.tar.gz
cd httpd-2.4.41/
./configure --prefix=/usr/local/httpd --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make && make install
添加httpd環境變量
#編輯系統環境變量檔案
vim /etc/profile
#在檔案末尾添加httpd路徑 儲存并退出
export PATH=/usr/local/httpd/bin:$PATH
#重新加載系統配置檔案,使之生效
source /etc/profile
添加httpd服務到systemctl
#進入 /usr/lib/systemd/system
cd /usr/lib/systemd/system
#編輯 httpd.service 檔案
vim httpd.service
#httpd.service 檔案加入以下内容 儲存并退出
#######################################################
[Unit]
Description=apache - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
###### httpd 安裝路徑
ExecStart=/usr/local/httpd/bin/httpd -k start
###### httpd 安裝路徑
ExecReload=/usr/local/httpd/bin/httpd -k restart
##### httpd 安裝路徑
ExecStop=/usr/local/httpd/bin/httpd -k stop
[Install]
WantedBy=multi-user.target
#######################################################
#授予 httpd.service 檔案權限
chmod 755 httpd.service
#重新加載服務配置檔案
systemctl daemon-reload
啟動/關閉httpd服務
systemctl start httpd
systemctl stop httpd
關閉Linux伺服器防火牆,通路 host:80