在centos6编译安装httpd-2.4方法一

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在centos6编译安装httpd-2.4方法一相关的知识,希望对你有一定的参考价值。

安装httpd-2.4
依赖于apr-1.4+, apr-util-1.4+, [apr-iconv]
apr: apache portable runtime,解决跨平台实现
CentOS 6:默认:apr-1.3.9, apr-util-1.3.9
安装前准备开发包:
开发环境包组:
Development Tools,Server
相关包:pcre-devel,openssl-devel expat-devel
下载源代码并解压缩:
httpd-2.4.27.tar.bz2
apr-1.6.2.tar.bz2
apr-util-1.6.0.tar.bz2
第一步:先安装所需要的包。(工作中不要装包组,挑一些去装)
yum groupinstall "development tools"
yum install openssl-devel pcre-devel expat-devel
[[email protected] apr-1.6.3]# yum install libtool
[[email protected] ~]# mkdir httpd2.4
[[email protected] ~]# cd httpd2.4/
把源代码传到里面;
[[email protected] httpd2.4]#rz
然后解压缩。
tar xvf apr-1.6.3.tar.bz2
tar xvf apr-util-1.6.1.tar.bz2
tar xvf httpd-2.4.29.tar.bz2
编译httpd之前要先编译APR
第二步:现在我们先去编译APR ( apr-1.6.3)
[[email protected] httpd2.4]# cd apr-1.6.3
[[email protected] apr-1.6.3]# ls
apr-config.in buildconf dso libapr.rc NOTICE support
apr.dep build.conf emacs-mode LICENSE NWGNUmakefile tables
apr.dsp build-outputs.mk encoding locks passwd test
apr.dsw CHANGES file_io Makefile.in poll threadproc
apr.mak CMakeLists.txt helpers Makefile.win random time
apr.pc.in config.layout include memory README tools
apr.spec configure libapr.dep misc README.cmake user
atomic configure.in libapr.dsp mmap shmem
build docs libapr.mak network_io strings
[[email protected] apr-1.6.3]# ./configure --prefix=/app/apr (开始编译)
[[email protected] apr-1.6.3]#make -j 4 && make install
[[email protected] apr-1.6.3]# ls /app
apr
[[email protected] apr-1.6.3]# cd ..
[[email protected] httpd2.4]# ls
apr-1.6.3 apr-util-1.6.1 httpd-2.4.29
apr-1.6.3.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.29.tar.bz2
[[email protected] httpd2.4]# cd apr-util-1.6.1
[[email protected] apr-util-1.6.1]# ls
aprutil.dep build.conf docs LICENSE redis
aprutil.dsp build-outputs.mk encoding Makefile.in renames_pending
aprutil.dsw CHANGES export_vars.sh.in Makefile.win strmatch
aprutil.mak CMakeLists.txt hooks memcache test
apr-util.pc.in config.layout include misc uri
apr-util.spec configure ldap NOTICE xlate
apu-config.in configure.in libaprutil.dep NWGNUmakefile xml
buckets crypto libaprutil.dsp README
build dbd libaprutil.mak README.cmake
buildconf dbm libaprutil.rc README.FREETDS
[[email protected] apr-util-1.6.1]# ./configure --prefix=/app/apr-util --with-apr=/app/apr
[[email protected] apr-1.6.3]#make -j 4 && make install

第三部:编译安装httpd2.4
[[email protected] apr-util-1.6.1]# cd ..
[[email protected] httpd2.4]# cd httpd-2.4.29
[[email protected] httpd2.4]#./configure --prefix=/app/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-apr=/app/apr/ \
--with-apr-util=/app/apr-util/ \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork
[[email protected] httpd-2.4.29]# make -j 4 && make install

[[email protected] httpd-2.4.29]# cd /app
[[email protected] app]# ls
apr apr-ut httpd24

第四步:环境变量。
[[email protected] httpd24]# cd bin
[[email protected] bin]# ls
ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolve
apachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs

[[email protected] bin]# echo ‘PATH=/app/httpd24/bin/:$PATH‘ > /etc/profile.d/httpd24.sh
[[email protected] bin]# . /etc/profile.d/httpd24.sh
[[email protected] bin]# apachectl start
第五步:用户和组
(这里注意:如果是最小化安装,apache 用户是没有的,要手工进行创建。
[[email protected] bin]# getent passwd apache
apache:x:48:48:Apache:/var/www:/sbin/nologin
创建的方法是:
useradd -r -s /sbin/nologin apache
[[email protected] bin]#ss -ntlp

第六部:配置文件
[[email protected] bin]# cd /root/httpd2.4/
[[email protected] httpd2.4]# ls
apr-1.6.3 apr-util-1.6.1 httpd-2.4.29
apr-1.6.3.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.29.tar.bz2
[[email protected] httpd2.4]# cd httpd-2.4.29/
[[email protected] httpd-2.4.29]# ls
apr-1.6.3 apr-util-1.6.1 httpd-2.4.29
apr-1.6.3.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.29.tar.bz2
[[email protected] httpd2.4]# cd httpd-2.4.29/
[[email protected] httpd-2.4.29]# cd /app/httpd24/conf/
[[email protected] conf]# ls
extra httpd.conf magic mime.types original
[[email protected] conf]# vim /app/httpd24/conf/httpd.conf
技术分享图片
user apache
group apache

[[email protected] conf]# apachectl restart (重启服务)
[[email protected] conf]# ps aux
技术分享图片

现在就可以试试啦:
[[email protected] ~]# curl 192.168.10.107
<html><body><h1>It works!</h1></body></html>
它的路径放在:
技术分享图片
[[email protected] ~]# cd /app/httpd24/
[[email protected] httpd24]# ls
bin build cgi-bin conf error htdocs icons include logs man manual modules
[[email protected] httpd24]# cd htdocs
[[email protected] htdocs]# ls
index.html

第七步:开机脚本。

设为开机启动:
[[email protected] conf]# echo "/app/httpd24/bin/apachectl start" >> /etc/rc.d/rc.local
开机重启。
最好写脚本:
cp /etc/init.d/httpd /etc/init.d/httpd24
vim /etc/init.d/httpd24
apachectl=/app/httpd24/bin/apachectl
httpd=${HTTPD-/app/httpd24/bin/httpd}
pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
技术分享图片
[[email protected] ~]# ll /etc/init.d/httpd24
读写执行的权限。
chkconfig --add httpd24
chkconfig httpd24 on
service httpd24 start
reboot

vim /etc/rc.d/rc.local

/app/httpd24/bin/apachectl start 就可以删啦。

以上是关于在centos6编译安装httpd-2.4方法一的主要内容,如果未能解决你的问题,请参考以下文章

centos6 编译安装httpd-2.4

CentOS6 编译安装httpd-2.4

entos6 编译安装httpd-2.4方法一

apache-httpd2.4编译安装

下载编译安装httpd 2.4的最新版本

编译安装httpd 2.4