apache安裝:
首先,解壓httpd包,進入解壓後的目錄,最先查看INSTALL文件,查看安裝步驟
接着:
第一步:./configure (配置編譯參數)
./configure \
> --prefix=/usr/local/apache2 \ //指定安裝到哪裏
> --with-included-apr \ //它是httpd要依賴的包,它支持httpd跨平臺去運作
> --enable-so \ //表示啓用DSO
> --enable-deflate=shared \ //表示動態共享的方式編譯deflate模塊
> --enable-expires=shared \ //表示動態共享的方式編譯expires模塊
> --enable-rewrite=shared \ //表示動態共享的方式編譯rewrite模塊
> --with-pcre
遇到的問題:
apache安裝遇到的問題:
1.出現:configure: error: no acceptable C compiler found in $PATH
是因爲你的機器裏沒有安裝任何C語言編譯器,可以安裝gcc (yum install -y gcc)
2.出現:configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
是因爲你的機器沒有安裝zlib包,可以用yum安裝:yum install -y zlib-devel
3.爲了避免在make 的時候錯誤,所以最好是提前安裝好一些庫文件
解決方法:yum install -y pcre pcre-devel apr apr-devel
第二步:make (編譯)
第三步:make install (安裝)
檢驗編譯安裝是否成功:echo $?
編譯安裝完成之後,進入你剛纔指定的文件位置(--prefix=/usr/local/apache2)
進入到apache2目錄之後,這個bin裏面的apachectl,是它的啓動文件,你可以這樣啓動:
/usr/local/apache2/bin/apachectl start
第二種方法:把bin/apachectl複製到/etc/init.d/目錄下並重命名:
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
啓動apache的時候,會有這樣一種情況:service httpd start
出現如下信息:“httpd:Could not reliably determine the server's fully qualified domain name,using localhost.localdomain for ServerName".
解決方法就是:找到你--prefix指定的文件路徑,進入到apache中,進入conf中,編輯httpd.conf
命令如下:cd /usr/local/apache2
cd conf
vi httpd.conf
打開這個httpd.conf文件之後,找到#ServerName www.example.com:80前面的#去掉,保存即可
apache的一些常用選項:
/usr/local/apache2/bin/apachectl -l //列出靜態模塊
/usr/local/apache2/bin/apachectl -t //查看配置文件有沒有錯誤)
/usr/local/apache2/bin/apachectl -M //把有哪些模塊列出來