溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

CentOS下安裝Apache并配置的方法

發(fā)布時間:2022-05-07 16:18:24 來源:億速云 閱讀:291 作者:iii 欄目:大數(shù)據(jù)

這篇文章主要介紹了CentOS下安裝Apache并配置的方法的相關(guān)知識,內(nèi)容詳細易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇CentOS下安裝Apache并配置的方法文章都會有所收獲,下面我們一起來看看吧。

centos系統(tǒng)安裝的是basic server。安裝apache之前所必須的缺少的組件比較多,下面羅列下本次需要安裝的組件

apache - aprapache - apr-utilperl - pcreapache

官網(wǎng)下載apache

下載穩(wěn)定版本httpd-2.4.9.tar.gz,上傳到服務器/usr/packages目錄下。

安裝apache:

# tar -xvzf httpd-2.4.9.tar.gz

# cd httpd-2.4.9

# ./configure --prefix=/usr/local/apache --enable-module=so --enable-module=rewrite

檢查編譯環(huán)境報錯:

checking for apr... no
configure: error: apr not found . please read the documentation.

原因缺少apr(apache portable runtime),需要下載apr與apr-util。

下載地址:http://apr.apache.org/download.cgi

下載apr-1.5.1.tar.gz、apr-util-1.5.3.tar.gz

安裝apr:

# tar -xvzf apr-1.5.1.tar.gz
# cd apr-1.5.1
# .configure
# make
# make install

安裝apr-util:

# tar -xvzf apr-util-1.5.3.tar.gz
# cd apr-util-1.5.3
# .configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make
# make install

再次檢查編譯環(huán)境報錯:

configure: error: pcre-config for libpcre not found. pcre is required and available from http://pcre.org/

缺少pcre

安裝pcre:

# unzip -o pcre-8.35
# cd pcre-8.35
# ./configure --prefix=/usr/local/pcre
# make
# make install

再次檢查編譯環(huán)境時加上參數(shù):

--with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre

沒有報錯:

# make
# make install

安裝完畢。

這是我第一次安裝,缺少關(guān)聯(lián)關(guān)系的組件,下次安裝直接先安裝組件,最后安裝apache,這樣會順暢些吧。

啟動apache

# cp /usr/local/apache/bin/apachectl /sbin/
# apachectl start

配置隨系統(tǒng)啟動時啟動apache服務

# vi /etc/rc.d/rc.local

在最后一行加上: /sbin/apachectl start

修改apache默認站點目錄

修改/usr/local/apache/conf/httpd.conf文件

CentOS下安裝Apache并配置的方法

改成

CentOS下安裝Apache并配置的方法

執(zhí)行命令
# apachectl restart

關(guān)于“CentOS下安裝Apache并配置的方法”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“CentOS下安裝Apache并配置的方法”知識都有一定的了解,大家如果還想學習更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI