系统: CentOS6.5_64
软件: httpd-2.4.10.tar.bz2
依赖: openssl-1.0.1j.tar.gz、apr-1.5.1.tar.bz2、apr-util-1.5.4.tar.bz2、pcre-devel
下载地址: http://www.openssl.org/source/ openssl
下载地址: http://httpd.apache.org/download.cgi httpd
下载地下: http://apr.apache.org/download.cgi apr,apr-util 是Apache的项目
pcre-devel 我们的系统安装光盘上就有。
首先我们先说明一些情况, 我们已经安装了基础开发包。
我们的系统上已经安装了apr和openssl,但是版本太低了,而它们还会被其它的软件所依赖,所以在不影响其它软件的情况下,就只能编译安装新的版本了。 而原来的httpd也会被其它的软件所依赖,不可以卸载。
1. 先把pcre-devel装上,直接yum安装。
1
yum install pcre-devel -y #-y 是直接安装的意思,敬我以前连-y都不知道。
2. 安装apr-1.5.1, 这个版本是我昨天下载的,现在是最新的版本。 低版本会安装不上event模块。
1
2
./configure --prefix=/usr/local/apr1.5 #只来个安装位置就可以
make && make install #稍等片片刻。
3. 安装apr-util-1.5.4.
1
2
3
4
./configure --prefix=/usr/local/apr1.5 --with-apr=/usr/local/apr1.5
#这个是apr的工具集,它依赖于上面的那个apr, 所以加上--with来指定我们安装apr的目录。
#跟apr安装在一个目录,现在看来没有什么问题。
make && make install
4. 安装openssl-1.0.1j
1
2
3
./config --prefix=/usr/local/openssl1j enable-shared
# enable-shared没有这一项, httpd编译会报错。 有点奇怪的是,在虚拟机上会报错,提示要加上-fPID。
make $$ make install
导出库文件,新建/etc/ld.so.conf.d/openssl1j.conf文件。 https会用到新版本的库文件。
1
2
vim /etc/ld.so.conf.d/openssl1j.conf
ldconfig
文件内容就写你的openssl安装目录下的lib的路径。 如:
1
/usr/local/openssl1j/lib
5. 安装httpd2.4.10
1
2
3
4
./configure --prefix=/usr/local/httpd2.4 --sysconfdir=/etc/httpd2.4 --enable-so --enable-ssl --enable-rewrite --enable-cgi --with-zlib --with-pcre --with-apr=/usr/local/apr1.5/ --with-apr-util=/usr/local/apr1.5/ --with-ssl=/usr/local/openssl1j/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event
make && make install
#--prefix 安装目录 --sysconfdir 配置文件目录 --enable-so 开启DSO动态装卸shared模块 --enable-ssl https的功能 --enable-rewrite 地址重写 --enable-cgi CGI脚本功能 --with-zlib 压缩功能的函数库 --with-pcre perl库 刚才安装的软件的目录 --enable-modules=most 编译常用的模块 --enable-mpms-shared=all 所有的动态模块 后面这个默认挂载MPM模块event.
6. 杂项
(1)去httpd的安装目录看一下结果。 一切OK的话就可以下面的了。
(2) 把httpd的头文件符号链接到/usr/include #不是必须的,怕以后有软件会用。
1
ln -s /usr/local/httpd2.4/include/ /usr/include/httpd2.4
(3) 新建/etc/profile.d/httpd2.4.sh文件,添加进PATH变量。
1
2
3
4
5
vim /etc/profile.d/httpd2.4.sh #写入文件内容,执行一个source
source /etc/profile.d/httpd2.4.sh
文件内容:
export PATH=/usr/local/httpd2.4/bin:$PATH
注意路径要写在PATH的前头,这样bash先找到的就是新的httpd了。 不然自动打开的又会是以前的那个httpd了。
1
2
[iyunv@CentOS-Office bin]# echo $PATH
/usr/local/httpd2.4/bin:/usr/local/httpd2.4/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
(4)停止你的老httpd, 来看看新的可不可以运行吧。
1
2
3
4
5
6
7
[iyunv@CentOS-Office openssl1j]# httpd
AH00557: httpd: apr_sockaddr_info_get() failed for CentOS-Office
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
[iyunv@CentOS-Office openssl1j]# httpd -v #查看版本
Server version: Apache/2.4.10 (Unix)
Server built: Nov 10 2014 11:10:33
[iyunv@CentOS-Office openssl1j]#
看来我这里暂时是可以运行了。 启动httpd的时候报的错,只要自已的主机名可以解析自已的IP,就没事了。 嗯,在我们这种只是做实验,做练习来说。 添加到/etc/hosts文件里是个不错的办法。
像我这里,加上一行:
172.16.2.0 CentOS-Office
就OK了。
(5) 来个服务脚本,可以用service来启动关闭。
为了避免麻烦,直接把原来的httpd的服务脚本复制一下,改吧改吧。
1
2
cp /etc/init.d/httpd /etc/init.d/httpd
vim /etc/init.d/httpd
先贴一下要改的部分, 占占版面。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
40
41 # Path to the apachectl script, server binary, and short-form for messages.
42 apachectl=/usr/sbin/apachectl #这一行要改,我就写下边了。
apachectl=/usr/local/httpd2.4/bin/apachectl #注意路径,看你安装在哪了。
43 httpd=${HTTPD-/usr/sbin/httpd} #这一行也要改
httpd=/usr/local/httpd2.4/bin/httpd #因为httpd2.4可以动态加载MPM模块。
#所以就不用运行不同MPM模块的程序,指定这一个就好。
#
44 prog=httpd
45 pidfile=${PIDFILE-/var/run/httpd/httpd.pid} #这一行改
pidfile=/var/run/httpd2.4/httpd2.4.pid #不是默认路径,还要改httpd配置文件,
#可以把路径改成你的安装目录下的logs目录,默认是在这里。
46 lockfile=${LOCKFILE-/var/lock/subsys/httpd} #这一行改
lockfile=/var/lock/subsys/httpd2.4 #
47 RETVAL=0
48 STOP_TIMEOUT=${STOP_TIMEOUT-10}
49
OK 保存退出。
上边的PID文件的路径如果用默认路径,就不用下边这几行了。
1
2
3
4
5
6
[iyunv@CentOS-Office run]# mkdir httpd2.4
[iyunv@CentOS-Office run]# chmod 700 httpd2.4/ #这个文件是由第一个httpd进程创建的
#这个进程是root启动的。root的权限。
[iyunv@CentOS-Office httpd2.4]# vim /etc/httpd2.4/httpd.conf
文件里面加入这一行:
pidFile "/var/run/httpd2.4/httpd2.4.pid"
好啦, 如果现在有httpd进程在运行, killall httpd
然后就可以启动试试啦。
1
2
[iyunv@CentOS-Office run]# service httpd start
正在启动 httpd: [确定]
这样暂时就算是安装完成了.
注意: httpd2.4的脚本是httpd , 而原来httpd2.2成了httpd.bak.
我们的脚本名称还是httpd. 以前httpd2.2的时候添加过chkconfig的话,就不用设置了。
chkconfig设置:
1
2
3
4
5
6
7
[iyunv@CentOS-Office run]# chkconfig --list httpd
httpd 服务支持 chkconfig,但它在任何级别中都没有被引用(运行“chkconfig --add httpd”)
[iyunv@CentOS-Office run]# chkconfig --add httpd
[iyunv@CentOS-Office run]# chkconfig httpd on
[iyunv@CentOS-Office run]# chkconfig --list httpd
httpd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[iyunv@CentOS-Office run]#
后记: 这样就可以了,初学中,哪位大侠路过发现问题,可一定要来一砖啊。
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com