您好,登錄后才能下訂單哦!
安裝libevent
#tar –zxvf libevent-1.4.12-stable.tar.gz
#cd libevent-1.4.12
#./configure--prefix=/usr/local/servers/libevent
#make&& make install
先安裝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/ 路徑下會出現(xiàn)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的啟動參數(shù)
復(fù)制代碼代碼如下:
測試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
先把之前的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
進(jìn)去phpinfo進(jìn)去查看
或者用(用php自帶擴(kuò)展安裝)
#/usr/local/php5/bin/php –m
出現(xiàn)如下擴(kuò)展
# /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]
#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安裝包里就自帶,找到你php運行的版本,我是php-5.5.12,具體方法如下:
#cd /php-5.5.12/ext
注(/ext)里面有如下擴(kuò)展:
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
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。