扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
安装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/ 路径下会出现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
先把之前的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]
#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)里面有如下扩展:
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
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流