Linux下安裝Apache 2.4

本文原創,歡迎轉載。轉載請在文章明顯可見處張貼如下內容:(注意:請保留超鏈接格式)

本文爲Rainisic原創,歡迎轉載,轉載請在文章明顯可見處張貼原帖信息:

http://www.cnblogs.com/rainisic/archive/2012/05/23/Linux_Apache2_4_Install.html

下載Apache 2.4及依賴包

Apache官網下載:http://httpd.apache.org/download.cgi

由於Apache依賴於APR、APR-Util和PCRE,所以需要下載:

APR + APR-Util:http://apr.apache.org/download.cgi

PCRE:http://sourceforge.net/projects/pcre/files/pcre/

在此,筆者使用均爲目前最新版本,Apache 1.4.6,APR 1.4.1,APR-Util 2.4.1,Perl 5.14.2,PCRE 8.30

安裝依賴

APR及APR-Util安裝

解壓縮APR及APR-Util

shell> sudo tar zxvf apr-1.4.6.tar.gz -C /opt/sources
shell> sudo tar zxvf apr-util-1.4.1.tar.gz -C /opt/sources

創建安裝目錄並創建軟鏈接

shell> sudo mkdir /opt/software/develop/apr-1.4.6
shell> sudo mkdir /opt/software/develop/apr-util-1.4.1
shell> sudo ln -s /opt/software/develop/apr-1.4.6 /usr/local/apr
shell> sudo ln -s /opt/software/develop/apr-util-1.4.1 /usr/local/apr-util

安裝APR及APR-Util

複製代碼
shell> cd /opt/sources/apr-1.4.6
shell> sudo ./configure --prefix=/usr/local/apr
shell> sudo make
shell> sudo make install

shell> cd /opt/sources/apr-util-1.4.1
shell> sudo ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
shell> sudo make
shell> sudo make install
複製代碼

安裝PCRE

首先請確定系統安裝了Perl,Perl在此不再贅述,如有需要請去官網查看安裝細則:http://www.cpan.org/src/README.html

解壓縮PCRE

shell> sudo tar zxvf pcre-8.30.tar.gz -C /opt/sources

創建PCRE安裝目錄及軟鏈接

shell> sudo mkdir /opt/software/develop/pcre-8.30
shell> sudo ln -s /opt/software/develop/pcre-8.30 /usr/local/pcre

安裝PCRE

shell> cd /opt/sources/pcre-8.30
shell> sudo ./configure --prefix=/usr/local/pcre
shell> sudo make
shell> sudo make install

安裝Apache 2.4

解壓縮Apache 2.4

shell> sudo tar zxvf httpd-2.4.2.tar.gz -C /opt/sources

創建Apache安裝目錄及軟鏈接

shell> sudo mkdir /opt/software/develop/httpd-2.4.2
shell> sudo ln -s /opt/software/develop/httpd-2.4.2 /usr/local/apache2

安裝Apache

複製代碼
shell> cd /opt/sources/httpd-2.4.2

# 此處請根據自己要搭建的環境進行配置,我這裏是爲了配置PHP環境
shell> sudo ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite=shared --with-mpm=prefork --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

shell> sudo make
shell> sudo make install
複製代碼

啓動Apache

通過apachectl啓動Apach

shell> sudo /usr/local/apache2/bin/apachectl start

檢查是否有Apache進程

shell> ps aux | grep httpd

如果有Apache的進程,則證明啓動成功,瀏覽器地址欄輸入 http://localhost 試試吧~

啓動成功之後,可以將apachectl拷貝到/etc/init.d下,作爲service啓動。

shell> sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
shell> sudo service httpd start

擴展閱讀

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