官方安裝教程 http://httpd.apache.org/docs/2.4/install.html
一.下載安裝包
進入https://httpd.apache.org/download.cgi#apache24
下載 tar.gz包
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.39.tar.gz
二.安裝
1.解壓
tar -xzvf httpd-2.4.39.tar.gz mv httpd-2.4.39 httpd
正確的安裝(這個是安裝失敗后的總)
wget http://us.mirrors.quenda.co/apache//apr/apr-1.7.0.tar.gz wget http://us.mirrors.quenda.co/apache//apr/apr-util-1.6.1.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
#解壓后進入各自目錄運行
cd /usr/local/httpd/srclib/apr ./configure make make install cd /usr/local/httpd/srclib/apr-util ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make make install
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
mv pcre httpd/srclib/pcre
./configure --prefix=/usr/local/pcre make make install
./configure -with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make
make install
2.安裝
./configure --enable-rewrite=shared
錯誤解決參考:https://blog.csdn.net/zhtking120/article/details/9762315
報錯1. APR not found. Please read the documentation.
sudo apt-get install libapr1-dev libaprutil1-dev
報錯2. 還是報錯
可能上一個問題沒有解決: 進入這里 從Apache APR下載APR和APR-Util的最新版本,將它們解壓縮到./srclib/apr和./srclib/apr-util(確保域名沒有版本號;例如,APR分發必須在./srclib/apr/下
wget http://us.mirrors.quenda.co/apache//apr/apr-1.7.0.tar.gz wget http://us.mirrors.quenda.co/apache//apr/apr-util-1.6.1.tar.gz tar -xzvf apr-1.7.0.tar.gz tar -xzvf apr-util-1.6.1.tar.gz mkdir ./srclib apr-1.7.0 ./srclib/apr mv apr-util-1.6.1 ./srclib/apr-util cd /usr/local/httpd/srclib/apr ./configure make make install cd /usr/local/httpd/srclib/apr-util ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make make install
又報錯ubuntu xml/apr_xml.c:35:10: fatal error: expat.h:
apt-get install libexpat1-dev
報錯3. no acceptable C compiler found in $PATH
apt-get install build-essential
報錯4. configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz mv pcre httpd/srclib/pcre ./configure --prefix=/usr/local/pcre make make install
繼續編譯
./configure -with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make
make install
中途如有亂七八糟的報錯將上面安裝的東西刪除重新裝一邊
安裝成功
三.啟動測試
ln -s /usr/local/apache2/bin/apachectl /sbin/
apachectl start
報錯1. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0
解決方法:進入apache的安裝目錄 編輯httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80
ServerName localhost:80 #亦可以用域名