linux 安裝 apache

來源:互聯網
上載者:User

標籤:

安裝Apache前準備:

一、檢查該環境中是否已經存在httpd服務的設定檔,預設儲存路徑:/etc/httpd/httpd.conf(這是centos預裝的Apache的一個ent版本,一般我們安裝原始碼版的Apache)。如果已經存在/etc/httpd/httpd.conf,請先卸載或者關閉centos系統內建的web服務,執行命令:chkconfig  httpd off,再或者把centos內建的httpd服務的80連接埠改為其他連接埠,只要不與我們安裝的Apache服務的連接埠衝突就可以啦。

停止並卸載Linux系統內建的httpd服務:

1、service httpd stop

2、ps -ef | grep httpd

3、kill -9 pid號(逐個刪除)

4、rpm -qa |grep httpd

5、rpm -e httpd軟體包

[[email protected] bin]# find / -name httpd.conf
[[email protected] bin]#

二, 下載Apache安裝包 httpd-2.4.10.tar.gz ,:http://httpd.apache.org/
在安裝Apache時,我分別針對不同版本進行了安裝,在編譯時間是不同的,configure後跟的參數不同。

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre  #(除了指定Apache的安裝目錄外,還要安裝apr、apr-util、pcre,並指定參數)
make
make install

在編譯Apache(在安裝httpd-2.4.10時遇到的問題)時分別出現了apr not found、APR-util not found、pcre-config for libpcre not found的問題,下面就httpd-2.4.10的這些問題解決來實際操作一把。

1, 解決apr not found問題

[[email protected] bin]# tar -zxf apr-1.4.5.tar.gz
[[email protected] apr-1.4.5]# ./configure --prefix=/usr/local/apr
[[email protected] apr-1.4.5]# make
[[email protected] apr-1.4.5]# make install

2.解決APR-util not found問題

[[email protected] bin]# tar -zxf apr-util-1.3.12.tar.gz
[[email protected] apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
[[email protected] apr-util-1.3.12]# make
[[email protected] apr-util-1.3.12]# make install

3、解決pcre-config for libpcre not found問題

[[email protected] ~]# unzip pcre-8.31.zip

[[email protected] ~]# cd pcre-8.31

[[email protected] pcre-8.31]# ./configure --prefix=/usr/local/pcre

[[email protected] pcre-8.31]#

make[[email protected] pcre-8.31]# make install

 

apache服務自啟動設定

[email protected]#cp /usr/local/apahe/bin/apachectl /etc/rc.d/init.d/httpd
[email protected]#vim /etc/rc.d/init.d/httpd

在httpd中加入
#chkconfig: 35 85 15
#description: apache
儲存退出。

[email protected]# chkconfig --add httpd
[email protected]# chkconfig httpd on

查看一下是否添加成功:

chkconfig --list httpd

測試:
[email protected]# service httpd 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

    Apache的設定檔則是conf目錄下的httpd.conf檔案,將其開啟:

      找到ServerName(約213行),將其設定為localhost:80,並將前面的井號刪除

測試:

  [[email protected] ~]# curl http://localhost

  <html><body><h1>It works!</h1></body></html>

linux 安裝 apache

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.