1. 程式人生 > >Centos7源碼安裝httpd2.4版本web服務器

Centos7源碼安裝httpd2.4版本web服務器

txt 程序 mem class mman fault gid mysql- grep

我們的系統平臺是在centos7.5的環境下安裝httpd2.4版本的軟件,2.4版本的軟件有一個特征就是需要安裝arp包以及arp-util包才可以。

1、首先是下載httpd2.4版本的包,以及安裝開發環境,這裏開發環境直接使用組安裝“Development tools”即可,(註意centos6是安裝“Development tools和Server Platform Development”兩種開發環境)

wget http://ftp.cuhk.edu.hk/pub/packages/apache.org//httpd/httpd-2.4.37.tar.gz
yum groupinstall "Development tools
"

2、解壓到指定目錄/usr/local目錄下

tar -zxf httpd-2.4.37.tar.gz -C /usr/local

3、在/usr/local目錄下創建一個httpd目錄,然後在剛剛解壓的目錄裏面開始執行configure檢測依賴環境

./configure --prefix=/usr/local/httpd

發現報錯:

configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... no
configure: error: APR
-util not found. Please read the documentation. configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... no configure: error: APR not found. Please read the documentation.

缺少apr-util包和apr包,那我們來安裝即可

yum install apr apr-util apr-devel apr-util-devel

這兩個包很重要,所以大家一定要記住。也有的人是下載apr源碼包編譯的,都是可以的。

4、繼續執行configure檢測環境

[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd-2.4.37]#./configure --prefix=/usr/local/httpd
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:

    Server Version: 2.4.37
    Install prefix: /usr/local/httpd
    C compiler:     gcc
    CFLAGS:           -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -E

哈哈,終於編譯成功了,繼續安裝

5、接下來執行make命令完成項目構建

[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd-2.4.37]#make
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc  -pthread           -o mod_rewrite.la -rpath /usr/local/httpd/modules -module -avoid-version  mod_rewrite.lo 
make[4]: Leaving directory `/usr/local/httpd-2.4.37/modules/mappersmake[3]: Leaving directory `/usr/local/httpd-2.4.37/modules/mappersmake[2]: Leaving directory `/usr/local/httpd-2.4.37/modulesmake[2]: Entering directory `/usr/local/httpd-2.4.37/supportmake[2]: Leaving directory `/usr/local/httpd-2.4.37/support
make[1]: Leaving directory `/usr/local/httpd-2.4.37

看到這裏說明編譯成功了。

6、執行make install 安裝

[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd-2.4.37]#make install
Installing man pages and online manual
mkdir /usr/local/httpd/man
mkdir /usr/local/httpd/man/man1
mkdir /usr/local/httpd/man/man8
mkdir /usr/local/httpd/manual
make[1]: Leaving directory `/usr/local/httpd-2.4.37

安裝成功。

7、看下安裝的目錄

[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local]#cd httpd
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd]#ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd]#cd bin
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/bin]#ls
ab         apxs      dbmmanage  envvars-std  htcacheclean  htdigest  httpd      logresolve
apachectl  checkgid  envvars    fcgistarter  htdbm         htpasswd  httxt2dbm  rotatelogs
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/bin]#

8、我們看到了安裝的目錄裏面有我們想要的文件,但是到這裏還沒有完成,我們還有一些後續工作需要做。

9、設置環境變量

[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/bin]#cd /etc/profile.d/
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/profile.d]#ls
256term.csh  colorgrep.csh  colorls.csh  csh.local  lang.sh   less.sh  sh.local  vim.sh      which2.sh
256term.sh   colorgrep.sh   colorls.sh   lang.csh   less.csh  path.sh  vim.csh   which2.csh
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/profile.d]#vim httpd.sh
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/profile.d]#cat httpd.sh 
HTTPD_HOME=/usr/local/httpd
PATH=$PATH:$HTTPD_HOME/bin

最後記得source一下立即生效。

10、建立庫文件信息(以.so結尾的文件)

一般上我們運行程序,Linux系統會在特定的路徑下為應用查找所以來的庫文件:/usr/lib、/usr/lib64、/lib、/lib64這四個目錄下面,但是自己編譯安裝的程序提供的庫文件有可能不在系統搜索的路徑中,因此我們需要在系統裏面添加一下。註意以.conf結尾。

[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/modules]#cd /etc/ld.so.conf.d/
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#ls
dyninst-x86_64.conf  kernel-3.10.0-862.3.2.el7.x86_64.conf  mysql-x86_64.conf
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#echo /usr/local/httpd/modules > httpd-2.4.37.conf
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#cat httpd-2.4.37.conf 
/usr/local/httpd/modules
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#

11、然後重新執行ldconfig命令重新生成映射緩存ld.so.conf

[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#ldconfig

12、除了我們剛剛設置的環境變量、庫文件外,我們還需要設置頭文件信息。我們這裏復制頭文件過去即可。

[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/include]#ls
apache_noprobes.h      ap_expr.h      ap_regkey.h        http_core.h      mod_auth.h      util_cookies.h  util_script.h
ap_compat.h            ap_hooks.h     ap_release.h       httpd.h          mod_core.h      util_ebcdic.h   util_time.h
ap_config_auto.h       ap_listen.h    ap_slotmem.h       http_log.h       mod_request.h   util_fcgi.h     util_varbuf.h
ap_config_auto.h.in    ap_mmn.h       ap_socache.h       http_main.h      mpm_common.h    util_filter.h   util_xml.h
ap_config.h            ap_mpm.h       heartbeat.h        http_protocol.h  scoreboard.h    util_ldap.h
ap_config_layout.h     ap_provider.h  http_config.h      http_request.h   util_cfgtree.h  util_md5.h
ap_config_layout.h.in  ap_regex.h     http_connection.h  http_vhost.h     util_charset.h  util_mutex.h
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/include]#mkdir  /usr/include/httpd
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/include]#cp ./*  /usr/include/httpd/

其實我們就是把httpd安裝目錄下的include目錄的所有頭文件復制一份,放置在/usr/include/httpd目錄下,註意,這個httpd需要提前創建好。

13、最後就是man手冊了,Centos7下面的man手冊配置文件是/etc/man_db.conf文件,我們修改一下即可。

Centos7源碼安裝httpd2.4版本web服務器