天天看點

Apache安裝

Apache是一個基金會的名字,httpd才是我們要安裝的軟體包,早期它的名字就叫apache

Apache官網www.apache.org

cd /usr/local/src/

apr和apr-util是一個通用的函數庫,它讓httpd可以不關心底層的作業系統平台,可以很友善地移植(從linux移植到windows)

2.2的apr和2.4所依賴的apr版本是不一樣的。Centos的yum安裝的apr和2.4是不比對的。是以需要自己編譯

tar zxvf httpd-2.4.27.tar.gz

tar zxvf apr-util-1.5.4.tar.gz

tar zxvf apr-1.5.2.tar.gz

cd apr-1.6.3

./configure --prefix=/usr/local/apr

make && make install

cd /usr/local/src/apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

cd /usr/local/src/httpd-2.4.27

./configure \ //這裡的反斜杠是脫義字元,加上它我們可以把一行指令寫成多行

--prefix=/usr/local/apache2.4 \

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util \

--enable-so \ //支援動态擴充子產品

--enable-mods-shared=most //絕大多數用到的子產品都加載

/usr/local/apache2.4/bin/apachectl start //啟動

cd /usr/local/apache2.4/

ls bin/httpd //二進制腳本

bin/httpd

ls conf/httpd.conf //配置檔案

conf/httpd.conf

ls htdocs/ //通路頁。預設網站

index.html

ls /usr/local/apache2.4/modules

/usr/local/apache2.4/bin/apachectl -M //apachectl腳本調用了二進制httpd檔案

/usr/local/apache2.4/bin/httpd -M //檢視加載的子產品

so_module (static) //說明是在httpd裡面的

http_module (static)

mpm_event_module (static)

authn_file_module (shared) //說明是擴充子產品。是一個可以看到的.so檔案在/usr/local/apache2.4/modules/下

問題!!make報錯

collect2: error: ld returned 1 exit status

make[2]: [htpasswd] 錯誤 1

make[2]: 離開目錄“/usr/local/src/httpd-2.4.27/support”

make[1]: [all-recursive] 錯誤 1

make[1]: 離開目錄“/usr/local/src/httpd-2.4.27/support”

make: *** [all-recursive] 錯誤 1

解決辦法:

cp -r apr-1.6.2  /usr/local/src/httpd-2.4.27/srclib/apr

cp -r apr-util-1.6.0  /usr/local/src/httpd-2.4.27/srclib/apr-util

#./configure --with-included-apr --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most

#make &&make install

錯誤!!

1.xml/apr_xml.c:35:19: 緻命錯誤:expat.h:沒有那個檔案或目錄

#include <expat.h>

[root@lsx-02 apr-util-1.6.0]# yum list |grep 'expat.'

2.configure: error: no acceptable C compiler found in $PATH

yum install -y gcc

yum list |grep -i PCRE

yum install -y pcre-devel.x86_64

本文轉自 蝦米的春天 51CTO部落格,原文連結:http://blog.51cto.com/lsxme/2050916,如需轉載請自行聯系原作者