build 源碼編譯安裝httpd

     衆所周知,編譯安裝可以獲得最新的軟件,比較安全,bug比較少;可以自己定義開啓哪功能,安裝到哪裏;但是安裝起來依賴關係較多,所以比較麻煩。我以安裝httpd爲例談一談自己對編譯安裝的拙見。

    1.下載所需要的壓縮文件或目錄
        從網站apache.org 下載httpd

wKiom1MtmRiQ3-1lAANrsxZQKtc183.jpg
         2.解壓
[root@teacher lianxi]# tar xf httpd-2.4.9.tar.bz2

         3.進入目錄
[root@teacher lianxi]# cd httpd-2.4.9
[root@teacher httpd-2.4.9]# ls
ABOUT_APACHE     CHANGES        InstallBin.dsp  README
acinclude.m4     config.layout  LAYOUT          README.platforms
Apache-apr2.dsw  configure      libhttpd.dsp    ROADMAP
Apache.dsw       configure.in   LICENSE         server
apache_probes.d  docs           Makefile.in     srclib
ap.d             emacs-style    Makefile.win    support
build            httpd.dsp      modules         test
BuildAll.dsp     httpd.spec     NOTICE          VERSIONING
BuildBin.dsp     include        NWGNUmakefile
buildconf        INSTALL        os
[

[root@teacher httpd-2.4.9# ./configure --help 可以查看那些功能可以開啓,那些功能默認情況,那些默認不開,指定安裝路徑等等
Installation directories:
 --prefix=PREFIX         install architecture-independent files in PREFIX
===
  以--enable開頭的選項說明默認情況下不開啓需要我們使用這個選項去打開這個功能
  以--disable開頭的選項說明默認情況下開啓需要我們使用這個選項去關閉這個功能
--enable-authn-anon     anonymous user authentication control
--disable-authz-host    host-based authorization control
--disable-version       determining httpd version in config files
需要開啓ssl功能指定相關OpenSSL軟件的路徑
--with-ssl=PATH         OpenSSL installation directory
--with-apr=/usr/local/apr/
====
  瞭解軟件的安裝和使用請閱讀,
  (1) README文檔
  (2) INSTALL文檔
       INSTALL文件裏說明的步驟
     $ ./configure --prefix=PREFIX
     $ make
     $ make install
     $ PREFIX/bin/apachectl start

====
       4,Simply; 經典步驟

(1) ./configure --prefix=/desired/path/of/apr
編譯前的配置
[root@teacher httpd-2.4.9]# ./configure --prefix=/usr/local/apache9 --enable-cache  --enable-so   配置安裝的目錄,同時開啓緩存功能和動態加載模塊的功能
作用是生成Makefile文件,後面的make(編譯)會根據這個文件裏的要求去執行
[root@localhost httpd-2.4.9]# ./configure --prefix=/usr/local/apache9 --enable-so  --enable-cache
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no          缺包
configure: error: APR not found.  Please read the documentation.
[root@localhost httpd-2.4.9]# vim INSTALL
[root@localhost httpd-2.4.9]#
=====
[root@vm-build apr-1.5.0]# make   缺make包
-bash: make: command not found
[root@vm-build apr-1.5.0]# yum install make
===
[root@teacher httpd-2.4.9# ./configure --prefix=/usr/local/apache9
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
 setting CC to "gcc"
 setting CPP to "gcc -E"
 setting CFLAGS to " -g -O2 -pthread"
 setting CPPFLAGS to " -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE"
 setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no   缺APR-util軟件
configure: error: APR-util not found.  Please read the documentation.

安裝缺APR-util軟件

wKioL1MtnkCTPtnwAAHtFt_h_54206.jpg



  (2) make  編譯(是將c語言寫的程序編譯成二進制文件)

  (3) make install (將編譯好的二進制文件複製到相應的目錄下)

=====

三,安裝pcre的錯誤,及解決方法
   source='pcrecpp.cc' object='pcrecpp.lo' libtool=yes \
DEPDIR=.deps depmode=none /bin/sh ./depcomp \
/bin/sh ./libtool --tag=CXX   --mode=compile  -DHAVE_CONFIG_H -I.      -c -o pcrecpp.lo pcrecpp.cc
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] 錯誤 1
make[1]: Leaving directory `/root/pcre-8.21'
make: *** [all] 錯誤 2
[root@wuhanVMware pcre-8.21]# yum install libtool  安裝libtool軟件
[root@wuhanVMware pcre-8.21]# yum instal gcc-c++*   安裝gcc-c++相關的包
===

[root@vm-build httpd-2.4.9]# ./configure --prefix=/usr/local/apache9  --enabled-so --enable-cache  配置,指定安裝路徑
[root@vm-build httpd-2.4.9]#make ;make install  編譯和編譯安裝

=========
A-->B--->C--->D
安裝httpd-2.4.9版本
1.安裝apr---》apr-utils------》pcre---》httpd-2.4.9
apr-1.5.0.tar.gz
apr-util-1.5.3.tar.gz
pcre-8.21.tar.bz2
httpd-2.4.9.tar.bz2
=====

四,httpd安裝好後的使用
    [root@vm-build bin]# ./apachectl start
AH00557: httpd: apr_sockaddr_info_get() failed for vm-build.sxkeji.com
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
[root@vm-build bin]# /usr/local/apache9/bin/apachectl start
AH00557: httpd: apr_sockaddr_info_get() failed for vm-build.sxkeji.com
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
httpd (pid 44056) already running
[root@vm-build bin]#
[root@vm-build apache9]# ls
bin    cgi-bin  error   icons    logs  manual
build  conf     htdocs  include  man   modules
[root@vm-build apache9]# cd conf
[root@vm-build conf]# ls
extra  httpd.conf  magic  mime.types  original

1關閉rpm的80端口
   [root@vm-build conf]# vim  httpd.conf
ServerName www.feng.com:80   去掉189行前面的註釋,讓服務器使用www.feng.com這個域名提供服務

fully qualified domain name  (FQDN 完全符合要求的域名  www.baidu.com)
[root@vm-build conf]# /usr/local/apache9/bin/apachectl restart  重新啓動服務
[root@vm-build conf]# /usr/local/apache9/bin/apachectl restart
[root@vm-build conf]# /usr/local/apache9/bin/apachectl stop  停止服務
[root@vm-build conf]# /usr/local/apache9/bin/apachectl start 啓動服務
[root@vm-build conf]#

===
   先停用rpm方式安裝的httpd軟件
[root@vm-build httpd-2.4.9]## service  httpd stop
Stopping httpd:                                            [  OK  ]
[root@vm-build httpd-2.4.9]##
[root@vm-build httpd-2.4.9]## /usr/local/apache9/bin/apachectl  stop
停止編譯安裝的httpd服務
[root@vm-build httpd-2.4.9]## /usr/local/apache9/bin/apachectl start
啓動編譯安裝的httpd服務
===
2 清除防火牆規則
   [root@vm-build conf]# iptables  -F 作用就是讓防火牆失效。
[root@vm-build conf]# ip add  查看服務器ip地址
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
   inet 127.0.0.1/8 scope host lo
   inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
   link/ether 00:0c:29:24:a9:3d brd ff:ff:ff:ff:ff:ff
   inet 10.0.0.133/16 brd 10.0.255.255 scope global eth0
   inet6 fe80::20c:29ff:fe24:a93d/64 scope link
      valid_lft forever preferred_lft forever
[root@vm-build conf]#

3 使用瀏覽器去訪問 (firefox 、elinks)在firefox中輸入ip地址10.0.0.99 或 10.0.0.199 或 10.0.0.191

====
4 簡單製作網站
   [root@teacher htdocs]# pwd
/usr/local/apache9/htdocs    真正存放網站的目錄,你可以將網站存放在此
[root@teacher htdocs]# ls
index.html
[root@teacher htdocs]#
[root@teacher htdocs]# vim index.html 修改網站的首頁文件
[root@teacher htdocs]# cat index.htm
   ====
(1)

file:///tmp/ct_tmp/1.pngwKioL1MtmrqS9306AACUKPkt2NA916.jpg


注意圖片dou.jpg存放在htdocs目錄下
   ====
(2)

file:///tmp/ct_tmp/2.pngwKioL1MtmsmB5thNAABNjNT8k2g856.jpg


   ====
(3)

wKiom1MtmwvSDNpbAAC2JX3Pmng385.jpgfile:///tmp/ct_tmp/3.png




===
(4)
       也可以在htdocs目錄下新建文件夾download,存放些軟件給其他人下載
       訪問路徑爲http://10.0.0.133/download

wKioL1Mtmv2DaLONAAHGHLOSwb8313.jpgfile:///tmp/ct_tmp/4.png


===

  (5)最後的效果

wKioL1Mtm4jCWVHMAAK2o5Lp8Ek614.jpg


                                                                   

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