linux 配置php5.3

來源:互聯網
上載者:User

1、首先修改yum源,修改成163的源以便提高速度

2、首先更新yum:

1 yum -y update

3、使用yum安裝需要的程式和庫

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
yum -y install libevent libevent-devel
yum install libc-client-devel

4、下載並安裝所需程式
通過wget命令將下列檔案下載到cd /usr/src/中
wget http://nginx.org/download/nginx-0.8.52.tar.gz
wget http://cn.php.net/get/php-5.3.3.tar.gz/from/this/mirror
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.6-rc.tar.gz/from/http://mysql.he.net/
wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?use_mirror=ncu
wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?use_mirror=ncu
wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz?use_mirror=ncu
wget http://downloads.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.tar.gz?use_mirror=ncu
wget http://downloads.sourceforge.net/project/imagemagick/ImageMagick/00-6.6.5/ImageMagick-6.6.5-0.tar.gz?use_mirror=ncu
wget http://pecl.php.net/get/APC-3.1.4.tgz
wget http://pecl.php.net/get/memcache-2.2.6.tgz
wget http://pecl.php.net/get/imagick-3.0.1RC2.tgz

5、安裝上述所下載的軟體:
①安裝libiconv:

tar zxvf libiconv-1.13.1.tar.gz 
cd libiconv-1.13.1/
./configure --prefix=/usr/local/libiconv
make
make install

②修改動態連結載入的目錄尋找檔案

vi /etc/ld.so.conf

在檔案最後添加一行內容/usr/local/lib,然後運行以下命令

/sbin/ldconfig

③安裝libmcrypt

./configure 
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make instal

④安裝mhash

./configure 
make
make install
cd ../
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

⑤安裝mcrypt

cd mcrypt-2.6.8/ 
/sbin/ldconfig
./configure
make
make install

⑥安裝memcached

cd memcached-1.4.5 
./configure --prefix=/usr/local/memcached
make
make install

⑦安裝pcre

cd pcre-8.10/ 
./configure
make
make install

6、配置php

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/lib/libxml2.so.2.7.6 --with-mysql=/usr/include/mysql/ --with-config-file-path=/usr/local/php --with-iconv=/usr/local/libiconv/ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --with-IBM_DB2=/home/db2inst1/sqllib/include --enable-sockets  --enable-ftp --with-ldap[=DIR] --with-ldap-sasl[=DIR] memcache memcached

注意:
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd,這樣mysql, mysqli, pdo mysql都會使用mysqlnd。(使用mysqlnd後,需要使用mysqladmin重新設定一下mysql密碼:mysqladmin -u root -p password。
配置php過程中如果提示Cannot find MySQL header file under...,是由於沒有找到mysql.h檔案,安裝MySQL-devel-version.rpm,既可在/usr/include/mysql中找到
配置成功後既可make和make install了。
若出現:configure: error: Try adding --with-zlib-dir=<DIR>. 錯誤 則在配置到最後添加--with-zlib即可
若出現:mysql configure failed 錯誤,則將--with-mysql 修改為 --with-mysql-dir

添加db2擴充:

--with-IBM_DB2=/home/db2inst2/sqllib/include

或者可以直接使用pear命令安裝擴充,pear在php的安裝目錄下的bin檔案夾下:

pecl install ibm_db2 根據提示輸入db2安裝目錄,如:/opt/ibm/db2/V10.1


補充:
在安裝完php後,若想附加其他擴充,如:mcrypt,在解壓出來到php源碼檔案夾下ext中集中到大部分到向外延展群組件,這裡進入ext/mcrypt目錄中執行以下命令:
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
安裝完以後,修改php.ini檔案,將mcrypt擴充添加進去:extension=mcrypt.so
6、修改apache設定檔
在apache設定檔httpd.conf中添加
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
DirectoryIndex 後附加上index.php
7、將php安裝目錄中的php.ini-development複製到配置php檔案時所指定的目錄中,即:with-config-file-path=/usr/local/php5所指定的/usr/local/php5目錄中,並更名為php.ini

聯繫我們

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