本文檔解決AppacheHttp由版本2.2.x升級到版本2.4.29的問題,安裝需要先進行依賴軟件包的安裝,請檢查相應依賴軟件包安裝情況,如系統已經正確安裝相應依賴軟件包,可略過,本文所述版本升級不會覆蓋先前的apache服務器
1. 安裝包准備

將上述所有源碼包上傳到/tmp目錄下,並用root用戶登陸
2. 安裝expat-2.1.0
cd /tmp
tar -zxvf expat-2.1.0.tar.gz
cd expat-2.1.0
./configure
make && make install
3. 安裝apr-1.6.3.tar.gz
cd /tmp
tar -zxvf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix=/usr/local/apr
make && make install
4. 安裝apr-util-1.5.4
cd /tmp
tar -jxvf apr-util-1.5.4.tar.bz2
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
5. 安裝pcre-8.41
cd /tmp
tar -zxvf pcre-8.41.tar.gz
cd pcre-8.41
./configure --prefix=/usr/local/pcre
make && make install
6. 安裝httpd-2.4.29
cd /tmp
tar -zxvf httpd-2.4.29.tar.gz
cp -rf apr-1.6.3 httpd-2.4.29/srclib/apr
cp -rf apr-util-1.5.4 httpd-2.4.29/srclib/apr-util
cd httpd-2.4.29
./configure --prefix=/opt/apache2 --enable-mods-shared=all --enable-deflate --enable-speling --enable-cache --enable-file-cache --enable-disk-cache --enable-mem-cache --enable-rewrite --enable-so --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --with-included-apr
make && make install
注意:
可能出現的錯誤:make時出現server/.libs/libmain.a(exports.o):(.data+0xcfc): undefined reference to `apr_os_uuid_get’,解決辦法:
cd /tmp/ httpd-2.4.29
cd srclib/apr;
make
cd ..
cd srclib/apr-util;
make
再退回 apache 的源碼目錄重新 make
cd /tmp/ httpd-2.4.29
make && make install
如想再安裝一個更新的apache服務,使用
./configure --prefix=/opt/apache3 --enable-mods-shared=all --enable-deflate --enable-speling --enable-cache --enable-file-cache --enable-disk-cache --enable-mem-cache --enable-rewrite --enable-so --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --with-included-apr --enable-ssl
其它命令不變,只是--prefix=路徑 改變即可
7. 修改配置文件
cd /opt/apahce2/conf
vi httpd.conf
ServerName 配置為127.0.0.1:80
Include conf/extra/httpd-info.conf 這一行前的#去掉
以上為測試配置
如果想把兩個老apache遷移過來,請參考原來配置文件,將配置文件中的配置信息(見備注)覆蓋過來
8. 重新啟動apache
#ps -ef | grep apache
#kill -9 進程名(如果有進程)
啟動新安裝的apache服務
/opt/apache2/bin/httpd -k start -f /opt/apache2/conf/httpd.conf
9. 驗證
在瀏覽器中輸入:http://服務器ip出現下圖說明正常

備注:
原apacheHttpdServer安裝路徑為/opt/apahce和/opt/apache1
更新的apacheHttpdServer安裝路徑/opt/apache2
配置文件路徑/opt/apache2/conf/httpd.conf
頁面部署路徑/opt/apache2/htdocs
停止服務:/opt/apache2/bin/httpd -k stop -f /opt/apache2/conf/httpd.conf(或 /opt/apache2/bin/apachectl start)
開啟服務:/opt/apache2/bin/httpd -k start -f /opt/apache2/conf/httpd.conf(或 /opt/apache2/bin/apachectl stop)
如需安裝兩個新服務,第二個路徑可設置在/opt/apache3,當要進行 make clean一下,否則出錯,安裝過程等同/opt/apache2的操作。
老版本apahce配置信息備份:
1 ServerRoot "/opt/apache" 2
3 Listen 8081 4
5 NameVirtualHost 172.17.130.166 6
7 <VirtualHost 172.17.130.166>
8
9 ServerName www.GuangSoft.com 10
11 </VirtualHost>
12
13 <VirtualHost 172.17.130.166>
14
15 ServerName m.GuangSoft.com 16
17 </VirtualHost>
18
19 ServerName localhost:8081 20
21 DocumentRoot "/home/weblogic/GuangSoft" 22
23 <Directory />
24
25 Options FollowSymLinks 26
27 AllowOverride None 28
29 Order deny,allow 30
31 Deny from all 32
33 </Directory>
34
35 <Directory /home/weblogic/GuangSoft/WEB-INF>
36
37 Order allow,deny 38
39 Deny from all 40
41 </Directory>
42
43 <Directory "/home/weblogic/GuangSoft">
44
45 <FilesMatch ".(php|asp|jsp)$">
46
47 Deny from all 48
49 </FilesMatch>
50
51 </Directory>
52
53 <Directory "/home/weblogic/GuangSoft">
54
55 Options -Indexes FollowSymLinks 56
57 AllowOverride None 58
59 Order allow,deny 60
61 Allow from all 62
63 </Directory>
64
65 <IfModule alias_module>
66
67 ScriptAlias /cgi-bin/ "/opt/apache/cgi-bin/" 68
69 Alias /GuangSoftPayment "/home/weblogic/GuangSoftPayment" 70
71 Alias /GuangSoftAccount "/home/weblogic/GuangSoftAccount" 72
73 Alias /investor "/home/weblogic/investor" 74
75 Alias /GuangSoftzxzx "/home/weblogic/GuangSoftzxzx" 76
77 Alias /GuangSoftPortal "/home/weblogic/GuangSoftPortal" 78
79 </IfModule>
80
81 <Directory "/opt/apache/cgi-bin">
82
83 AllowOverride None 84
85 Options None 86
87 Order allow,deny 88
89 Allow from all 90
91 </Directory>
92
93 <Directory "/home/weblogic/GuangSoftPayment">
94
95 AllowOverride None 96
97 Options None 98
99 Order allow,deny 100
101 Allow from all 102
103 </Directory>
104
105 <Directory "/home/weblogic/GuangSoftPortal">
106
107 AllowOverride None 108
109 Options None 110
111 Order allow,deny 112
113 Allow from all 114
115 </Directory>
116
117 <Directory "/home/weblogic/GuangSoftAccount">
118
119 AllowOverride None 120
121 Options None 122
123 Order allow,deny 124
125 Allow from all 126
127 </Directory>
128
129 <Directory "/home/weblogic/investor">
130
131 AllowOverride None 132
133 Options None 134
135 Order allow,deny 136
137 Allow from all 138
139 </Directory>
140
141 <Directory "/home/weblogic/GuangSoftzxzx">
142
143 AllowOverride None 144
145 Options None 146
147 Order allow,deny 148
149 Allow from all 150
151 </Directory>
