一. 首先安裝編譯工具:
// yum install gcc
//yum install gcc-c++
//yum install gcc-g77
二. 前往官方站點下載源碼包。
// 到/usr/local/src下進行下載
// wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.41.tar.gz 下載源碼包。
// tar -zxvf httpd-2.4.41.tar.gz 將壓縮包解壓。
三. 按照編譯安裝程序源碼包的步驟進行安裝。
步驟:
- ./configure --prefix=安裝路徑–>指定安裝路徑
- –with- =安裝路徑 -->關聯其他軟件。
- make 配置文件配置文件。
- make install 安裝
- 啓動。
具體安裝過程。
- 到 /usr/local/ httpd-2.4.41下執行 ./configure --prefix=/usr/local/apache
[root@fei httpd-2.4.41]# ./configure --prefix=/usr/local/apache
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
- 通過最後一行錯誤提示,需要安裝Apr。
將apr下載到/usr/local/src下,進入安裝apr
[root@fei src]# ls
apr-1.7.0 httpd-2.4.41
apr-1.7.0.tar.gz httpd-2.4.41.tar.gz
[root@fei apr-1.7.0]# ./configure --prefix=/usr/local/apr //安裝apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
.
.
.
config.status: executing libtool commands
rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands
config.status: include/apr.h is unchanged
config.status: include/arch/unix/apr_private.h is unchanged
//並且沒有報錯。
[root@fei apr-1.7.0]# make && make install //開始安裝
make[1]: Entering directory `/usr/local/src/apr-1.7.0'
.
.
.
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
//太好了,居然沒有報錯
-
返回到 /usr/local/ httpd-2.4.41下執行./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/
- 將 apache和apr關聯
[root@fei httpd-2.4.41]# ./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr/
checking for chosen layout... Apache
checking for working mkdir -p... yes
.
.
.
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
- 通過最後一行錯誤提示,需要安裝APR-util。
將apr-util下載到/usr/local/src下解壓,進入安裝apr-util
[root@fei src]# ls
apr-1.7.0 apr-util-1.6.1 httpd-2.4.41
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.41.tar.gz
[root@fei apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
.
.
.
config.status: creating include/private/apu_config.h
config.status: include/private/apu_config.h is unchanged
config.status: executing default commands //沒有出錯,可以安裝了。
[root@fei apr-util-1.6.1]# make && make install
make[1]: Entering directory `/usr/local/src/apr-util-1.6.1'
.
.
.
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr/bin/apu-1-config
//沒有出錯,安裝成功。
-
再次返回到 /usr/local/ httpd-2.4.41下執行./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
- 將 apache,apr,apr-util三者關聯
[root@fei httpd-2.4.41]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
checking for chosen layout... Apache
.
.
.
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
//通過最後一行錯誤提示,需要安裝pcre。
將pcre下載到/usr/local/src下解壓,進入安裝pcre
- 將pcre下載到/usr/local/src下解壓,進入安裝pcre,安裝步驟與之前相同。
- 安裝pcre前需要下載expat-devel
[root@fei pcre-8.44]# ./configure --prefix=/usr/local/pcre
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
.
.
.
Link pcretest with libreadline .. : no
Valgrind support ................ : no
Code coverage ................... : no
//並沒有報錯,可以安裝了。
[root@fei pcre-8.44]# make && make install
rm -f pcre_chartables.c
ln -s ./pcre_chartables.c.dist pcre_chartables.c
.
.
.
make[3]: Leaving directory `/usr/local/src/pcre-8.44'
make[2]: Leaving directory `/usr/local/src/pcre-8.44'
make[1]: Leaving directory `/usr/local/src/pcre-8.44'
//沒有報錯,安裝完成。
-
現在再次返回到 /usr/local/ httpd-2.4.41下執行./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
- apache,apr, apr-util,pcre關聯
[root@fei httpd-2.4.41]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with--prefix=/usr/local/pcre/
checking for chosen layout... Apache
.
.
.
LDFLAGS:
LIBS:
C preprocessor: gcc -E
//通過最後結果發現,終於不報錯了。可以安裝了
[root@fei httpd-2.4.41]# make && make install
Making all in srclib
.
.
.
mkdir /usr/local/apache/manual
make[1]: Leaving directory `/usr/local/src/httpd-2.4.41'
//沒有報錯,安裝完成。
- 這時在/usr/local下可以看到安裝的軟件
[root@fei local]# ls
apache apr apr-util bin etc games include lib lib64 libexec pcre sbin share src
- 現在前往開始apache/bin啓動
- 網卡啓動 ./apachectl start
- 網卡關閉 ./apachectl stop
[root@fei bin]# ./apachectl start //網卡啓動
AH00557: httpd: apr_sockaddr_info_get() failed for fei
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[root@fei bin]# ps -ef |grep httpd //網卡已經啓動
root 1771 1 0 23:24 ? 00:00:00 /usr/local/apache/bin/httpd -k start
root 1773 1443 0 23:24 pts/0 00:00:00 grep httpd
//網卡已經啓動
- 編輯 /etc/hosts -->127.0.0.1 主機名.example.com
[root@fei bin]# curl 192.168.126.132 / /打開網頁顯示It works!
<html><body><h1>It works!</h1></body></html>
- 發現連接失敗
- 更改端口:iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -j ACCEPT或者關閉防火牆iptables -F
- 重新啓動
現在看來是連接成功了