分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

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

发布时间:2023-09-06 01:47责任编辑:白小东关键词:http编译
安装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
[root@centos6 apr-1.6.3]# yum install libtool
[root@centos6 ~]# mkdir httpd2.4
[root@centos6 ~]# cd httpd2.4/
把源代码传到里面;
[root@centos6 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)
[root@centos6 httpd2.4]# cd apr-1.6.3
[root@centos6 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
[root@centos6 apr-1.6.3]# ./configure --prefix=/app/apr ???(开始编译)
[root@centos6 apr-1.6.3]#make -j 4 && make install
[root@centos6 apr-1.6.3]# ls /app
apr
[root@centos6 apr-1.6.3]# cd ..
[root@centos6 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
[root@centos6 httpd2.4]# cd apr-util-1.6.1
[root@centos6 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
[root@centos6 apr-util-1.6.1]# ./configure --prefix=/app/apr-util --with-apr=/app/apr
[root@centos6 apr-1.6.3]#make -j 4 && make install

第三部:编译安装httpd2.4
[root@centos6 apr-util-1.6.1]# cd ..
[root@centos6 httpd2.4]# cd httpd-2.4.29
[root@centos6 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
[root@centos6 httpd-2.4.29]# make -j 4 && make install

[root@centos6 httpd-2.4.29]# cd /app
[root@centos6 app]# ls
apr ?apr-ut ??httpd24 ?

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

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

第六部:配置文件
[root@centos6 bin]# cd /root/httpd2.4/
[root@centos6 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
[root@centos6 httpd2.4]# cd httpd-2.4.29/
[root@centos6 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
[root@centos6 httpd2.4]# cd httpd-2.4.29/
[root@centos6 httpd-2.4.29]# cd /app/httpd24/conf/
[root@centos6 conf]# ls
extra ?httpd.conf ?magic ?mime.types ?original
[root@centos6 conf]# vim /app/httpd24/conf/httpd.conf

user apache
group apache

[root@centos6 conf]# apachectl restart ??(重启服务)
[root@centos6 conf]# ps aux

现在就可以试试啦:
[root@centos7 ~]# curl ?192.168.10.107
<html><body><h1>It works!</h1></body></html>
它的路径放在:

[root@centos6 ~]# cd /app/httpd24/
[root@centos6 httpd24]# ls
bin ?build ?cgi-bin ?conf ?error ?htdocs ?icons ?include ?logs ?man ?manual ?modules
[root@centos6 httpd24]# cd htdocs
[root@centos6 htdocs]# ls
index.html

第七步:开机脚本。

设为开机启动:
[root@centos6 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}

[root@centos6 ~]# 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方法一

原文地址:http://blog.51cto.com/13466315/2091959

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved