具体安装步骤如下:
具体安装软件包:
nginx1.0.13 wget http://nginx.org/download/nginx-1.0.13.tar.gz postgresql9.1.2 wget http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.gz php5.3.10 wget http://cn2.php.net/get/php-5.3.10.tar.gz/from/ar.php.net/mirror memcache 1.4.13 wget http://code.google.com/p/memcached/downloads/detail?name=memcached-1.4.13.tar.gz&can=2&q= memcached php插件 memcache1.5 wget http://pecl.php.net/get/memcache-1.5.tgz apc php插件 apc3.1.9 wget http://pecl.php.net/get/APC-3.1.9.tgz
1.升级系统包
yum update
关闭selinux
2.nginx安装:
安装pcre
yum install pcre*
解压编译:
tar –zxvf nginx-1.0.13.tar.gz cd nginx-1.0.13 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-iconv-dir --with-freetype-dir --with-jpeg-dir=/usr/local --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-debug --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-force-cgi-redirect --enable-fpm --with-pgsql=/usr/local/pgsql make && make install
yum install jpeg* yum install libjpeg* yum install libpng* yum install iconv* yum install libiconv* yum install freetype* yum install gd*
更改配置文件:
vi /usr/local/nginx/conf/nginx.conf
去掉下面一段的注释:
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; include fastcgi_params; }
45行添加index.php
做好这两个操作后启动nginx /usr/local/nginx/sbin/nginx
3.postgresql安装
安装readline
yum install readline*
解压编译:
tar –zxvf postgresql-9.1.2.tar.gz cd postgresql-9.1.2 ./configure --prefix=/usr/local/postgresql make && make install
postgresql配置:
useradd postgre mkdir /home/postgre/data chown -R postgre:postgre/usr/local/postgresql/ chown -R postgre:postgre /home/postgre su postgre /usr/local/postgresql/bin/initdb --encoding=utf8 -D /home/postgre/data
4.php安装
安装所需软件包
yum install jpeg* yum install libjpeg* yum install libpng* yum install iconv* yum install libiconv* yum install freetype* yum install gd*
解压编译
tar -zxvf php-5.3.10.tar.gz cd php-5.3.10 ./configure --prefix=/usr/local/php--with-pgsql=/usr/local/postgresql --with- gd=/usr --with-jpeg-dir=/usr--with-png-dir=/usr --with-zlib --enable-mb string --with-freetype-dir --with-iconv--enable-fpm make && make install
复制php.ini
cp php.ini-production /usr/local/php/lib/php.ini cd /usr/local/php/etc/ mv php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
这个配置一般默认就可以启动
启动php-fpm
/usr/local/php/sbin/php-fpm
5.memcached安装
安装所需要的软件包:
yum install libevent*
解压编译:
tar -zxvf memcached-1.4.13.tar.gz cd memcached-1.4.13 ./configure --prefix=/usr/local/memcached make && make install
6.memcachedphp插件安装
安装所需要的软件包
yum install autoconf
解压编译
tar -zxvf memcache-1.5.tgz cd memcache-1.5 /usr/local/php/bin/phpize ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
配置memcached与php.ini
/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
vim /usr/local/php/lib/php.ini
查找extension_dir
更改路径为/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
添加
extension=memcache.so
启动memcached:
/usr/local/memcached/bin/memcached -d m 20-u root -l localhost -p 11211
启动说明:
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.200,
-p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid
7.apc插件的安装
解压编译安装
tar -zxvf APC-3.1.9.tgz cd APC-3.1.9 /usr/local/php/bin/phpize ./configure --enable-apc --enable-apc-mmap--with-php-config=/usr/local/php/bin/php-config make && make install
配置php.ini
ls/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
vim /usr/local/php/lib/php.ini
在extension=memcache.so下面添加extension=apc.so以及
apc.enabled = 1
apc.cache_by_default = on
apc.shm_segments = 1
apc.shm_size = 32
apc.ttl = 600
apc.user_ttl = 600
apc.num_files_hint = 0
apc.write_lock = On
检测是否安装成功
/usr/local/php/bin/php -m |grep apc
装完后 reboot
用phpinfo查看是否都已经加载
8.开机自动启动
echo"/usr/local/nginx/sbin/nginx" >>/etc/rc.local echo "/usr/local/php/sbin/php-fpm" >>/etc/rc.local echo"/usr/local/memcached/bin/memcached -d m 20 -u root -l localhost -p11211" >>/etc/rc.local
9.防火墙设置
vim /etc/sysconfig/iptables
开启11211和80端口
10.测试脚本
Phpinfo
<?php phpinfo(); ?>
memacache
<?php $mem = new Memcache; $mem->connect("192.168.10.99",11211); $mem->set('key', 'This is a test!', 0,60); $val = $mem->get('key'); echo $val; ?>