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

解壓:tar xvf apr-1.6.2.tar.gz   tar xvf   apr-util-1.6.0.tar.gz    tar xvf  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/

計算機生成了可選文字: 「 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

 

然後安裝包:

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. 在另一主機上訪問一下:

18395d10ba336752ef14a7a0af8d00fd.png

擴展:指定運行身份: 

        

  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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章