1. 程式人生 > >LAMP環境搭建教程(原創)

LAMP環境搭建教程(原創)

作業系統:centos6.3

IP地址:192.168.146.129

閘道器:

DNS:

作業系統安裝步驟,此處不在給出截圖。

備註:伺服器系統採用最小化安裝,安裝一下GCC編譯工具和一個桌面即可。如下圖所示:

<a href="http://www.php100.com/uploadfile/2013/0219/20130219052450812.jpg" target="_blank" class="cboxElement" rel="example4" 15"="" style="text-decoration: none; color: rgb(1, 150, 227); ">

二、LAMP安裝前的準備

1、獲取軟體包

把上面下載的13個原始碼包放到linux系統下的/usr/local/src/目錄中,如下圖示:

<a href="http://www.php100.com/uploadfile/2013/0219/20130219052450509.png" target="_blank" class="cboxElement" rel="example4" 15"="" style="text-decoration: none; color: rgb(1, 150, 227); ">

2、檢查安裝時使用的編譯工具是否存在

<a href="http://www.php100.com/uploadfile/2013/0219/20130219052451742.png" target="_blank" class="cboxElement" rel="example4" 15"="" style="text-decoration: none; color: rgb(1, 150, 227); ">

如果安裝系統的時候已經安裝了GCC編譯工具,則顯示上圖中的資訊,如果沒有安裝,可以使用下面的方法進行安裝:

# From CentOS 5.8 - [DVD#1]

mkdir -p /media/cdrom

mount -r /dev/cdrom /media/cdrom

cd /media/cdrom/CentOS

rpm -Uvh glibc-devel-2.*

rpm -Uvh gcc-4.*

rpm -Uvh gcc-c++-4.*

rpm -Uvh libaio-devel-0.*

rpm -Uvh libstdc++-devel-4.*

如果上面安裝的一某個RPM包還需要另外一個包時,可繼續在光碟中查詢,這裡不在贅述。

3、檢查並解除安裝預設的低版本環 境                                                                                         由 於安裝系統的時候我是最小化安裝,只安裝了一個桌面,GCC編譯工具也是系統裝完之後安裝的,所以沒有預設的LAMP環境,如下圖示:

<a href="http://www.php100.com/uploadfile/2013/0219/20130219052451925.png" target="_blank" class="cboxElement" rel="example4" 15"="" style="text-decoration: none; color: rgb(1, 150, 227); ">

如果安裝的時候有選擇預設全部安裝,就已經安裝了LAMP環境,但是相對版本較低,而且安裝的路徑等可能不是我們想要的結果。所以這裡順便介紹一 下,如果存在預設的LAMP環境,進行解除安裝的方法,以apache為 例:                                                  #rpm -qa | grep -i httd  // 查詢系統中已安裝的Apache相關軟體 包                                         #service httpd stop      //如果 apache已開啟,停止執行apache服務 器                                    #rpm -e httpd-xxx --nodeps //解除安裝 apache服務 器                                                                       php、 mysql解除安裝方法同上。

【開始搭建LAMP環境】

搭建LAMP環境時,需要安裝的所有軟體都要按照一定的順序安裝,我們按照Apache->MySQL->PHP的順序安裝。但是在安 裝PHP之前,應先安裝PHP5需要的最新版本庫檔案,例如libxml2、libmcrypt,以及GD2庫等檔案。安裝GD2庫是為了讓PHP5支援 GIF、PNG和JPEG圖片格式,所以在安裝GD2庫之前還要先安裝最新的zlib、libpng、freetype和jpegsrc等庫檔案。而且中 間還會穿插安裝一些軟體。

1、解壓tar.gz為字尾的壓縮包軟體

LAMP環境搭建所需要的每個軟體的原始碼檔案,都是以.tar.gz提供給我們的打包壓縮檔案,所以我們必須將其解壓再解包。可通過命令#tar zxvf tarfile.tar.gz達到目的。

2、在linux系統中原始碼包安裝過程

進行解壓後的目錄,LAMP環境搭建所需要的軟體都使用C語言開發的,所以安裝原始碼檔案最少需要配置(configure)、編譯(make)、安裝(make install)三個步驟。

安裝libxml2最新庫檔案

step1:進入下載的軟體原始碼包所在目錄/usr/local/src/下,解壓軟體包libxml2-2.9.0.tar.gz到當前目錄libxml2-2.9.0下,並進入libxml2-2.9.0目錄。命令如下行所示:

[[email protected]   ~]# cd /usr/local/src  //進入軟體原始碼包所在目錄

[[email protected]   src]# tar zxvf libxml2-2.9.0.tar.gz //解包解壓

[[email protected]   src]# cd libxml2-2.9.0  //進入解包解壓後的目錄

step2:使用configure命令檢查並配置安裝需要的系統環境,並生成安裝配置檔案,命令列如下。

[[email protected]   libxml2-2.9.0]# ./configure --prefix=/usr/local /libxml2 //選項--prefix=/usr/local/libxml2作用,是在安裝時將軟體安裝到/usr/local/libxml2 目錄下。

step3:使用make命令編譯原始碼檔案並生成安裝檔案。命令列如下示。

[[email protected]   libxml2-2.9.0]# make  //對軟體原始碼檔案進行編譯

step4:使用make install命令安裝編譯過的檔案。命令列如下。

[[email protected]   libxml2-2.9.0]# make install  //開始安裝libxml2庫檔案

如果安裝成功以後,在/usr/local/libxml2/目錄下將生成bin,include,lib,share四個目錄。在後面安裝 PHP5原始碼的配置時,會通過在configure命令的選項中加上"--with-libxml-dir=/usr/local/libxml2"選 項,用於指定安裝libxml2庫檔案的位置。

安裝libmcrypt最新庫檔案

安裝方法與上面安裝libxml2方法相同,注意configure時的路徑/usr/local/libmcrypt

如果安裝成功就會在/usr/local/libmcrypt/目錄下生成bin,include,lib,man,share五個目錄。然後在安 裝PHP5原始碼包的配置時,就可以通過configure命令加上“--with-mcrypt-dir=/usr/local/libmcrypt” 選項,指定這個libmcrypt庫檔案的位置。

如./configure時報錯:configure: error: C++ compiler cannot create executables 。

解決方案:

執行下面命令,然後重新configure(配置)

yum install gcc gcc-c++ gcc-g77

安裝完成libmcrypt庫以後,不同的linux系統版本有可能還要安裝一下libltdl庫。安裝方法和前面的步驟相同,可以進入到解壓縮的 目錄/usr/local/src/libmcrypt-2.5.8下,找到libltdl庫原始碼所在的目錄libltdl,進入這個目錄按照下面幾個 命令配置、編譯、安裝就可以了。

[[email protected]   libltdl]# pwd

/usr/local/src/libmcrypt-2.5.8/libltdl  //進入軟體原始碼目錄

[[email protected]   libltdl]# ./configure --enable-ltdl-install  //配置ltdl庫的安裝

[[email protected]   libltdl]# make  //編譯

[[email protected]   libltdl]# make install  //安裝

安裝zlib最新庫檔案

安裝方法與前面安裝libxml2的方法相同,要注意的地方就是路徑/usr/local/zlib/。如果安裝成功將會在/usr/local /zlib目錄下生成include,lib,share三個目錄。在安裝PHP5配置時,在configure命令的選項中加上“--with- zlib-dir=/usr/local/libmcrypt”選項,用於指定zlib庫檔案位置。

安裝libpng最新庫檔案

安裝方法與前面安裝libxml2的方法相同,要注意路徑/usr/local/libpng/

在./configure --prefix=/usr/local/libpng這步最後會提示:configure: error: ZLib not installed

解決方法如下:

1.進入zlib的原始檔目錄,執行命令 make clean,清除zlib;

2.重新配置 ./configure,後面不要接--prefix引數;

3.make && make install;

4.進入libpng目錄,執行命令 ./configure --prefix=/usr/local/libpng;

5.make && make install;

6.安裝成功.

如果安裝成功將會在/usr/local/libpng目錄下生成bin,include,lib和share四個目錄。在安裝GD2庫配置時,通 過在configure命令選項中加上“--with-png=/usr/local/libpng”選項,指定libpng庫檔案的位置。

安裝jpeg8最新庫檔案

step1:安裝GD2庫前所需的jpeg8庫檔案,需要自己手動建立安裝需要的目錄,它們在安裝時不能自動建立。命令列如下。

[[email protected]   ~]# mkdir /usr/local/jpeg8  //建立jpeg8軟體安裝目錄

[[email protected]   ~]# mkdir /usr/local/jpeg8/bin //建立存放命令的目錄

[[email protected]   ~]# mkdir /usr/local/jpeg8/lib  //建立jpeg8庫檔案所在目錄

[[email protected]   ~]# mkdir /usr/local/jpeg8/include //建立存放標頭檔案目錄

[[email protected]   ~]# mkdir -p /usr/local/jpeg8/man/man1 //建立存放手冊的目錄

step2:configure有點不一樣,如下命令列示:

[[email protected]   jpeg-8b]# ./configure \

> --prefix=/usr/local/jpeg8/ \

> --enable-share \

> --enable-static

警告:configure: WARNING: unrecognized options: --enable-share

在安裝GD2庫配置時,可以在configure命令的選項中加上“--with-jpeg=/usr/local/jpeg8”選項,指定jpeg8庫檔案的位置。安裝PHP時也要指定該庫檔案的位置。

安裝freetype最新庫檔案

step1:進入軟體原始碼包所在目錄/usr/local/src/中,解壓軟體包freetype-2.4.10.tar.gz到當前目錄freetype-2.4.10下,並進入freetype-2.4.10目錄。命令列如下:

#cd /usr/local/src/   //進入軟體原始碼包所在目錄

#tar zxvf freetype-2.4.10.tar.gz  //解壓包到freetype-2.4.10目錄

#cd freetype-2.4.10 //進入目錄freetype-2.4.10中

step2:使用configure命令檢查並配置安裝需要的系統環境,並生成安裝配置檔案。命令列如下:

#./configure --prefix=/usr/local/freetype //選項--prefix=/usr/local/freetype,是在安裝時將軟體安裝到/usr/local/freetype目錄下

step3:使用make命令編譯原始碼檔案並生成安裝檔案,命令列如下:

#make  //對軟體原始碼檔案進行編譯

step4:使用make install命令進行安裝,命令列如下:

#make install //開始安裝freetype庫檔案

如果安裝成功將會在/usr/local/freetype目錄下存在bin,include,lib和share四個目錄。並在安裝GD2庫時, 通過configure命令選項中加上“--with-freetype=/usr/local/freetype/”選項,指定freetype庫檔案 位置。

安裝atuoconf最新的庫檔案

其方法與上面安裝freetype相同。唯一注意的地方是configure時,不用指定路徑。

安裝最新的GD庫檔案

安裝方法大致與freetype相同。唯一注意的地方是configure時的路徑,命令列如下:

#./configure \  //配置命令

>--prefix=/usr/local/gd \  //指定安裝軟體的位置

>--with-jpeg=/usr/local/jpeg8/ \  //指定去哪找jpeg庫檔案

>--with-png=/usr/local/libpng/ \  //指定去哪找png庫檔案

>--with-freetype=/usr/local/freetype/   //指定去哪找freetype 2.x字型庫的位置

如果安裝成功會在/usr/local/gd/目錄下存在bin、include和lib這三個目錄。在安裝PHP5時,通過在configure命令選項中加上“--with-gd=/usr/local/gd”選項,指定GD庫檔案的位置。

如果報錯:

make[2]: *** [gd_png.lo] Error 1

make[2]: Leaving directory `/tmp/gd-2.0.35'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/tmp/gd-2.0.35'

make: *** [all] Error 2

解決方案:

vi gd_png.c

找到#include "png.h"改成#include "/usr/local/libpng/include/png.h"

安裝新版本的apache伺服器

1、解除安裝apr、apr-util

yum remove apr apr-util

下載安裝:

http://apr.apache.org/download.cgi

apr-1.4.6.tar.gz

./configure --prefix=/usr/local/apr-httpd/ && make && make install

下載安裝:

http://apr.apache.org/download.cgi

apr-util-1.5.1.tar.gz

./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/ && make && make install

下載:http://sourceforge.net/projects/pcre

#unzip -o pcre-8.32.zip

#cd pcre-8.32

#./configure --prefix=/usr/local/pcre

#make

#make install

[[email protected]   httpd-2.4.3]# ./configure \

> --prefix=/usr/local/apache243 \

> --enable-mods-shared=all \

> --enable-deflate \

> --enable-speling \

> --enable-cache \

> --enable-file-cache \

> --enable-disk-cache \

> --enable-mem-cache \

> --enable-so \

> --enable-expires=shared \

> --enable-rewrite=shared \

> --enable-static-support \

> --sysconfdir=/etc/httpd \

> --with-z=/usr/local/zlib/ \

> --with-apr=/usr/local/apr-httpd/ \

> --with-apr-util=/usr/local/apr-util-httpd/ \

> --with-pcre=/usr/local/pcre/ \

> --disable-userdir

#make && make install

安裝完成後,進入/usr/local/apache243/目錄下,檢查是否有以下檔案:

bin  build  cgi-bin  error  htdocs  icons  include  logs  man  manual  modules

啟動Apache伺服器,並查埠是否開啟,啟動Apache伺服器的命令列如下:

#/usr/local/apache243/bin/apachectl start

提示資訊:

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message

解決方案:

vi /etc/httpd/httpd.conf

加上下面一行,重啟apache

ServerName localhost:80

檢視埠命令列如下:

#netstat -tnl|grep 80

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LIST

測試安裝結果,開啟瀏覽器,在位址列中輸入URL為:http://192.168.146.129/

如果瀏覽器中出現It works!則表明Apache伺服器可以使用。

每種伺服器軟體都有必要製成開機時自動啟動,Apache伺服器開機自動啟動,只要在“/etc/rc.d/rc.local”檔案,加上 Apache伺服器的啟動命令即可。可以直接開啟“/etc/rc.d/rc.local”檔案,在最後一行寫入Apache啟動命令,也可以用echo 命令追加進去,如下命令列示:

[[email protected]   apache243]# echo "/usr/local/apache243/bin/apachectl start" >> /etc/rc.d/rc.local

安裝MySQL資料庫管理系統

1、增加使用者名稱和使用者組

#groupadd mysql

#useradd -g mysql mysql

2、進入原始碼包使用configure 檢查並配置安裝需要的系統環境,並生成安裝配置檔案

#./configure \

>--prefix=/usr/local/mysql \  //將軟體安裝在/usr/local/mysql目錄下

>--enable-thread-safe-client \

>--with-extra-charsets=all  //在安裝mysql時安裝所有字符集

如果遇到錯誤資訊:

checking for tgetent in -lncurses... no

checking for tgetent in -lcurses... no

checking for tgetent in -ltermcap... no

checking for termcap functions library... configure: error: No curses/termcap library found

原因:缺少ncurses安裝包

解決方案:

執行下面三行命令,執行完之後重新./configure(配置)

yum list|grep ncurses

yum -y install ncurses-devel

yum install ncurses-devel

接著#make && make install

3、建立mysql資料庫伺服器的配置檔案,可以使用原始碼包support-files目錄中的my-medium.cnf檔案作為模板,將其複製到/etc/目錄下,命名為my.cnf檔案即可。

[[email protected]   mysql-5.0.18]# cp support-files/my-medium.cnf /etc/my.cnf

4、如果還沒安裝過MySQL,必須建立MySQL授權表。進入到安裝目錄/usr/local/mysql下,執行bin目錄下的mysql_install_db指令碼,用來初始化MySQL資料庫的授權表,其中儲存了伺服器訪問允許。

[[email protected]   mysql-5.0.18]#cd /usr/local/mysql

[[email protected]   mysql]# bin/mysql_install_db --user=mysql  //建立授權表

如果使用root使用者執行上面的命令,應當使用--user選項,選項的值應當與你在第一步為執行伺服器所建立的登入賬戶(mysql使用者)相同。 如果用mysql使用者登入來執行上面的命令,可以省略--user選項。用mysql_install_db建立mysql授權表後,需要手動重新啟動服 務器。

5、將程式二進位制的所有權改為root使用者,資料目錄的所有權改為執行mysqld程式的mysql使用者。如果現在位於安裝目錄(/usr/local/mysql)下,命令列如下:

[[email protected]   mysql]# chown -R root .(注意有點)  //將檔案的所有屬性改為root使用者

[[email protected]   mysql]# chown -R mysql var  //將資料目錄的所有屬性改為mysql使用者

[[email protected]   mysql]# chgrp -R mysql .  //將組屬性改為mysql組

[[email protected]   mysql]# ls -l

total 40

drwxr-xr-x. 2 root  mysql 4096 Feb  7 20:50 bin

drwxr-xr-x. 3 root  mysql 4096 Feb  7 20:50 include

drwxr-xr-x. 2 root  mysql 4096 Feb  7 20:50 info

drwxr-xr-x. 3 root  mysql 4096 Feb  7 20:50 lib

drwxr-xr-x. 2 root  mysql 4096 Feb  7 20:50 libexec

drwxr-xr-x. 3 root  mysql 4096 Feb  7 20:50 man

drwxr-xr-x. 7 root  mysql 4096 Feb  7 20:50 mysql-test

drwxr-xr-x. 3 root  mysql 4096 Feb  7 20:50 share

drwxr-xr-x. 5 root  mysql 4096 Feb  7 20:50 sql-bench

drwx------. 4 mysql mysql 4096 Feb  7 20:53 var

6、在所需要的東西被安裝完成後,應當使用下面的命令啟動MySQL服務了,命令列如下:

[[email protected]   mysql]#/usr/local/mysql/bin/mysqld_safe --user=mysql &

報告資訊(不理會):

[[email protected]   mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql &

[1] 4720

[[email protected]   mysql]# nohup: ignoring input and redirecting stderr to stdout

Starting mysqld daemon with databases from /usr/local/mysql/var

7、MySQL資料庫伺服器啟動之後,檢視一下它的埠3306是否開啟,如果看到以下結果表明mysql服務啟動成功。命令列如下

[[email protected]   mysql]# netstat -tnl|grep 3306

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN

8、使用mysqladmin驗證伺服器在執行中。以下命令提供了簡單的測試,可檢查伺服器是否已經開啟並能響應連線。命令列如下:

[[email protected]   mysql]# bin/mysqladmin  version

Enter password:

bin/mysqladmin  Ver 8.41 Distrib 5.0.18, for pc-linux-gnu on i686

Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL license

Server version          5.0.18-log

Protocol version        10

Connection              Localhost via UNIX socket

UNIX socket             /tmp/mysql.sock

Uptime:                 18 min 59 sec

Threads: 1  Questions: 3  Slow queries: 0  Opens: 0  Flush tables: 1  Open tables: 6  Queries per second avg: 0.003

[[email protected]   mysql]# bin/mysqladmin variables //檢視所有mysql引數

9、設定訪問許可權,在mysql安裝過程中,使用mysql_install_db程式安裝了mysql資料庫授權表,表定義了初始mysql使用者 賬戶和訪問許可權,所有初始化賬戶均沒有密碼。這些賬戶為超使用者賬戶,可以執行任何操作。初始root賬戶的密碼為空,因此任何人可以用root賬戶不用任 何密碼來連線mysql伺服器,並具有所有許可權,這意味著mysql安裝未受保護。如果你想要防止客戶端不使用密碼用匿名使用者來連線,你應當為匿名賬戶指 定密碼或刪掉匿名帳戶,應當為mysql root賬戶指定密碼。使用mysql -u root啟動mysql客戶端控制檯,連線mysql伺服器。命 令行如下:

[[email protected]   mysql]# bin/mysql -u root  //沒有密碼可直接登入本機伺服器

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5 to server version: 5.0.18-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

10、如果有匿名賬戶存在,它擁有全部的許可權,因此刪掉它可以提高安全,在mysql客戶端執行SQL語如下:

mysql> delete from mysql.user where host='localhost' and user='';

Query OK, 1 row affected (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

11、可以用幾種方法為root賬戶指定密碼,我們選擇用其中的一種。在mysql客戶端命令列上使用set password指定密碼,一定要使 用password()函式來加密密碼。例如下面設定localhost域的密碼為ios100。其他域可以使用同樣的語句,使用的SQL語句如下。

mysql> set password for 'root'@'localhost'=password('ios100');

Query OK, 0 rows affected (0.00 sec)

12、如果想退出mysql客戶端,可以在mysql客戶端提示符下輸入命令exit或者quit,還可以按鍵盤ctrl+c組合鍵,都可以從 mysql客戶端退出。因為已經給mysql伺服器的root賬號設定了密碼,所以再次登入mysql客戶端就要提供密碼才能進入。退出mysql客戶端 和重新啟動mysql客戶端的控制檯命令如下。

mysql> exit

Bye

[[email protected]   mysql]# bin/mysql -u root -h localhost -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6 to server version: 5.0.18-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

如果想關閉mysql伺服器,在命令列使用mysql伺服器的mysqladmin命令,通過-u引數給出mysql資料庫管理員使用者名稱root和通過-p引數給出密碼,即可關閉mysql伺服器。如下示:

[[email protected]   mysql]# bin/mysqladmin -u root -p shutdown

Enter password:

STOPPING server from pid file /usr/local/mysql/var/localhost.pid

130207 21:27:05  mysqld ended

[1]+  Done                    /usr/local/mysql/bin/mysqld_safe --user=mysql

13、mysql伺服器和apache伺服器一樣也有必要設定為開機自動執行,設定方法進入到mysql原始碼目錄/usr/local/src /mysql-5.0.18,將子目錄support-files下的mysql.server檔案複製到/etc/rc.d/init.d目錄中,並重 命名為mysqld,命令列如下。

[[email protected]   mysql]# cd /usr/local/src/mysql-5.0.18

[[email protected]   mysql-5.0.18]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

修改一下許可權

[[email protected]   mysql-5.0.18]# chown root.root /etc/rc.d/init.d/mysqld

[[email protected]   mysql-5.0.18]# chmod 755 /etc/rc.d/init.d/mysqld

把mysqld新增到chkconfig中

[[email protected]   mysql-5.0.18]# chkconfig --add mysqld

在圖形和字符集介面下自動啟動mysqld

[[email protected]   mysql-5.0.18]# chkconfig --level 3 mysqld on

[[email protected]   mysql-5.0.18]# chkconfig --level 5 mysqld on

再使用chkconfig --list命令檢查設定

[[email protected]   mysql-5.0.18]# chkconfig --list mysqld

mysqld          0:off   1:off   2:on    3:on    4:off    5:on    6:off

安裝最新版的PHP模組

進入php-5.4.11原始碼包編譯

[[email protected]   php-5.4.11]# ./configure \

> --prefix=/usr/local/php \

> --with-config-file-path=/usr/local/php/etc \

> --with-apxs2=/usr/local/apache243/bin/apxs \

> --with-mysql=/usr/local/mysql/ \

> --with-libxml-dir=/usr/local/libxml2/ \

> --with-png-dir=/usr/local/libpng/ \

> --with-jpeg-dir=/usr/local/jpeg8/ \

> --with-freetype-dir=/usr/local/freetype/ \

> --with-gd=/usr/local/gd/ \

> --with-zlib-dir=/usr/local/zlib/ \

> --with-mcrypt=/usr/local/libmcrypt/ \

> --with-mysqli=/usr/local/mysql/bin/mysql_config \

> --enable-soap \

> --enable-mbstring=all \

> --enable-sockets

make(配置)

提示資訊:

Build complete.

Don't forget to run 'make test'.

解決方案:

不要make test 直接make install

配置時可能會出現下面的錯誤:

checking for MySQL support... yes

checking for specified location of the MySQL UNIX socket... no

checking for MySQL UNIX socket location... no

configure: error: Cannot find libmysqlclient_r under /usr/local/mysql. Note that the MySQL client library is not bundled anymore!

其實這跟PHP沒有關係,那是因為在編譯APACHE的時候,使用--with-mpm模組,所以就必須在編譯MYSQL的時候加上 --enable-thread-safe-client.引數

這是PHP5.2的一個改進,在PHP5.2.0之前的版本都不需要MYSQL啟用安全執行緒。關於--enable-thread-safe- client項的官方介紹如下:如何生成執行緒式客戶端庫總是執行緒安全的。最大的問題在於從套接字讀取的net.c中的子程式並不是中斷安全的。或許你可能 希望用自己的告警中斷對伺服器的長時間讀取,以此來解決問題。如果為SIGPIPE中斷安裝了中斷處理程式,套接字處理功能應是執行緒安全的。 SupeSite/X-為了避免連線中斷時放棄程式,MySQL將在首次呼叫mysql_server_init()、mysql_init()或 mysql_connect()時遮蔽SIGPIPE。如果你打算使用自己的SIGPIPE處理程式,首先應呼叫 mysql_server_init(),然後安裝你的處理程式.

還有第二種解決方法比較方便 :編譯之前,先處理一下mysql的庫,預設查詢libmysqlclient_r.so,可是mysql預設為libmysqlclient.so,內容完全一樣,做個連結即可

# cd /usr/local/mysql/lib/mysql/

# ln -s libmysqlclient.so.15.0.0 libmysqlclient_r.so

(以上解決方法來自網際網路!)

還會報make: *** [ext/gd/gd.lo] error

解決方法如下:

好像說這個錯誤算是php5.4的bug,下面對應的兩篇文章有對應的說明:

https://bugs.php.net/bug.php?id=55224

https://bugs.php.net/bug.php?id=60108

解決方法:

vi <gd_dir>/include/gd_io.h

gdIOCtx結構中增加void *data;

格式如下

typedef struct gdIOCtx

{

int (*getC) (struct gdIOCtx *);

int (*getBuf) (struct gdIOCtx *, void *, int);

void (*putC) (struct gdIOCtx *, int);

int (*putBuf) (struct gdIOCtx *, const void *, int);

/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */

int (*seek) (struct gdIOCtx *, const int);

long (*tell) (struct gdIOCtx *);

void (*gd_free) (struct gdIOCtx *);

void (*data);

}

gdIOCtx;

我的GD安裝在/usr/local/gd2目錄下,所以是#vi vi /usr/local/gd/include/gd_io.h

libltdl.so.3: cannot open shared object file: No such file or directory

make: *** [ext/phar/phar.php] Error 127

解決方法:

ln -s /usr/local/lib/libltdl.so.3 /usr/lib/libltdl.so.3

[[email protected]   ~]# cd /usr/local/libpng/lib/

[[email protected]   lib]# ls

libpng15.a   libpng15.so     libpng15.so.15.10.0  libpng.la  pkgconfig

libpng15.la  libpng15.so.15  libpng.a             libpng.so

可以看到libpng15.so.15

然後修改/etc/ld.so.conf 檔案:vi /etc/ld.so.conf

在第一行下面追加/usr/local/libpng/lib這個路徑。

然後重新編譯安裝即可。

提示資訊:

=====================================================================

=====================================================================

WARNED TEST SUMMARY

---------------------------------------------------------------------

Bug #52062 (large timestamps with DateTime::getTimestamp and DateTime::setTimestamp) (32 bit) [ext/date/tests/bug52062.phpt] (warn: XFAIL section but test passes)

=====================================================================

You may have found a problem in PHP.

This report can be automatically sent to the PHP QA team at

http://qa.php.net/reports and http://news.php.net/php.qa.reports

This gives us a better understanding of PHP's behavior.

If you don't want to send the report immediately you can choose

option "s" to save it.  You can then email it to [email protected] later.

Do you want to send this report now? [Yns]:

解決方案:

不要make test 直接make install

安裝完成後,需要建