安裝apache有點曲折,主要是apr導致的
安裝包: httpd-2.4.1.tar.bz2
下載地址:http://www.apache.org
首先要定義一個完整的主機名 :
否則在啓動apache的時候會有這樣的報錯:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
編輯 /etc/sysconfig/network 文件,然後重啓才能生效
開始安裝
]# chmod +x httpd-2.4.1.tar.bz2
]# tar jxf httpd-2.4.1.tar.bz2]# cd httpd-2.4.1
]# ./configure --prefix=/usr/local/apache
checking for APR... no
configure: error: APR not found. Please read the documentation.
發現沒有安裝apr相關包,然後就用yum批量安裝
]# yum install apr apr-util apr-devel apr-util-devel apr-util-mysql -y
再次運行configure出現這個報錯:
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
解救措施就是安裝pcre相關包
]# yum install pcre pcre-devel pcre-static -y
]# rpm -qa |grep pcre
pcre-7.8-3.1.el6.x86_64
pcre-devel-7.8-3.1.el6.x86_64
]# make
rotatelogs.c:(.text+0x5ed): undefined reference to `apr_file_link'
collect2: ld returned 1 exit status
make[2]: *** [rotatelogs] Error 1
檢查apr包是否已經安裝,事實證明已經安裝過了
[root@Webmail httpd-2.4.1]# rpm -qa |grep apr
apr-1.3.9-3.el6.x86_64
apr-util-1.3.9-3.el6.x86_64
apr-devel-1.3.9-3.el6.x86_64
apr-util-devel-1.3.9-3.el6.x86_64
apr-util-ldap-1.3.9-3.el6.x86_64
試了幾次都是同樣的報錯,把rpm包都卸載了,安裝apr源碼包
apr-1.3.8.tar.gzapr-util-1.3.8.tar.gz
安裝apr-util的時候需要指定apr的路徑 --with-apr=/usr/local/apr
重新安裝apache
./configure --prefix=/usr/local/apache --with-apr-util=/usr/local/apr-util
在make install的時候,SB錯誤又出現了
.libs/rotatelogs.o: In function `post_rotate':
/home/software/httpd-2.4.1/support/rotatelogs.c:298: undefined reference to `apr_file_link'
collect2: ld returned 1 exit status
看來不是apr包的問題了,難道是哪個地方沒有配置麼 ?
]# ./configure --prefix=/usr/local/apache/ --with-apr=/usr/local/apr/bin/apr-1-config --with-lib=/usr/local/apr/lib/ --with-apr-util=/usr/local/apr-util/
再續!!!!
今天又回來繼續這個問題
我把apr和apr-util全都make clean然後刪掉安裝路徑相關的文件/usr/local/apr
在apache官方網站上重新下載的apr包 apr-util包和httpd包
http://mirror.bit.edu.cn/apache//apr/
apr-1.4.5.tar.gz
apr-util-1.3.8.tar.gz
http://mirror.bit.edu.cn/apache//httpd/
httpd-2.4.1.tar.gz
在中途中除了遇到這樣一個蹩腳錯誤,我也不知道什麼原因導致的,就用yum install libtool -y 就ok了
info.lo -lrt -lcrypt -lpthread
libtool: link: `strings/apr_strings.lo' is not a valid libtool object
make: *** [libapr-1.la] 錯誤 1
[root@Webmail apr-1.4.5]# libtool: link: `strings/apr_strings.lo' is not a valid libtool object
make[1]: *** [libapr-1.la] 錯誤 1
make[1]: Leaving directory `/home/software/apr-1.4.5'
make: *** [all-recursive] 錯誤 1
重新整理一下安裝思路:
安裝環境:
]# yum install libtool apr apr-util apr-devel apr-util-devel apr-util-mysql pcre pcre-devel pcre-static -y
安裝apr
./configure --prefix=/usr/local/apr
make && make install
安裝apr-util
./configure --with-apr=/usr/local/apr
make && make install
安裝http
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/bin/apr-1-config --with-lib=/usr/local/apr/lib
make && make install
如果apr和apr安裝完整的話,再安裝http,應該沒問題,我覺得我的apr和apr-util沒有安裝完整
功夫不負有心人喲,O(∩_∩)O
-------------------------------------------------------
]# cp /home/software/httpd-2.4.1/support/apachectl /etc/init.d/httpd
開機自啓動
將service httpd start 加入文件 /etc/rc.d/rc.local
啓動服務
]# service httpd start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
]# ps aux |grep http
root 8571 0.0 0.1 71228 2588 ? Ss 17:03 0:00 /usr/local/apache/bin/httpd -k start
daemon 8572 0.0 0.2 415488 4460 ? Sl 17:03 0:00 /usr/local/apache/bin/httpd -k start
daemon 8573 0.0 0.2 415488 4464 ? Sl 17:03 0:00 /usr/local/apache/bin/httpd -k start
daemon 8574 0.0 0.2 415488 4468 ? Sl 17:03 0:00 /usr/local/apache/bin/httpd -k start
root 8658 0.0 0.0 105388 888 pts/0 S+ 17:03 0:00 grep http
]# netstat -anpt |grep 80
tcp 0 0 :::80 :::* LISTEN 8571/httpd
另外chkconfig不支持httpd,那麼可以用以下方式實現開機自動啓動:
]# vi /etc/init.d/httpd 在#/bin/sh下加入下列兩行
#chkconfig:2345 57 57
#description:Apache
PS:開頭必須得加#,要不然還是不支持chkconfig
]# ln -s /etc/init.d/httpd /etc/rc.d/rc2.d/S57httpd
]# ln -s /etc/init.d/httpd /etc/rc.d/rc53d/S57httpd
]# ln -s /etc/init.d/httpd /etc/rc.d/rc4.d/S57httpd
]# ln -s /etc/init.d/httpd /etc/rc.d/rc5.d/S57httpd
]# chkconfig --add httpd
]# chkconfig --list |grep httpd
檢測服務
然後在本機的瀏覽器地址欄中輸入localhost:80,看一下是否顯示“It Works”的提示