本文档解决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>