如何在CentOS 7上安裝源碼Apache包並啓用該服務html
第1步:先從Apache官網下載最新的Apache包,而後經過WinSCP上傳到遠程的Centos 7上linux
並掛載VMware的 iso CentOS 7鏡像後部署好本地的yum源-----apache
使VMware 12中的DVD自動掛載,添加以下語句到/etc/fstab
app
[root@Franklin13 ~]# cat /etc/fstab|grep cdromtcp
/dev/cdrom /media/cdrom auto defaults 0 0ide
--------編譯安裝過程以下 -------------ui
第2步: 查看源碼包裏的INSTALL或readme文件並用yum命令查看Development Tools組合包是否已安裝spa
(因./configure編譯時要調用 Development Tools安裝後的某個軟件,好比GCC )3d
[root@Franklin13 httpd-2.4.41]# ls -l|grep IN*orm
-rw-r--r--. 1 root dip 3782 May 18 2016 INSTALL
有時,yum groupinstall "Development tools"會出現以下報錯,且用yum clean all; yum makecache後仍舊出現這種報錯
經Google後發現須要用以下方式安裝才能進行:
yum groupinstall "Development Tools" --setopt=group_package_types=mandatory,default,optional
這種狀況的緣由不少,見以下網址
https://access.redhat.com/solutions/1310043
第3步:進入解壓後的httpd目錄中,運行編譯的3部曲 ./configure --prefix=...&make&make install:
但有時會出現報錯,好比我遇到的 「 checking for APR... no 」
[root@Franklin13 httpd-2.4.41]# ./configure --prefix=/usr/local/apache2.4.41 --sysconfdir=/etc/httpd2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
經百度後發現是以下緣由:
參考文章---- https://www.cnblogs.com/yewandemty/p/5396338.html
先將這些模塊(apr和apr-util 安裝,再進行httpd的安裝 )
Apr的下載網址: http://archive.apache.org/dist/
Apr-util的下載: http://archive.apache.org/dist/apr/
(注意:要先安裝 apr,再安裝 apr-uti,且安裝apr-uti時要添加 --with-apr=後面跟以前編譯apr的安裝路徑 )
下圖爲如何右擊來下載 apr-util模塊
而後再編譯安裝 httpd時必須添加以下兩個 with參數,也是醉了:
[root@Franklin13 httpd-2.4.41]# ./configure --prefix=/usr/local/apache2.4.41 --sysconfdir=/etc/httpd2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
[root@Franklin13 httpd-2.4.41]#
但出現了以下新的報錯 「 pcre-config for libpcre not found"
故不得不下載 pcre模塊,而後編譯安裝
以後,httpd源碼包才能安裝成功
[root@Franklin13 httpd-2.4.41]# history 5
502 ./configure --prefix=/usr/local/apache2.4.41 --sysconfdir=/etc/httpd2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
503 make
504 history 5
505 make install
506 history 5
安裝成功後到安裝路徑目錄下 /bin下運行 apachectl start便可
[root@Franklin13 bin]# pwd
/usr/local/apache2.4.41/bin
[root@Franklin13 bin]# apachectl start
[root@Franklin13 bin]#
[root@Franklin13 bin]# netstat -tan|grep 80
tcp6 0 0 :::80 :::* LISTEN
[root@Franklin13 bin]#
[root@Franklin13 bin]#
[root@Franklin13 bin]# ps -ef|grep httpd
root 59193 1 0 16:27 ? 00:00:01 /usr/sbin/httpd -DFOREGROUND
apache 59199 59193 0 16:27 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 59201 59193 0 16:27 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 59203 59193 0 16:27 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 59204 59193 0 16:27 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 59205 59193 0 16:27 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 63802 19545 0 17:46 pts/5 00:00:00 grep --color=auto httpd
[root@Franklin13 bin]#
-------------------- 全文完 ----------------------------------------------------------