LAMP搭建2:Apache安裝

來源:互聯網
上載者:User

標籤:lamp   安裝   apache   

1.進入/usr/local/src/目錄下去下載Apache的安裝包httpd-2.2.29.tar.gz

[[email protected] support-files]# cd /usr/local/src

[[email protected] src]# ls

httpd-2.2.9.tar.gz

2.解壓安裝包

[[email protected] src]# tar zxvf httpd-2.2.9.tar.gz

3.進入安裝目錄

[[email protected] src]# cd httpd-2.2.9

[[email protected] httpd-2.2.9]# ls

ABOUT_APACHE      CHANGES        include         modules           srclib

acinclude.m4      config.layout  INSTALL         NOTICE            support

Apache.dsw        configure      InstallBin.dsp  NWGNUmakefile     test

apachenw.mcp.zip  configure.in   LAYOUT          os                VERSIONING

build             docs           libhttpd.dsp    README

BuildAll.dsp      emacs-style    LICENSE         README.platforms

BuildBin.dsp      httpd.dsp      Makefile.in     ROADMAP

buildconf         httpd.spec     Makefile.win    server

4.查看安裝說明檔案INSTALL可以看到安裝步驟

……

$ ./configure --prefix=PREFIX

$ make

$ make install

$ PREFIX/bin/apachectl start

……

5.使用下面的參數配置安裝選項,斷行符號即可

[[email protected] httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre

其中:

--prefix指定安裝目錄

--with-include-apr依賴包apr,支援httpd,可以跨平台運作

--with-pcre正則相關的庫

shared表示以動態共用的方式安裝

有錯改錯,缺少什麼庫就安裝:

如checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

yum install  zlib-devel

6.直到配置沒有問題然後開始編譯

[[email protected] httpd-2.2.9]# echo $?

0

[[email protected] httpd-2.2.9]# make

7.編譯沒問題然後開始安裝

[[email protected] httpd-2.2.9]# echo $?

0

[[email protected] httpd-2.2.9]# make install

8.安裝成功

[[email protected] httpd-2.2.9]# echo $?

0

[[email protected] httpd-2.2.9]# ls /usr/local/apache2/

bin    cgi-bin  error   icons    lib   man     modules

build  conf     htdocs  include  logs  manual

9.現在還不能直接運行,需要編輯Apache主設定檔httpd.conf:

[[email protected] httpd-2.2.9]# vim /usr/local/apache2/conf/httpd.conf

將ServerName改為localhost:80,去掉前面的注釋符#

……

# ServerName gives the name and port that the server uses to identify itself.

# This can often be determined automatically, but we recommend you specify

# it explicitly to prevent problems during startup.

#

# If your host doesn‘t have a registered DNS name, enter its IP address here.

#

ServerName localhost:80

……

10.將Apache加入系統內容變數:

[[email protected] support-files]# vim /etc/profile.d/path.sh

#!/bin/bash

export PATH=$PATH:/etc/init.d/:/usr/local/mysql/bin/:/usr/local/apache2/bin/

[[email protected] support-files]# source /etc/profile.d/path.sh

11.檢查配置是否正確,正確則啟動Apache

[[email protected] httpd-2.2.9]# apachectl -t

Syntax OK

[[email protected] httpd-2.2.9]# apachectl start

httpd (pid 22581) already running

12.查看Apache的進程和連接埠

[[email protected] httpd-2.2.9]# ps aux|grep httpd

[[email protected] httpd-2.2.9]# netstat -lnp


LAMP搭建2: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.