yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel
centos5.6下 MySQL 5.5.23 CMake 安装笔记
php-5.3.8-fpm安装记录
cd /usr/local/src/
tar jxvf php-5.3.8.tar.bz2
cd php-5.3.8
./configure --prefix=/usr/local/php-5.3.8 --enable-fpm --with-libxml-dir --with-openssl --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --with-curlwrappers --with-db4 --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-intl --with-icu-dir=/usr/local/icu --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --with-mysql --with-mysql-sock --with-mysqli --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-libexpat-dir --with-iconv-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear
make ZEND_EXTRA_LIBS='-liconv'
make test
make install
cp usr/local/src/php-5.3.8/php.ini /usr/local/php-5.3.8/etc
cd /usr/local/php-5.3.8
cp php-fpm.conf.default php-fpm.conf <========复制一份并重命名
/usr/local/php-5.3.8/sbin/php-fpm ========启动php-fpm
启动错误解决:
ALERT: [pool www] pm.min_spare_servers(0) must be a positive value
编辑php-fpm.conf找到pm.min_spare_servers 去除;号,注意非注释内容pm.min_spare_servers
ALERT: [pool www] pm.max_spare_servers(0) must be a positive value
编辑php-fpm.conf找到pm.max_spare_servers 去除;号,同样非注释内容pm.max_spare_servers
WARNING: [pool www] pm.start_servers is not set. It's been set to 20.
编辑php-fpm.conf找到pm.start_servers 去除;号,同样非注释内容pm.start_servers
netstat -alnp|grep php
查看进程,有N多进程
==========================
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
#tar -zxvf libiconv-1.13.1.tar.gz
#cd libiconv-1.13.1
# ./configure --prefix=/usr/local/libiconv
# make
# make install
再检查php,指定 iconv的位置 --with-iconv=/usr/local/libiconv
tar jxvf php-5.3.8.tar.bz2
cd php-5.3.8
//del --enable-intl --with-icu-dir=/usr/local/icu
./configure --prefix=/usr/local/php-5.3.8 --enable-fpm --with-libxml-dir --with-openssl --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --with-curlwrappers --with-db4 --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --with-mysql=/usr/local/mysql --with-mysql-sock --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-libexpat-dir --with-iconv-dir==/usr/local/libiconv --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear
finaly show
Thank you for using PHP.
make
make install
last show:
ln -s -f /usr/local/php-5.3.8/bin/phar.phar /usr/local/php-5.3.8/bin/phar
Installing PDO headers: /usr/local/php-5.3.8/include/php/ext/pdo/
cp php-fpm.conf.default php-fpm.conf <========复制一份并重命名
/usr/local/php-5.3.8/sbin/php-fpm ========启动php-fpm
FPM 配置文件为php-fpm.conf
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
去掉分号
ln -s /usr/local/php-5.3.8/sbin/php-fpm /bin/php-fpm
cp php.ini-producsion /usr/local/php-5.3.8/etc/php.ini
ngnix1.0.5安装记录
tar zxvf nginx-1.0.5.tar.gz
cd nginx-1.0.5
useradd www #添加www nginx运行账户
usermod -s /sbin/nologin -g www www #将www加入www组并禁止www登录shell
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --without-http_rewrite_module --with-http_ssl_module --with-pcre && make && make install
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf #启动nginx,nginx启动成功。
报错 error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
Fixed:ln -s /usr/local/lib/libpcre.so.1 /lib
/usr/local/nginx/sbin/nginx -s reload
ifconfig eth0:1 192.168.0.245 broadcast 192.168.0.255 netmask 255.255.255.0 up
route add -host 192.168.0.245 dev eth0:1
扩展memcache
rpm一、源码包准备
服务器端主要是安装memcache服务器端,目前的最新版本是 memcached-v1.4.4 。
下载:http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz
另外,Memcache用到了libevent这个库用于Socket的处理,所以还需要安装libevent,
libevent的最新版本是libevent-1.4.13-stable。(如果你的系统已经安装了libevent,可以不用安装)
官网:http://www.monkey.org/~provos/libevent/
下载:http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
准备Memcached的PHP扩展的源码安装包:
官网:http://pecl.php.net/get/memcache-2.2.5.tgz
Linux指令下载:
wget http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz
wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
wget http://pecl.php.net/get/memcache-2.2.5.tgz
二、安装与配置
1、先安装libevent
tar zxvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure –prefix=/usr
make
make install
2、测试libevent是否安装成功
ls -al /usr/lib | grep libevent
libevent-1.1a.so.1
libevent-1.1a.so.1.0.2
libevent-1.4.so.2
libevent-1.4.so.2.1.3
libevent.a
libevent_core-1.4.so.2
libevent_core-1.4.so.2.1.3
libevent_core.a
libevent_core.la
libevent_core.so
libevent_extra-1.4.so.2
libevent_extra-1.4.so.2.1.3
libevent_extra.a
libevent_extra.la
libevent_extra.so
libevent.la
libevent.so
版本不同,可能文件列表不同。
3、安装memcached,同时需要安装中指定libevent的安装位置
tar zxvf memcached-1.4.4.tar.gz
cd memcached-1.4.4
./configure –with-libevent=/usr
make && make install
安装完成后会把memcached 自动放到 /usr/local/bin/memcached
4、测试是否成功安装memcached
ls -al /usr/local/bin/mem*
-rwxr-xr-x 1 root root 201869 12-14 21:44 /usr/local/bin/memcached
5、安装Memcache的PHP扩展
①安装PHP的memcache扩展
tar vxzf memcache-2.2.5.tgz
cd memcache-2.2.5
/usr/local/php-5.3.8/bin/phpize
./configure -enable-memcache -with-php-config=/usr/local/php-5.3.8/bin/php-config -with-zlib-dir
make
make install
②上述安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php-5.3.8/lib/php/extensions/no-debug-non-zts-20090626/
③把php.ini中的extension_dir = “./”修改为
extension_dir = “/usr/local/php-5.3.8/lib/php/extensions/no-debug-non-zts-20090626/”
④添加一行来载入memcache扩展
三、memcached的基本设置
1.启动Memcache的服务器端:
memcached -d -m 10 -u root -l 127.0.0.1 -p 11211 -c 256 -P /tmp/memcached.pid
参数说明:
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址202.207.177.177,
-p是设置Memcache监听的端口,我这里设置了11211,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,
2.如果要结束Memcache进程,执行:
kill `cat /tmp/memcached.pid`
也可以启动多个守护进程,不过端口不能重复。
3.检查Memcached是否启动
netstat -ant
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LIST
11211端口已经打开,说明Memcached已正常启动。
4.重启CentOS
reboot
四、Memcache环境测试
运行下面的php文件,如果有输出This is a test!,就表示环境搭建成功。开始你的Memcache的征途吧!
<?php
$mem = new Memcache;
$mem->connect("127.0.0.1", 11211);
$mem->set('key','This is a test!', 0, 60);
$val = $mem->get('key');
echo $val;
?>
著名的PHPCMS同样支持Memcached扩展:
<?php
//MemCache服务器配置
//define('MEMCACHE_HOST', 'localhost'); //MemCache服务器主机
//define('MEMCACHE_PORT', 11211); //MemCache服务器端口
//define('MEMCACHE_TIMEOUT', 1); //S,MemCache服务器连接超时
class cache
{
var$memcache;
function__construct()
{
$this->memcache = &newMemcache;
$this->memcache->pconnect(MEMCACHE_HOST, MEMCACHE_PORT, MEMCACHE_TIMEOUT);
}
functioncache()
{
$this->__construct();
}
functionget($name)
{
return$this->memcache->get($name);
}
functionset($name,$value, $ttl= 0)
{
return$this->memcache->set($name,$value, 0, $ttl);
}
functionrm($name)
{
return$this->memcache->delete($name);
}
functionclear()
{
return$this->memcache->flush();
}
}
?>
安装leveldb
http://code.google.com/p/leveldb/source/checkout
git clone https://code.google.com/p/leveldb/
git clone http://code.google.com/p/leveldb/ //work!!
2012-05-01 http://xingqiba.sinaapp.com/?p=172
git clone http://code.google.com/p/leveldb/
cd leveldb
make //编译后在/home/lyc/leveldb/Leveldb路径下会出现一个库文件libleveldb.a,这个可以用在自己的项目中
cd ../
git clone git://github.com/arraypad/php-leveldb.git
cd php-leveldb
/usr/local/php-5.3.8/bin/phpize
./configure --with-leveldb=/usr/local/src/leveldb --with-php-config=/usr/local/php-5.3.8/bin/php-config
make
make install
注意修改php.ini增加extension = leveldb.so并重启php
安装ICE
wget http://www.zeroc.com/download/Ice/3.4/Ice-3.4.2.tar.gz
wget http://www.zeroc.com/download/Ice/3.4/ThirdParty-Sources-3.4.2.tar.gz
tar zxvf ThirdParty-Sources-3.4.2.tar.gz
cd ThirdParty-Sources-3.4.2
#安装Berkeley DB
tar zxvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix/
../dist/configure --prefix=/usr --enable-cxx
make
make install
cd ../../
#安装 bzip2-1.0.6.tar.gz
tar zxvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make
make install
cd ../
#expat-2.0.1.tar.gz
tar zxvf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure
make
make install
cd ../
#安装openssl-0.9.8d.tar.gz
cd ../
tar zxvf openssl-0.9.8r.tar.gz
cd openssl-0.9.8r
./config --prefix=/usr --openssldir=/usr/openssl
make
make install
cd ../
#安装mcpp
tar zxvf mcpp-2.7.2.tar.gz
cd mcpp-2.7.2
patch -p0 < ../mcpp/patch.mcpp.2.7.2
./configure CFLAGS=-fPIC --enable-mcpplib --disable-shared
make
make install
cd ../
#安装Ice
ca /usr/local
tar zxvf Ice-3.4.2.tar.gz //最好解压到安装目录,解压到哪个目录就最好安装到哪个目录下,避免文件缺失
cd Ice-3.4.2/cpp
export LD_LIBRARY_PATH=/usr/local/Ice-3.4.2/lib
==>找到cpp/config/Make.rules.Linux,在最显眼的地方【143行】在最后加上一个 -liconv,再编译
make
make install
cd /usr/local/Ice-3.4.2/php
vim php/config/Make.rules.php
USE_NAMESPACES ?= yes
PHP_HOME ?= /usr/local/php-5.3.8
cd /usr/local/Ice-3.4.2/php
make
make install
cd /opt/Ice-3.4.2/php
如果是在linxu下安装IcePHP的话,则需要在Ice源文件下的php目录下编译源码,然后执行makeinstall安装IcePHP扩展,一般Ice会安装到opt/Ice-3.4.1目录下(这里假设版本号为3.4.1),然后在php.ini中定义:
extension_dir = /opt/Ice-3.4.1/php
extension = IcePHP.so
include_path = /opt/Ice-3.4.1/php
4.安装过程中出现的一些错误,及解决方法:
4.1)错误提示:/usr/lib.ld:Error:cannot find -lmcpp --->解决方法:应该是mcpp之前没有安装成功,将mcpp重新安装成功后就行
4.2)错误提示:fatal error:db_cxx.h:No such file or directory -->解决方法:之前没有把db-4.8.3安装成功,重新安装一遍
4.3)安装Ice完成后,运行例子错误提示:error while loading shared libraries: libIce.so.34: cannot open shared object file: No such file or directory -->解决办法:应该是之前编译Ice某些目录配置不对;使用命令 export LD_LIBRARY_PATH=/opt/Ice-3.4.2/lib重新来导出动态链接库目录即可。(共享库搜索顺序一般是$LDLIBRARY_PATH,/etc/ld.so.cache, /usr/lib, /lib)
4.4)安装Ice后,发现系统不能识别slice2cpp命令。原因及解决办法:应该是安装过程中没有把slice2cpp可执行文件复制到/ur/bin目录下面,或者是链接环境没有设置好;来到/opt/Ice-3.4.2/bin下面将slice2cpp复制到/usr/bin目录下即可。
4.5)libiconv.so.2: cannot open shared object file解决办法:
解决办法如下:
1.在/etc/ld.so.conf中加一行/usr/local/lib,
2.然后运行/sbin/ldconfig,文件解决,没有报错了~~