PHP安装扩展

  • 安装libevent

    成都创新互联专注于乡宁网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供乡宁营销型网站建设,乡宁网站制作、乡宁网页设计、乡宁网站官网定制、重庆小程序开发服务,打造乡宁网络公司原创品牌,更为您提供乡宁网站排名全网营销落地服务。

#tar –zxvf libevent-1.4.12-stable.tar.gz

#cd libevent-1.4.12

#./configure--prefix=/usr/local/servers/libevent

#make&& make install

  • 安装memcache

先安装libevent

#tar –zxvflibevent-1.4.12-stable.tar.gz

#cdlibevent-1.4.12-stable

#./configure--prefix=/usr/local/servers/libevent

#make

#makeinstall

 

然后安装memcached,同时需要安装中指定libevent的安装位置

#tar -zxvf memcached-1.2.6.tar.gz

#cd memcached-1.2.6

#./configure--prefix=/usr/local/servers/memcached--with-libevent=/usr/local/servers/libevent

#make

#make install
#usr/local/servers/memcached/bin/memcached -d -m 128 -l localhost -p 11211 -uroot(启动memcached)

 

然后安装memcache

#tar -zxvf memcache-3.0.8.tgz

#cd memcache-3.0.8

#/usr/local/php5/bin/phpize
#./configure -enable-memcache=/usr/local/servers/memcached--with-php-config=/usr/local/php5/bin/php-config

#make

#make install

#ll /usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/  

安装完成后也有类似memcache的提示
在/usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/ 路径下会出现memcached.so
编辑 php.ini添加如下
extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/memcache.so

extension=memcache.so


重启php-fpm查看php是否支持了memcached



  • php-fpm的启动参数

复制代码代码如下:


测试php-fpm配置
#/usr/local/php5/sbin/php-fpm -t
#/usr/local/php5/sbin/php5-fpm -c /usr/local/php5/etc/php.ini -y /usr/local/php5/etc/php5-fpm.conf-t
(指定路径)
启动php-fpm
#/usr/local/php5/sbin/php-fpm

/usr/local/php5/sbin/php5-fpm -c /usr/local/php5/etc/php.ini -y /usr/local/php5/etc/php-fpm.conf


更改目录文件存放在

#vim /etc//rc.d/init.d/php-fpm

prefix=/usr/local/php5

  • PHP5.0以上版本自带memcache扩展

先把之前的php.ini配置文件备份一下

#cp php.ini php.ini.bak

 

重新./configure

 

#./configure --prefix=/usr/local/php5--with-config-file-path=/usr/local/php5/etc --with-MySQL=/usr/local/mysql--with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-zlib--enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop--enable-sysvsem --enable-inline-optimization --with-curlwrappers--enable-mbregex --enable-fpm --enable-mbstring --enable-ftp--enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets--with-xmlrpc --enable-zip --enable-soap --with-pear --with-gettext--enable-session --with-mcrypt --with-curl --enable-pod --with-pdo-mysql--with-pdo-mysql=mysqlnd --without-pod-sqlite

这时会报错:

make: ***[sapi/cli/PHP] Error 1

解决;

Vim Makefile

在EXTRA_LIBS = -lcrypt-lcrypt -lrt -lmysqlclient_r -lgd -lfreetype -lpng -lz -ljpeg -lz -lresolv -lm -ldl-lnsl -lxml2 -lz -lm -lxml2-lz -lm -lmysqlclient_r -lz -lcrypt -lnsl -lm -lxml2-lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm–lcrypt

在最后加上-liconv

#make

#make install

 

 

#cd /usr/local/php5/bin

#./pecl install memcache

重新启动nginx php-fpm

进去phpinfo进去查看

  • 或者用(用php自带扩展安装)

#/usr/local/php5/bin/php –m

出现如下扩展

# /usr/local/php5/bin/php -m

PHP Warning:  Module 'memcache' already loaded in Unknownon line 0

[PHP Modules]

bcmath

Core

ctype

curl

date

dom

ereg

fileinfo

filter

ftp

gd

gettext

hash

iconv

json

libxml

mbstring

mcrypt

memcache

mysql

openssl

pcntl

pcre

PDO

pdo_sqlite

Phar

posix

Reflection

session

shmop

SimpleXML

soap

sockets

SPL

sqlite3

standard

sysvsem

tokenizer

xml

xmlreader

xmlrpc

xmlwriter

zip

zlib

 

[Zend Modules]

  • 安装PDO_mysql

#tar –zxvfPDO_MYSQL-1.0.2.tgz

#cdPDO_MYSQL-1.0.2

#/usr/local/php5/bin/phpize

#./configure--with-php-config=/usr/local/php5/bin/php-config-with-pdo-mysql=/usr/local/mysql/

在make之前还要做一个mysql的header文件的软连接。因为mysql安装的时候指定了目录,不做软连接的话,还是找不到header文件

#ln -s/usr/local/mysql/include/* /usr/local/include/

#make

#makeinstall

#ll/usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/

会有一个pdo_mysql.so

#vim/etc/php.ini

添加

extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/pdo_mysql.so

extension=pdo_mysql.so

 

可以通过

#/usr/local/php5/bin/php -m

PHPWarning:  Module 'memcache' alreadyloaded in Unknown on line 0

PHPWarning:  Module 'pdo_mysql' alreadyloaded in Unknown on line 0

[PHPModules]

bcmath

Core

ctype

curl

date

dom

ereg

fileinfo

filter

ftp

gd

gettext

hash

iconv

json

libxml

mbstring

mcrypt

memcache

mysql

openssl

pcntl

pcre

PDO

pdo_mysql

pdo_sqlite

Phar

posix

Reflection

session

shmop

SimpleXML

soap

sockets

SPL

sqlite3

standard

sysvsem

tokenizer

xml

xmlreader

xmlrpc

xmlwriter

zip

zlib

 

[ZendModules]

 

重启nginx 跟php-fpm

  • Php增加mysqli扩展

php安装包里就自带,找到你php运行的版本,我是php-5.5.12,具体方法如下:

 

#cd /php-5.5.12/ext

注(/ext)里面有如下扩展:

ll

total328

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:38 bcmath

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 bz2

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 calendar

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 com_dotnet

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:38 ctype

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:38 curl

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:36 date

drwxr-xr-x  6 1001 1001 4096 Apr 29  2014 dba

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:38 dom

drwxr-xr-x  4 1001 1001 4096 Apr 29  2014 enchant

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:37 ereg

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 exif

-rwxr-xr-x  1 1001 1001 8165 Apr 29  2014 ext_skel

-rw-r--r--  1 1001 1001 1524 Apr 29  2014ext_skel_win32.php

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:38 fileinfo

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:39 filter

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:39 ftp

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:39 gd

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:39 gettext

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 gmp

drwxr-xr-x  4 1001 1001 4096 Jun  5 20:12 hash

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:39 iconv

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 imap

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 interbase

drwxr-xr-x20 1001 1001  4096 Apr 29  2014 intl

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:39 json

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 ldap

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:37 libxml

drwxr-xr-x  7 1001 1001 4096 Jun  5 13:40 mbstring

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:40 mcrypt

drwxr-xr-x  2 1001 1001 4096 Apr 29  2014 mssql

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:40 mysql

drwxr-xr-x  8 1001 1001 4096 Jun  6 15:54 mysqli

drwxr-xr-x  3 1001 1001 4096 Jun  5 19:08 mysqlnd

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 oci8

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 odbc

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:36 opcache

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:37 openssl

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:40 pcntl

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:37 pcre

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:40 pdo

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 pdo_dblib

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 pdo_firebird

drwxr-xr-x  4 1001 1001 4096 Jun  5 19:08 pdo_mysql

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 pdo_oci

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 pdo_odbc

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 pdo_pgsql

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:40 pdo_sqlite

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 pgsql

drwxr-xr-x  5 1001 1001 4096 Jun  5 21:05 phar

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:40 posix

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 pspell

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 readline

drwxr-xr-x  2 1001 1001 4096 Apr 29  2014 recode

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:40 reflection

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:40 session

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:40 shmop

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:40 simplexml

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 skeleton

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 snmp

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:41 soap

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:41 sockets

drwxr-xr-x  6 1001 1001 4096 Jun  5 13:41 spl

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:37 sqlite3

drwxr-xr-x  5 1001 1001 12288 Jun  5 21:04 standard

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 sybase_ct

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 sysvmsg

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:42 sysvsem

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 sysvshm

drwxr-xr-x  4 1001 1001 4096 Apr 29  2014 tidy

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:42 tokenizer

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 wddx

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:42 xml

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:42 xmlreader

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:42 xmlrpc

drwxr-xr-x  5 1001 1001 4096 Jun  5 13:42 xmlwriter

drwxr-xr-x  3 1001 1001 4096 Apr 29  2014 xsl

drwxr-xr-x  6 1001 1001 4096 Jun  5 13:42 zip

drwxr-xr-x  4 1001 1001 4096 Jun  5 13:38 zlib

#cdphp-5.5.12

#cdext/

#cdmysqli/

#/usr/local/php5/bin/phpize

#./configure-with-php-config=/usr/local/php5/bin/php-config-with-mysqli=/usr/local/mysql/bin/mysql_config

#make

#makeinstall

#ll/usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/

有mysqli.so就表示安装了

#vim/etc/php.ini

添加

#extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/mysqli.so

#extension=mysqli.so

 

重启nginx 跟php-fpm



文章标题:PHP安装扩展
文章源于:http://scyanting.com/article/gogdge.html