源碼安裝 apache 2.4.27
源碼安裝 apache 2.4.27
登陸apache官網下載源碼安裝包
http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.27.tar.gz
下載所需軟件源碼包
§ Apache
Apr:
Apr-Util: http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.0.tar.gz
(或者點擊這裏下載apr和apr-Util其他版本)
pcre: https://sourceforge.net/projects/pcre/files/pcre/8.41/pcre-8.41.tar.gz/download
(點擊這裏下載其他版本)
apache:http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.27.tar.gz
§ (點擊或者這裏下載其他版本)
tar -xf httpd-2.4.25.tar.gz#先用cd命令切換到軟件包所在的目錄,用ls命令查看當前目錄內容
· 1
《一》安裝前準備
以下面壓縮包為列
Samba-4.6.5.tar.gz或者. samba-4.6.5.tar.bz2
Tar
-c: 建立壓縮檔案
-x:解壓
-t:查看內容
-r:向壓縮歸檔文件末尾追加文件
-u:更新原壓縮包中的文件
這五個是獨立的命令,壓縮解壓都要用到其中一個,可以和別的命令連用但只能用其中一個。下面的參數是根據需要在壓縮或解壓檔案時可選的。
-z:有gzip屬性的
-j:有bz2屬性的
-Z:有compress屬性的
-v:顯示所有過程
-O:將文件解開到標準輸出
下面的參數-f是必須的
-f: 使用檔案名字,切記,這個參數是最後一個參數,後面只能接檔案名。
《一》Samba-4.6.5.tar.gz 格式解壓等操作 二 samba-4.6.5.tar.bz2
解壓命令 tar zxvf apache2.4.27.tar.gz 解壓命令 tar jxvf apache 2.4.27.tar.bz2
創建命令 tar zcvf apache2.4.27.tar.gz 創建命令 tar jcvf apache 2.4.27.tar.bz2
查看命令 tar ztvf apache2.4.27.tar.gz 查看命令 tar jtvf apache 2.4.27.tar.bz2
註意事項:wget vim gcc gcc-c++ cmake 這幾個也是安裝 Apache 所需要的小環境 。有的小環境,一般 Cnetos7 自帶,我個人建議還是手動的再用 yum install 安裝 或者 更新一下。
開始安裝吧!
第一步:解壓下載好的 Apache 包
[[email protected] ~]# tar -zxvf apache 2.4.27.tar.gz
//進入目錄 編譯解壓的原文件
# cd 解壓目錄
編譯解壓的原文件
#./configure --prefix=/soft/httpd/apache #配置安裝目錄 --prefix=/soft/httpd/apache
1.如果正常執行 (說明你的Linux安裝過Apache,或者已經安裝過所需的依賴包)
2.如果不正常執行、會出現以下錯誤信息
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
解決方案:就是安裝 剛剛下載好的 Apr。 Apache在安裝時需要一些準備環境、這裏需要安裝另外一個 Apr(Apache portable runtime)
《二》解壓下載好的 Apr 包
[[email protected] ~]# tar -zxvf apr-1.6.2.tar.gz
//進入目錄 編譯解壓的原文件
[[email protected] apr-1.6.2]# ./configure --prefix=/soft/httpd/apr/ #配置安裝目錄
//安裝目錄配置完成
make && make install 在指定地址生成目錄和文件
[[email protected] apr-1.6.2]# make && make install
《三》:解壓下載好的 Apr-util 包
[[email protected] ~]# tar -zxvf apr-util-1.6.0.tar.gz
//進入目錄 編譯解壓的原文件
[[email protected] apr-util-1.6.0]# ./configure --prefix=/usr/local/apr-util/ #配置安裝目錄
//報錯 看到錯誤信息 現在自己就知道了吧
--with-apr
[[email protected] apr-util-1.6.0]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/soft/httpd/apr/
//安裝目錄配置完成 就 make && make install 在指定地址生成目錄和文件
[[email protected] apr-util-1.6.0]# make && make install
《四》:繼續安裝 Apache
//切換到 Apache 源文件
[[email protected] httpd-2.4.27]# ./configure --prefix=/soft/httpd/apache/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
//還會出現下面的錯誤 原因是:還是缺少環境 PCRE
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
《五》:繼續安裝 pcre pcre2-10.23....版本會報錯了所有我們下載pcre版本
解決方案: 下載地址 http://jaist.dl.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz 下載最新版本 我下載的是 pcre-8.41.tar.gz
[[email protected] ~]# wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz
[[email protected] ~]# tar -zxvf pcre-8.41.tar.gz
[[email protected] pcre-8.41]# ./configure --prefix=/usr/local/pcre/
[[email protected] pcre-8.41]# make && make install
繼續安裝 Apache
[[email protected] httpd-2.4.27]# ./configure --prefix=/soft/httpd/apache/ --with-apr=/soft/httpd/apr/ --with-apr-util=/soft/httpd/apr-util/ --with-pcre=/usr/local/pcre/
[[email protected] httpd-2.4.20]# make && make install
《六》:測試 Apache
centos7使用systemctl代替chkconfig管理服務,
防火墻也由iptables更換成了firewalld
首先用systemctl關閉防火墻:
systemctl stop firewalld.service
systemctl disable firewalld.service
開啟 Apache 服務 停止 stop
[[email protected]~]# cd /soft/httpd/apache/bin/
[[email protected] bin]# ./apachectl start
《七》:在客戶端瀏覽器輸入自己的 IP 地址,看看能夠成功訪問 Apache。 It works
本文出自 “步步高升” 博客,請務必保留此出處http://1085858.blog.51cto.com/1075858/1950448
源碼安裝 apache 2.4.27