一、Apache安裝
下載apache (http://httpd.apache.org/)到tmp
解壓,tar –zxvf httpd-2.2.6.tar.gz
cd httpd-2.2.6
mkdir /usr/local/apache2
./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-rewrite --enable-cache
make
make install
安裝apache完成,輸入命令 #/usr/local/apache2/bin/apachectl -k start
啟動Apache
service httpd start
二、Mysql安裝
到這裡下載mysql RPM(service和client),
MySQL-server-community-5.1.51-1.rhel5.i386.rpm 安裝服務端
MySQL-client-community-5.1.51-1.rhel5.i386.rpm 安裝用戶端
MySQL-devel-community-5.1.51-1.rhel5.i386.rpm 用於php的mysql安裝
rpm –ivh MySQL-server-community-5.1.51-1.rhel5.i386.rpm
rpm –ivh MySQL-client-community-5.1.51-1.rhel5.i386.rpm
rpm –ivh MySQL-devel-community-5.1.51-1.rhel5.i386.rpm
三、 PHP準備的tar包安裝
安裝php之前要準備:
curl-7.15.0.tar.gz
freetype-2.3.5.tar.gz
gd-2.0.35.tar.gz
gettext-0.16.1.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.2.31.tar.bz2
libxml2-2.6.31.tar.gz
t1lib-5.0.0.tar.gz
tiff-3.8.2.tar.gz
zlib-1.2.3.tar.gz
3.1 安裝curl-7.15.0.tar.gz
#tar zxvf curl-7.15.0.tar.gz
#cd curl-7.15.0
#mkdir /usr/local/crul
#./configure --prefix=/usr/local/curl
#make clean
#make
#make install
3.2 jpegsrc.v6b.tar.gz
#mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
#./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
#make clean
#make
#make install
3.3 libxml2-2.6.31.tar.gz
#tar zxvf libxml2-2.6.31.tar.gz
#cd libxml2
#mkdir usr/local/libxml2
#./configure --prefix=/usr/local/libxml2
#make clean
#make(時間可能稍長些)
#make install
#cp xml2-config /usr/bin
3.4 PDFlib-7.0.3-Linux-php.tar.gz
#tar xvf PDFlib-7.0.3-Linux-php.tar.gz
#cd pdflib
#cp bind/php5/php520mt/libpdf-php.so /usr/local/lib/
(上面的php520mt目錄的同級目錄中有php503,php510,php520目錄,不知道是不是版本的區別)
3.5 t1lib-5.0.0.tar.gz
#tar zxvf t1lib-5.0.0.tar.gz
#cd t1lib
#mkdir /usr/local/t1lib
#./configure --prefix=/usr/local/t1lib
#make without-doc
#make install
3.6 freetype-2.3.5.tar.gz
#tar zxvf freetype-2.3.5.tar.gz
#cd freetype
# mkdir /usr/local/freetype
#./configure --prefix=/usr/local/freetype
#make clean
#make
#make install
3.7 zlib-1.2.3.tar.gz
#tar zxvf zlib-1.2.3.tar.gz
#cd zlib-1.2.3
#./configure --shared
#make clean
#make
#make install
3.8 libpng-1.2.26.tar.gz
#tar zxvf libpng-1.2.26.tar.gz
#cd libpng
#cp scripts/makefile.linux ./makefile
#mkdir /usr/local/libpng
#./configure --prefix=/usr/local/libpng
#make clean
#make
#make install
3.9 gettext-0.16.tar.gz
#tar zxvf gettext-0.16.tar.gz
#cd gettext
#mkdir /usr/local/gettext
#./configure --prefix=/usr/local/gettext
#make clean
#make
#make install(時間稍長)
3.10 gd-2.0.35.tar.gz
#tar zxvf gd-2.0.35.tar.gz
#cd gd
#./configure --with-png=/usr/local/lib --with-zlib=/usr/local/lib --with-freetype=/usr/local/freetype/lib --with-jpeg=/usr/local/jpeg/lib
#make clean
#make
#make install四、安裝PHP
下載php-5.2.14
tar gxvf php-5.2.14.tar.bz2
cd php-5.2.14
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --enable-track-vars --with-sockets --enable-sockets --with-sysvshm --with-sysvsem --with-pdflib-dir=/usr/local/lib --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/lib --enable-mbstring=all --with-zlib-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype --with-curl=/usr/local/curl --with-libxml-dir=/usr/local/libxml2/lib --with-gettext=/usr/local/gettext/lib --with-gd --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config
#make clean
#make
#make test
# make install
Php.ini檔案的修改
#cp php.ini-production /usr/local/lib/php.ini
#vi /usr/local/lib/php.ini
尋找修改extension_dir=./的內容(如下)
extension_dir = /usr/local/lib
添加PHP的環境變數:
臨時的 #export PATH=$PATH:/usr/local/php/bin
永久性的:在/etc下有個profile的檔案,將其開啟把“export PATH=$PATH:/usr/local/php/bin”這句放在“export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC”的上一行
立即生效環境配置,不需要重啟,用下命令:
. /etc/profile
五、修改apache設定檔httpd.conf
#vi /usr/local/apache2/conf/httpd.conf
尋找AddType 大約在DefaultType text/plain
<IfModule mime_module>
輸入如下內容
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .html
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .php
(不清楚是不是必須輸入這麼多項)
尋找DirectoryIndex index.html 在其後輸入 index.php
尋找確保有如下兩行配置:
LoadModule php5_module modules/libphp5.so
LoadModule rewrite_module modules/mod_rewrite.so
儲存檔案,退出。