求助,如何在 win 下使用 redis 或 memcached 加速 postgresql
1个回答
2017-06-25
展开全部
centos下nginx+postgresql+php+memcached+apc安装与配置具体安装步骤如下:具体安装软件包: 01nginx1/download/nginx-1/pub/source/v9/get/php-5/mirror1213memcache 1/p/memcached/downloads/detail?name=memcached-1/get/memcache-1/get/APC-3.1.9.tgz1.升级系统包yum update 关闭selinux2.nginx安装:安装pcreyum install pcre*解压编译:1tar –zxvf nginx-1.0.13.tar.gz23cd nginx-1.0.1345./configure --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-pcre6 7make && make install01yum install jpeg*0203yum install libjpeg*0405yum install libpng*0607yum install iconv*0809yum install libiconv*1011yum install freetype*1213yum install gd*更改配置文件:vi /usr/local/nginx/conf/nginx.conf去掉下面一段的注释: 01location ~ /.php$ {0203 root html;0405 fastcgi_pass 127.0.0.1:9000;0607 fastcgi_index index.php;0809 fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;1011 include fastcgi_params;1213}45行添加index.php做好这两个操作后启动nginx /usr/local/nginx/sbin/nginx3.postgresql安装安装readlineyum install readline*解压编译:1tar –zxvf postgresql-9.1.2.tar.gz23cd postgresql-9.1.245./configure --prefix=/usr/local/postgresql6 7make && make installpostgresql配置:01useradd postgre0203mkdir /home/postgre/data0405chown -R postgre:postgre/usr/local/postgresql/0607chown -R postgre:postgre /home/postgre0809su postgre10/usr/local/postgresql/bin/initdb --encoding=utf8 -D /home/postgre/data4.php安装安装所需软件包 01yum install jpeg*0203yum install libjpeg*0405yum install libpng*0607yum install iconv*0809yum install libiconv*1011yum install freetype*1213yum install gd*解压编译01tar -zxvf php-5.3.10.tar.gz0203cd php-5.3.100405./configure --prefix=/usr/local/php--with-pgsql=/usr/local/postgresql --with-0607gd=/usr --with-jpeg-dir=/usr--with-png-dir=/usr --with-zlib --enable-mb0809string --with-freetype-dir --with-iconv--enable-fpm1011make && make install复制php.ini 1cp php.ini-production /usr/local/php/lib/php.ini23cd /usr/local/php/etc/45mv php-fpm.conf.default php-fpm.confvim php-fpm.conf这个配置一般默认就可以启动启动php-fpm/usr/local/php/sbin/php-fpm5.memcached安装安装所需要的软件包:yum install libevent*解压编译:1tar -zxvf memcached-1.4.13.tar.gz23cd memcached-1.4.1345./configure --prefix=/usr/local/memcached67make && make install6.memcachedphp插件安装安装所需要的软件包yum install autoconf解压编译 1tar -zxvf memcache-1.5.tgz23cd memcache-1.545/usr/local/php/bin/phpize67./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.pid7.apc插件的安装解压编译安装1tar -zxvf APC-3.1.9.tgz23cd APC-3.1.945/usr/local/php/bin/phpize67./configure --enable-apc --enable-apc-mmap--with-php-config=/usr/local/php/bin/php-config89make && 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 = 1apc.cache_by_default = onapc.shm_segments = 1apc.shm_size = 32apc.ttl = 600apc.user_ttl = 600apc.num_files_hint = 0apc.write_lock = On检测是否安装成功/usr/local/php/bin/php -m grep apc装完后 reboot用phpinfo查看是否都已经加载8.开机自动启动 1<b>echo/usr/local/nginx/sbin/nginx >>/etc/rc.local23echo /usr/local/php/sbin/php-fpm >>/etc/rc.local45echo/usr/local/memcached/bin/memcached -d m 20 -u root -l localhost -p11211 >>/etc/rc.local</b>9.防火墙设置vim /etc/sysconfig/iptables开启11211和80端口10.测试脚本 Phpinfo1<?php23phpinfo();45?>memacache01<?php0203$mem = new Memcache;0405$mem->connect(192.168.10.99,11211);0607$mem->set('key', 'This is a test!', 0,60);0809$val = $mem->get('key');1011echo $val;1213?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询