centos6 编译安装httpd-2.4

前端之家收集整理的这篇文章主要介绍了centos6 编译安装httpd-2.4前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

看今天小编用俩种方法讲讲怎么用centos6 编译安装httpd-2.4

方法一:

1.如果之前有httpd,先把之前的httpd给卸了:yum remove httpd

源码:

apr-1.6.2.tar.qz  ―apr-util1.6.0.tar.gz  httpd-2_4_28.tar_bz2

解压:tarxvf apr-1.6.2.tar.gztarxvf apr-util-1.6.0.tar.gztarxvf httpd-2.3.28.tar.bz2

2.开始编译apr:先装包组:

Croot@centos6 #cd apr-1.6.2  Croot@centos6  / root/ ap r-1. 6.2  Croot@centos6 apr-1.6.2]#yum groupi nstall "development tool s"  Loaded pl ugi ns: fastestmi rror,refresh-packagekit,securi ty

编译:./configure --prefix=/app/apr

make && make install

Croot@centos6  - -prefix=/app/apr

be91d0a26e3b58967f7513a273f49505.png

3.开始编译apr-util,进入该目录下,进行编译:./configure --prefix=/app/apr-util --with-apr=/app/apr/

计算机<a href=生成了可选文字: 「 rootgcentos6 Crootacentos6 apruti 1 .dep apruti ] .dsp apruti 1 . ds apruti ] . mak apr-util . PC . 1 n apr-util .spec apu-confi g .i n bui 1 dconf . 刁 #cd a r . u 01 . 1 . 6 . 0 apr―u 1 build.conf bui ] d-outputs . mk CHANGES CMakeLi Sts 。 txt config. 1 ayout confi gu re . 1 n export―vars . sh 口 n ] baprutil .dep libaprutil libaprutil 。 libaprutil . rC LICENSE Makefile.in Makefil e . n NOTICE README README 。 cmake README 。 FREETDS" style="background-image:url("/e/u261/lang/zh-cn/images/localimage.png");background-position:center;background-repeat:no-repeat;border:1px solid rgb(221,221);" width="480" height="111" title="5.png" src="https://s4.51cto.com/oss/201710/21/bff3ef90b34574c345202955dc34a8e2.png">

然后安装包:

2c0b009a0a371f15670fa6e8e5b08d10.png

现在进行编译:

Croot@centos6  checking build system type..  checking host system type..  - -prefi x=/app/apr-uti 1  x  -pc- 1 nux-gnu  x86_64-pc-1 pyx-gnu  - -wi th-ap app/ apr

然后:make&& make install

4121065566ddd42d10500490111380e6.png

4.编译httpd

eeac34fbae09d07a2fcc8d6417541fbf.png

先安装包:

bbcde74df9b1a9effb54a31a49d9ea70.png

进入该目录下,进行编译:cd /httpd-2.4.28

Croot@centos6 httpd-2.4.28]#./confi gure  1 e-cai  --prefi x=/app/httpd24 -  -enable-rewrite --with-zlib --with-pcre --with-apr=/app/apr/ --with-apr-util=/app/apr  -util/ --enable-modules=most --enable-mpms-shared=all --wi th-mpm=prefork  -enable-so --enable-ssl --enab

Croot@centos6 httpd-2.4.28]#make -j 4 && make install

好了,到现在为止,已经编译完成了

找启动服务:

/ root/httpd-2.4 28  t@centos6  Croot@centos6  [root@centos6  httpd24] #1 s  httpd24] #cd bin  Croot@centos6  Croot@centos6  127.0.0.1.25  Iftpd-2.4.28] #pwd  httpd-2.4.28]#1s /app/httpd24/  httpd-2.4.28]#cd /app/httpd24/  ab  dbmmanage  apxs  checkgid envvars  a ac ect  root@centos6 bi n] -ntl  envvars-std  fcgi starter  Local  htcachecl ean  htdbm  Address : PO rt  .. :111  * : 111  * : 34512  htdi gest  htpasswd  httpd  1 ogresol ve  httxt2dbm rotatel ogs  peer Address : port  State  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  Recv-Q  128  128  128  128  128  128  128  100  100  128  127.0.0.1:631  t: 631  . : 1:25  Croot@centos6

启动服务:./apachectl

Croot@centos6 bi  AH00558: httpd: could not reliably determine the server's fully qualified domain name,using  centos6. local domain. set the 'serverName' di rective globally to suppress this message  [root@centos6 bi n] -ntl  . : 1:25  127.0.0.1:25  State  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  LISTEN  Recv-Q send-Q  128  128  128  128  128  128  128  128  100  100  128  Local Address: port  * : 111  * : 34512  127.0.0.1:631  peer Address : port  Croot@centos6

访问一下:

(D 192.168.37.106  t works!

方法二:

Aprutil httpd解压到同一个目录

  1. 首先安装包组

  • yum groupinstall "development tools"

  • yum install openssl-devel pcre-devel expat-devel

2.先建一个目录,把我们需要解压的包全放进去,这样有条理

  • mkdir src

  • mv apr* httpd-2.4.28.tar.bz2 src/

  • 进入该目录cd src

  • 进行解压:tar xvf apr-1.6.2.tar.gz tar xvf apr-util-1.6.0.tar.gz tar xvf httpd-2.4.28.tar.bz2

3.把apr整个目录拷进httpd-2.4.28/srclib/下并改名

  • cp -a apr-1.6.2 httpd-2.4.28/srclib/apr a表示保留所有的属性

  • cp -a apr-util-1.6.0 httpd-2.4.28/srclib/apr-util

4.编译

  • cd httpd-2.4.28/

  • ./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork

  • make -j 4 && make install 4指的是并发)

5.配置文件

  • 可启动服务的路径:cd /app/httpd24/bin/apachectl 主程序在:cd /app/httpd24/bin/httpd

  • 修改路径,启动比较方便(在任何路径都能启动):vim /etc/profile.d/httpd24.sh PATH=/app/httpd24/bin:$PATH

  • 执行一下文件,让其生效:. /etc/profile.d/httpd24.sh

  • 启动服务:apachectl

  • 注意一定要关闭防火墙和SElinux策略:iptables -F getenforce

  • 修改页面:主页面位置/app/httpd24/htdocs/index.html

  • e021e6dd04aed9a9da223dc7ed2d3ef3.png

6. 在另一主机上访问一下:

@L_502_1@

扩展:指定运行身份:

  1. 指定运行身份Apache

  • 首先确认系统有账户apacheid apache 如果不存在就要自己创建一个:useradd -r apache 查看apache的默认路径:getent passwd apache

  • 查看系统自带apache账户来源:rpm -q --scripts httpd

  • 指定身份:

vim /app/httpd24/conf/httpd.conf

User apache

Group apache

2.做成服务,这样就可以用service命令来控制,并且可以设成开机启动:

  • 停止该进程:apachectl stop

  • 复制原脚本,然后进行修改

cd /etc/init.d/

cp httpd 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}

  • 添加进服务列表:chkconfig --add httpd24

  • 确认一下:chkconfig --list httpd24

  • 开机启动:chkconfig httpd24 on

  • 启动该服务:service httpd24 start

  • 查看进程:ps aux 进程的pid文件位置:ls /app/httpd24/logs/

3. 测试:

好了,到此止为止,小编讲完了,好开心哦

a39596ed97b9929160dfb86b535bc009.jpg

原文链接:https://www.f2er.com/centos/375486.html

猜你在找的CentOS相关文章