LAMP安裝配置手記

來源:互聯網
上載者:User

配置環境
作業系統:Redhat Enterprise AS 4
已安裝包:httpd2.0.4, mysql4.1,libxml2.6.16, zlib1.2.1.2,gd2.0.28, libpng1.2.7
說明:網上的各種安裝說明都不是很好地說明了配置參數的來由,本文將儘可能標明每一步的必要性.已安裝包不是必需的,其中mysql可以獨立安裝,而rpm包形式的httpd因為不是mod-so形式安裝的,如果要支援php或者其它模組,要強制remove重安裝編碼版本. #rpm --nodeps --erase httpd
其它php可能需要的模組功能說明:
libxml2: xml解析庫
zlib: 開源壓縮庫
gd: 圖形庫
libpng: 用來處理png映像格式檔案的庫
freetype: TrueType字型繪製引擎
ZendOptimizer:
JPEG庫:

然後下載檔案mysql,apache,php,請到下面網址下載相應軟體
http://www.apache.org
http://www.php.net
http://www.mysql.com

第一步:安裝apache
進入安裝目錄,依次執行下面命令:
解壓源碼包
# tar -zxf httpd-2.0.55.tar.gz
進入安裝目錄
# cd httpd-2.0.55
配置apache安裝資訊, 配置安裝後目錄,模組動態配置,允許重寫重配置
# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
執行make安裝
# make; make install

第二步:配置apache
修改httpd.conf檔案
//ServerName 修改主機名稱,若無dns,則用IP替代
ServerName 192.168.36.163:80

//DocumentRoot 修改文檔路徑,就是要放置目標網頁的地方
DocumentRoot "/var/www/html"
<Directory "/var/www/html">

//DirectoryIndex 修改預設的首頁名稱
DirectoryIndex index.html index.php index.htm

第三步:安裝PHP
進入安裝目錄,依次執行下面命令:
解壓源碼包
# tar -zxf php-5.0.5.tar.gz
進入安裝目錄
#  cd php-5.05
配置php安裝資訊, 配置安裝後目錄,模組動態配置,允許重寫重配置
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-curl=/usr/local/curl --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --enable-soap --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --enable-mbstring
其中./configure 後的
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/
--with-libxml-dir
--enable-mbstring
是必要的選項

--with-gd=/usr/local/gd2/
--with-jpeg-dir=/usr/local/jpeg6/
--with-png
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
這是讓PHP支援GD庫的配置選項

執行make安裝
# make; make install

第四步:配置 httpd.conf讓apache支援PHP
# vi /usr/local/apache/conf/httpd.conf
php安裝完後會自動在httpd.conf加上下面一行(若無,請手動添加):
LoadModule php5_module        modules/libphp5.so

找到 AddType application/x-gzip .gz .tgz 在其下添加如下內容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

重啟apache
# /usr/local/apache/bin/apachectl restart

附:apache的一些重要配置選項
1 Directory
<Directory />
    Options FollowSymLinks
    AllowOverride None 
    Order deny,allow  #說明先執行denny,再執行allow
    allow from all   #此句是允許所有地址訪問,在這可設定具體IP的存取權限
</Directory>

2 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" #指令碼路徑
3 redirects (http return status code)
ErrorDocument 500 "The server made a boo boo."
ErrorDocument 404 /missing.html
ErrorDocument 404 "/cgi-bin/missing_handler.pl"
ErrorDocument 402 http://www.example.com/subscription_info.html

參考資料: 
http://blog.csdn.net/shfabjc/archive/2007/07/03/1676375.aspx 

聯繫我們

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