本文示範編譯安裝 httpd(httpd 2.4.4,相關套件可至 Apache 官網下載)。
先以 hwclock -s 把軟體時間同步為硬體時間,避免安裝出錯。
httpd-2.4.4 需要較新版的 apr 與 apr-util,這裡以原始碼升級(apr-1.5.2、apr-util-1.5.4):
# tar xf apr-1.5.2.tar.bz2 # cd apr-1.5.2 # ./configure --prefix=/usr/local/apr # make && make install # tar xf apr-util-1.5.4.tar.bz2 # cd apr-util-1.5.4 # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr # make && make install
此外還需事先安裝 pcre-devel;若編譯時報 OpenSSL 版本錯誤,則安裝 openssl-devel 並更新 openssl:
# yum -y install pcre-devel # yum -y install openssl-devel # yum update openssl
# tar xf httpd-2.4.4.tar.bz2 # cd httpd-2.4.4 # ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd \ --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=most --with-mpm=event # make && make install
參數含義:--prefix 指定安裝路徑;--sysconfdir 指定設定檔路徑;--enable-so 讓核心可裝載 DSO;--enable-ssl 支援 SSL;--enable-cgi 支援 CGI;--enable-rewrite 支援 URL 重寫;--with-zlib 支援 zlib;--with-pcre 含 pcre 函式;--enable-modules=most 支援共享模組;--with-mpm=event 載入 event 模組。
於 /etc/httpd/httpd.conf 加入 PidFile 路徑:
PidFile "/var/run/httpd.pid"
建立 /etc/rc.d/init.d/httpd(內容為標準的 httpd 啟動腳本,包含 start、stop、restart、reload、status 等 case 分支),然後賦予執行權並加入服務列表:
# chmod +x /etc/rc.d/init.d/httpd # chkconfig --add httpd
於 /etc/profile.d/httpd.sh 加入:
export PATH=$PATH:/usr/local/apache/bin
# service httpd restart
本文出自「10917734」部落格 https://10927734.blog.51cto.com/10917734/1851372