apache2 php5 mysql5安裝配置
一﹕下載以下package
curl-7.15.0.tar.gz
freetype-2.1.10.tar.gz
gd-2.0.35.tar.gz
httpd-2.2.4.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.2.8-config.tar.gz
php-5.2.3.tar.gz
zlib-1.2.3.tar.gz
mysql-5.0.45-linux-i686-glibc23.tar.gz
安裝php所需的package,其中libxml2是安裝php5必須的使用/usr/include內的也可
#####################apache php mysql#####
mysql5.0.21 -- 必需為source code make安裝
php5.1.2
httpd-2.2.4.tar.gz
GD庫所需要package有人說PHPsource code內建了GD2.0.28和zlib只要安裝GD的三個support package﹕jpg,png和freetype,但是我們還是下載,可以比較版本
查看操作系統版本﹕ # uname -r )
二﹕安裝apache2。
# tar -zvxf httpd-2.2.4.tar.gz 解壓httpd-2.2.4.tar.gz
# cd httpd-2.2.4 進入httpd-2.2.4目錄
# ./configure --prefix=/usr/local/apache 或者
# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
# make; make install 安裝apache
# vi /usr/local/apache/conf/httpd.conf
#ServerName www.example.com:80 在其下增加 ServerName xxxxxx.com.tw:80
# /usr/local/apache/bin/apachectl -k start 啟動apahce,
# 用瀏覽器查看http://www.xiutuo.com,得到it works,說明apache已經安裝成功\了。
# /usr/local/apache/bin/apachectl -k stop 停止apache。
三﹕安裝mysql(php5和mysql5必需用source code make)
configure MySQL 並加入對中文 big5 的支援
# ./configure --prefix=/usr/local/mysql --with-charset=big5 --with-extra-charsets=all
# make && make install
建立 mysql 使用者和群組
# useradd -s /bin/false -d /usr/local/mysql mysql
# useradd -g mysql mysql
修改mysql目錄權限
# chown -R root /usr/local/mysql
# chgrp -R mysql /usr/local/mysql
# chown -R mysql /usr/local/mysql/data
初始化 MySQL 資料庫並設定權限
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -Rf mysql var; chgrp -Rf mysql .
啟動 MySQL:
# bin/mysqld_safe --user=mysql &
如出現 Starting mysqld daemon with databases from /usr/local/mysql/data 代表正常啟動mysql服務了,
按Ctrl + C 跳出修改 mysql 的 root
密碼
# /usr/local/mysql/bin/mysqladmin -u root -p password "123456"
四﹕安裝GD庫(讓PHP支持GIF,PNG,JPEG)
a.安裝 jpeg6 建立目錄﹕
# mkdir -p /usr/local/jpeg6
# mkdir -p /usr/local/jpeg6/bin
# mkdir -p /usr/local/jpeg6/lib
# mkdir -p /usr/local/jpeg6/include
# mkdir -p /usr/local/jpeg6/man
# mkdir -p /usr/local/jpeg6/man1
# mkdir -p /usr/local/jpeg6/man/man1
# tar -zvxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make; make install
b.安裝libpng
# tar -zvxf libpng-1.2.8-config.tar.gz
# cd libpng-1.2.8-config
# cp scripts/makefile.std makefile
# make; make install
c.安裝 freetype (使用slackware 11內建)
# tar -zvxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# mkdir -p /usr/local/freetype
# ./configure --prefix=/usr/local/freetype
# make;make install
d.:安裝zlib
#tar -zxvf zlib-1.2.3.tar.gz
#cd zlib-1.2.3
# ./configure
# make;make install
e.安裝GD庫
# tar -zvxf gd-2.0.35.tar.gz
# mkdir -p /usr/local/gd2
# cd gd-2.0.35
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/ --with-zlib=/usr/local/lib/ --with-freetype=/usr/include/freetype/
# make; make install
e.安裝Curl庫 (使用slackware 11)
# tar -zxf curl-7.15.0.tar.gz
# mkdir -p /usr/local/curl
# ./configure --prefix=/usr/local/curl
# make; make install
a.安裝libxml2 (使用slackware 11內建)
# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# mkdir -p /usr/local/libxml2
# ./configure --prefix=/usr/local/libxml2
# make; make install
b.安裝 libxslt(可選安裝,你可以不安裝)
# tar -zxf libxslt-1.1.15.tar.gz
# mkdir -p /usr/local/libxslt (使用slackware 11內建)
# cd libxslt-1.1.15
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make; make install
五﹕安裝php5,php5必須有libxml2支援
# tar -zvxf php-5.1.2.tar.gz
# mkdir -p /usr/local/php
# cd php-5.1.2
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-debug
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-debug --with-mysql=/usr/local/mysql --with-curl=/usr/include/curl --enable-ftp
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-debug --with-mysql=/usr/local/mysql --with-curl=/usr/include/curl --enable-ftp --with-libxml-dir=/usr/include/libxml2 --with-expat-dir=/usr/lib --enable-soap --with-xsl=/usr/include/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/lib/ --with-png=/usr/local/lib/ --with-freetype-dir=/usr/include/freetype/
# make
# make install
******** cp php.ini-dist /usr/local/php/lib/php.ini (別忘記了呵呵)**********
其中./configure後的 --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/include/libxml2 (是必要的選項)
--with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png=/usr/local/lib --with-zlib-dir=/usr/local/lib --with-freetype-dir=/usr/include/freetype 這是讓PHP支援GD庫的配置選項
--with-curl=/usr/local/curl 支持CURL庫 --enable-ftp 打開FTP函數支援
--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt 讓PHP支援SOAP
簡易物件存取協定(Simple Object Access Protocol, SOAP)
六﹕重新配置apache2讓他支援php。
配置 httpd.conf 讓apache支持PHP
"enableplaintextpassword"==dword:00000001
# vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz
在其下加如下內容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# restart apache
# /usr/local/apache/bin/apachectl restart 在htdocs目錄內建一內容如下之test.php
<html>
<head>
</head>
<body>
<? phpinfo();?>
</body>
</html>
# 使用IE流灠 xxxxx.xxx.net.tw/test.php
問題
1.當你看到mysql有很多版本,如﹕ mysql-max-5.0.21-linux-i686-glibc23.tar.gz和 mysql-max-5.0.21-linux-i686.tar.gz 這倆個到底選哪個呢,glib23以上請選glibc23的,因為mysql briany版都會有跟glibc相容問題,經反覆TEST後,最後還是下載source code下來安裝最為妥當
2﹕編譯php時出現
./configure: /usr/local/apache2/bin/apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory 這是找不到perl解釋器的緣故。
修改/usr/local/apache2/bin/apxs文件中﹕ /replace/with/path/to/perl/interpreter
把他替換成perl所在的路徑如/opt/ActivePerl-5.8/bin/perl,
(如果你下載的是active perl5.8的rpm,他默認安裝路徑是/opt/ActivePerl-5.8/bin/perl)
3.安裝了perl后,發現所有的文本編輯器都不能用了。
運行vi或者gedit時候,提示找不到libperl.so 到perl的安裝目錄下找一個libperl.so放到/usr/lib
目錄下就解決問題了我的libperl.so在/opt/ActivePerl-5.8/lib/5.8.8/i686-linux-thread-multi-CORE/目錄下
。如果不知道libperl.so在什麼地方,可以用
# locate libperl.so
查找,或者用find命令
4.當我使用mysql-standard-5.0.20,編譯php時出現mysql錯誤﹕
checking for mSQL support... no checking for MSSQL support via FreeTDS... no checking for MySQL support... yes checking for specified location of the MySQL UNIX socket...
no checking for MySQL UNIX socket location... /tmp/mysql.sock checking
for mysql_close in
-lmysqlclient... no checking for mysql_error in
-lmysqlclient... no configure:
error: mysql configure failed. Please check config.log for more information.
安裝PHP的時候沒有指定一下mysql的安裝目錄。但是我已經指定了,
所以這個說法是錯誤的,其實主要原因是 mysql-level沒有裝,也就是mysql的版本不對,
應該換 mysql-max-5.0.21版本(包含所有mysql相關內容的軟件包)
還是建議用source code安裝
5.編譯php時出現 configure: error: freetype2 not found! 沒有安裝freetype-level
configure: error: libpng.(a|so) not found. 沒有安裝libpng-devel
6忘了mysql的root password
# /usr/local/mysql/support-files/mysql.server stop
# mysqld_safe --skip-grant-tables &
# mysqladmin -u user password \'newpassword\'
# mysqladmin flush-privileges
################################################################################
2007/07/30
################ 以下為PHP可過但mysql模組無法產生 #####################
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql-dir=/usr/local/mysql/ --with-curl=/usr/include/curl --enable-ftp --with-libxml-dir=/usr/include/libxml2 --with-expat-dir=/usr/lib --enable-soap --with-xsl=/usr/include/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/lib/ --with-png=/usr/local/lib/ --with-freetype-dir=/usr/include/freetype/
## 以下為PHP-OK
2007/07/31
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-debug --with-mysql=/usr/local/mysql --with-curl=/usr/include/curl --enable-ftp --with-libxml-dir=/usr/include/libxml2 --with-expat-dir=/usr/lib --enable-soap --with-xsl=/usr/include/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/lib/ --with-png=/usr/local/lib/ --with-freetype-dir=/usr/include/freetype/
|