Linux二進位安裝apache2.4.25

來源:互聯網
上載者:User

標籤:rect   read   apache服務   option   soc   地址   mkdir   net   follow   

Linux二進位安裝apache2.4.25

安裝環境:CentOS 6.2

 

先檢查是否安裝了Apache

如通是通過rpm包安裝的話直接用下面的命令:rpm -q httpd

也可以使用如下兩種方法:

httpd -v

apachectl -v

如果已安裝了Apache,則會顯示

 

一。準備環境
1.安裝gcc
[[email protected] /]# yum install gcc gcc-c++

2.安裝apr,apr-util
下載apr-1.4.6.tar.gz與apr-util-1.5.1.tar.gz,地址:http://apr.apache.org ,上傳至/usr/local,安裝目錄分別為/usr/local/apr 與/usr/local/apr-util

a.安裝apr-1.4.6.tar.gz
[[email protected] local]# mkdir -p apr
[[email protected] local]# tar -zxf apr-1.4.6.tar.gz
[[email protected] local]# cd apr-1.4.6
[[email protected] apr-1.4.6]# ./configure --prefix=/usr/local/apr
[[email protected] apr-1.4.6]# make
[[email protected] apr-1.4.6]# make install

b.安裝apr-util-1.5.1.tar.gz
[[email protected] local]# mkdir -p apr-util
[[email protected] local]# tar -zxf apr-util-1.5.1.tar.gz
[[email protected] local]# cd apr-util-1.5.1
[[email protected] apr-util-1.5.1]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
[[email protected] apr-util-1.5.1]# make
[[email protected] apr-util-1.5.1]# make install

3.安裝pcre-8.20.tar.gz
:http://sourceforge.net/projects/pcre/files/pcre/ ,上傳至/usr/local,安裝目錄為/usr/local/pcre
[[email protected] local]# mkdir -p pcre
[[email protected] local]# tar -zxf pcre-8.20.tar.gz
[[email protected] local]# cd pcre-8.20
[[email protected] pcre-8.20]# ./configure --prefix=/usr/local/pcre
[[email protected] pcre-8.20]# make
[[email protected] pcre-8.20]# make install


二。安裝apache
1.下載httpd-2.4.25.tar.gz,地址是:http://httpd.apache.org/ ,上傳至/usr/local,安裝目錄為/usr/local/apache2

2.安裝
[[email protected] local]# mkdir -p /usr/local/apache2
[[email protected] local]# tar zxvf httpd-2.4.25.tar.gz
[[email protected] local]# cd httpd-2.4.25
[[email protected] httpd-2.4.25]# ./configure --prefix=/usr/local/apache2 --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
[[email protected] httpd-2.4.25]# make
[[email protected] httpd-2.4.25]# make install

[[email protected] httpd-2.4.25]# /usr/local/apache2/bin/apachectl start
用瀏覽器訪問http://localhost,看到It works!,說明CentOS Apache安裝成功了,恭喜您!

3.啟動
第一種方法[[email protected] apache2]# /usr/local/apache2/bin/apachectl start 一定要是絕對路徑

第二種方法[[email protected] apache2]#service httpd start

第二種方法[[email protected] apache2]#/etc/init.d/httpd start

三。安裝出現的問題
1.configure: error: no acceptable cc found in $PATH
解決辦法:yum install gcc gcc-c++

2.configure: error: APR not found. Please read the documentation.
解決方案:安裝Apache的關聯軟體
如上安裝apr-1.4.6.tar.gz

3.configure: error: APR-util not found. Please read the documentation
解決方案:安裝apr-util
如上安裝apr-util-1.5.1.tar.gz

4.configure: error: APR version 1.3.0 or later is required
主要是因為apr版本過低造成的,應該卸載相關舊版本

5. 啟動時報錯:
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
解救辦法:絕對路徑即可:/usr/local/apache2/bin/apachectl start

要想徹底不顯示此行解決方案:

apache/conf/httpd.conf

首先找到ServerName(約213行),將其設定為localhost:80,並將前面的井號刪除,雖然這一步如果不修改的話也可以正常運行,但啟動Apache服務時會有一條煩人的提示(AH00558: httpd.exe: Could not reliably determine the server‘s fully qualified do main name, using fe80::fc76:abca:e24b:d490. Set the ‘ServerName‘ directive globally to suppress this message)

 

6.安裝完apache時,訪問時Index of /,為什麼不是it works

讓別人知道你的網站目錄結構直接查看你目錄下的所有檔案是很危險的一個事情。

下面介紹解決方案
apache/conf/httpd.conf
找到:
Options indexes FollowSymLinks
改為:
Options FollowSymLinks
當直接存取某個目錄時顯示就表明設定成功了。

 

7.重啟apache時,報:DocumentRoot must be a directory

原因:apache/confi/httpd.conf裡面有DocumentRoot設定檔,但實際目錄中又沒有這個目錄,注釋此配置即可。

 

8.[[email protected] conf]# /usr/local/apache2/bin/apachectl start

AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using localhost.localdomain. Set the ‘ServerName‘ directive globally to suppress this message
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs

解決方案:apache2/conf/httpd.conf Listener 80改為其它的連接埠號碼即可。

 

四。重要設定檔目錄

/etc/httpd/conf/httpd.conf    最主要的設定檔
/usr/lib/httpd/modules:apache  支援很多的模組,所以你想要使用的模組預設都放置在此目錄
/var/log/httpd          apache預設的log
/var/www/html          cenos預設的首頁所在目錄

五。配置apache,最後修改httpd.conf,使apache能使用php
增加如下參數
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType image/x-icon .ico

DirectoryIndex index.php index.html index.html.var

Linux二進位安裝apache2.4.25

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.