溫馨提示×

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

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

如何安裝apache并使工作模式為work

發(fā)布時(shí)間:2020-05-14 14:53:24 來(lái)源:億速云 閱讀:216 作者:Leah 欄目:軟件技術(shù)

如何安裝apache并使工作模式為work?這個(gè)問(wèn)題可能是我們?nèi)粘9ぷ鹘?jīng)常見(jiàn)到的。通過(guò)這個(gè)問(wèn)題,希望你能收獲更多。下面是解決這個(gè)問(wèn)題的步驟內(nèi)容。

、apache模式的查看

   如果apache已經(jīng)安裝,我們可以用 httpd -l  命令查看當(dāng)前模式(只可能有一種),如果找到 prefork.c 則表示當(dāng)前工作在prefork模式,同理出現(xiàn)worker.c則工作在worker模式。

   如果apache還未安裝,我們?cè)诰幾g的時(shí)候可以加入--with-pem=(prefork|worker)

選項(xiàng)決定啟用什么模式。

  當(dāng)然如果你安裝過(guò)了(筆者模式為prefork) 也可以使用以下命令來(lái)切換

mv httpd httpd.prefork
mv httpd.worker httpd

   重啟之后,模式就會(huì)改變。

二、安裝apche


由于Apache依賴(lài)于APR、APR-Util和PCRE,所以需要下載:

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

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

1、安裝 apr

tar zxvf apr-1.5.1.tar.gz (解壓文件到目錄/home/gaoqing/software/apache下)

./configure--prefix=/home/gaoqing/software/apache/apr 配置安裝目錄

make

make install

2、安裝apr-util

./configure--prefix=/home/gaoqing/software/apache/apr-util --with-apr=/home/gaoqing/software/apache/apr


make && make install

 

3、安裝 pcre

./configure --prefix=/home/gaoqing/software/apache/pcre


4、安裝apache,并指定工作模式為work

下載地址:http://httpd.apache.org/

./configure --prefix=/home/gaoqing/software/apache/apache --with-apr=/home/gaoqing/software/apache/apr
 --with-apr-util=/home/gaoqing/software/apache/apr-util --with-pcre=/home/gaoqing/software/apache/pcre
 --with-mpm=worker

make && make install


三、配置

   修改配置文件,否則會(huì)出現(xiàn)問(wèn)題:

AH00558: httpd: Could notreliably determine the server's fully qualified domain name, using 127.0.1.1.Set the 'ServerName' directive globally to suppress this message

解決方法:修改conf/httpd.conf   把:

                # ServerNamewww.example.com:80

            改為:

                ServerNamelocalhost:80

四:apache服務(wù)的啟動(dòng)、停止、重啟


假設(shè)你的apahce安裝目錄為/usr/local/apache2,這些方法適合任何情況

apahce啟動(dòng)命令:
推薦/usr/local/apache2/bin/apachectl start apaceh啟動(dòng)

apache停止命令
/usr/local/apache2/bin/apachectl stop  停止

apache重新啟動(dòng)命令:
/usr/local/apache2/bin/apachectl restart 重啟

要在重啟 Apache 服務(wù)器時(shí)不中斷當(dāng)前的連接,則應(yīng)運(yùn)行:

/usr/local/sbin/apachectl graceful

 

service httpd start 啟動(dòng)

service httpd restart 重新啟動(dòng)

servicehttpd stop 停止服務(wù)

關(guān)于編譯安裝apache的知識(shí)就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果喜歡這篇文章,不如把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

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

AI