標籤:apche編譯安裝
安裝軟體包準備,需要安裝apr 1.5.2、apr-util 1.5.4,如果要啟用ssl需要安裝openssl軟體包,
1,安裝apr因為是編譯安裝,通過./configure --help命令查看相關選項。
[[email protected] apr-1.5.2]# yum install -y gcc[[email protected] apr-1.5.2]# ./configure --prefix=/usr/local/apr[[email protected] apr-1.5.2]# make & make install
2,安裝apr-util,在安裝時需要指明apr的安裝位置,以及--prefix路徑
[[email protected] apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/[[email protected] apr-util-1.5.4]# make & make install
3,安裝httpd2.4.23,需要安裝pcre、pcre-devel,如果啟用ssl需要安裝openssl、openssl-devel(版本需要在0.9.8a以上版本)
[[email protected] httpd-2.4.23]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-ssl --enable-modules=all[[email protected] httpd-2.4.23]# make & make install
4,配置httpd
a,修改環境變數
在/etc/profile/建立httpd.sh,增加export PATH=/usr/local/httpd/bin:$PATH ,(. /etc/profile.d/httpd.sh)匯入環境變數。
b,包含庫檔案,建立軟串連 ln -sv /usr/local/httpd/include /usr/local/include/httpd.
c,編輯man設定檔,添加httpd協助文檔,編輯/etc/man.config增加如下內容 MANPATH /usr/local/httpd/man
d,由於沒有服務指令碼,所以只能使用apachectl start命令執行啟動。
如果出現如下報錯AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using localhost.localdomain. Set the ‘ServerName‘ directive globally to suppress this message,需要編輯httpd.conf 增加ServerName localhost(主機名稱),再重新啟動即可。
ps -axu |grep httpd 可以看到httpd的進程,用瀏覽器開啟即可看到“It works!”。
服務指令碼如下:
#!/bin/bash##description: httpd service#chkconfig: - 85 15. /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ];then . /etc/sysconfig/httpdfiHTTPD_LANG=${HTTPD_LANG-"C"}INITLOG_ARGS=""proc=httpdapachectl=/usr/local/httpd/bin/apachectlhttpd=${httpd-/usr/local/httpd/bin/httpd}pidfile=${pidfile-/var/run/httpd/httpd.pid}lockfile=${lockfile-/var/lock/subsys/httpd}STOP_TIMEOUT=${STOP_TIMEOUT-10}RETVAL=0start() {echo -n $"Starting $prog: "LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL}stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}}reload() { echo -n $"Reloading $prog: " if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then RETVAL=6 echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else # Force LSB behaviour from killproc LSB=1 killproc -p ${pidfile} $httpd -HUP RETVAL=$? if [ $RETVAL -eq 7 ]; then failure $"httpd shutdown" fi fi echo}case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL=$? ;; restart) stop start ;; condrestart|try-restart) if status -p ${pidfile} $httpd >&/dev/null; then stop start fi ;; force-reload|reload) reload ;; graceful|help|configtest|fullstatus) $apachectl [email protected] RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}" RETVAL=2 ;;esacexit $RETVAL
至此基本配置完成。
本文出自 “10923086” 部落格,請務必保留此出處http://10933086.blog.51cto.com/10923086/1877274
Centos 6 編譯安裝 Apache 2.4