apache源碼安裝

1.apr和apr-util,下載地址: http://apr.apache.org/download.cgilinux

yum install gcc
yum install libtool
yum install expat-devel
yum install pcre-devel

cd apr-1.6.3/
./configure --prefix=/opt/apr

出現如下錯誤apache

rm: cannot remove 'libtoolT': No such file or directory

include/arch/unix/apr_private.h is unchange
cp configure ./configure.bak
vi configure
#$RM 「$cfgfile」   #註釋掉這行
:wq

!./configure --prefix #從新執行上一次相同的命令
make -j 4 #四核運行
make install

tar -zxvf apr-util-1.6.1.tar.bz2 #注意不要下載apr-util-1.6.1.tar.gz這個gz文件會出現安裝錯誤
cd apr-util-1.6.1
./configure --prefix=/opt/apr-util --with-apr=/opt/apr
make && make instal

2. 下載安裝pcre【若是以及yum安裝則跳過此步】bash

wget https://ftp.pcre.org/pub/pcre/pcre2-10.30.tar.gz
tar -zxvf pcre2-10.30.tar.gz
cd pcre2-10.30
./configure --prefix=/opt/pcre
make && make installyum -y install pcre-devel

 3.安裝apachedom

./configure --prefix=/opt/apache --with-apr=/opt/apr --with-apr-util=/opt/apr-util --with-include-apr --enable-so
make && make install

4.你會發現apache stop|restart|start都不成功spa

Could not reliably determine the server's fully qualified domain name

解決辦法unix

vi httpd.conf
#ServerName www.example.com:80 
#修改成
ServerName localhost:80

5.將apache設定爲開機啓動rest

註冊Apache到Linux服務
在Linux下用源代碼方式編譯安裝完Apache後,啓動關閉Apache能夠經過以下命令實現: code

/opt/apache/bin/apachectl start|stop|restart

加入開機啓動server

cp /opt/apache/bin/apachectl  /etc/rc.d/init.d/httpd 
#連接文件的S61是啓動時的序號。
#當init.d目錄下有httpd腳本後,咱們就能夠經過service命令來啓動關閉apache了。
ln -s /etc/rc.d/init.d/httpd  /etc/rc.d/rc3.d/S61httpd
service httpd start | stop | restart

這時有個問題就是:雖然apache已經能夠自動啓動,但在linux的服務列表中卻看不到它,要添加服務,通常經過chkconfig --add xxx來實現,但須要腳本中有相應的信息才行,不然chkconfig就會提示:xxx 服務不支持 chkconfig。因此咱們首先編輯httpd腳本,在第2行(#!/bin/sh下面)添加以下注釋信息(包括#):blog

vi /etc/rc.d/init.d/httpd
# chkconfig: 35 61 61
# description: Apache

第一行的3個參數意義分別爲:在哪些運行級別啓動httpd(3,5);啓動序號(S61);關閉序號(K61)。注意:第二行的描述必需要寫!保存後執行:

chkconfig --add httpd #全部開機模式下自啓動,另外chkconfig httpd on 表示345模式下自啓動

就將httpd添加入服務了。在rc3.d、rc5.d路徑中未來就會出現S61httpd的連接,其餘運行級別路徑中會出現K61httpd的連接。

運行下面的命令查看服務,就能夠看到httpd的服務了。

chkconfig --list
相關文章
相關標籤/搜索