centos下nginx+postgresql+php+memcached+apc安裝與配置

來源:互聯網
上載者:User


centos下nginx+postgresql+php+memcached+apc安裝與配置 具體安裝步驟如下: 具體安裝軟體包:  www.2cto.com  01nginx1.0.1302 03wget   http://nginx.org/download/nginx-1.0.13.tar.gz04 05postgresql9.1.206 07wget   http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.gz08 09php5.3.1010 11wget   http://cn2.php.net/get/php-5.3.10.tar.gz/from/ar.php.net/mirror12 13memcache 1.4.1314 15wget   http://code.google.com/p/memcached/downloads/detail?name=memcached-1.4.13.tar.gz&can=2&q=16 17memcached php外掛程式 memcache1.518 19wget   http://pecl.php.net/get/memcache-1.5.tgz20 21apc php外掛程式 apc3.1.922 23wget   http://pecl.php.net/get/APC-3.1.9.tgz1.升級系統包 yum update  關閉selinux 2.nginx安裝: 安裝pcreyum install pcre*  解壓編譯: 1tar –zxvf nginx-1.0.13.tar.gz2 3cd nginx-1.0.134 5./configure --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-pcre6  www.2cto.com   7make && make install01yum install jpeg*02 03yum install libjpeg*04 05yum install libpng*06 07yum install iconv*08 09yum install libiconv*10 11yum install freetype*12 13yum install gd*更改設定檔: vi /usr/local/nginx/conf/nginx.conf 去掉下面一段的注釋:  www.2cto.com  01location ~ \.php$ {02 03    root           html;04 05    fastcgi_pass   127.0.0.1:9000;06 07    fastcgi_index  index.php;08 09    fastcgi_param SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;10 11    include        fastcgi_params;12 13}45行添加index.php 做好這兩個操作後啟動nginx /usr/local/nginx/sbin/nginx 3.postgresql安裝 安裝readline yum install readline* 解壓編譯: 1tar –zxvf postgresql-9.1.2.tar.gz2 3cd postgresql-9.1.24 5./configure --prefix=/usr/local/postgresql6   www.2cto.com  7make && make installpostgresql配置: 01useradd postgre02 03mkdir /home/postgre/data04 05chown -R postgre:postgre/usr/local/postgresql/06 07chown -R postgre:postgre /home/postgre08 09su postgre10/usr/local/postgresql/bin/initdb --encoding=utf8 -D /home/postgre/data4.php安裝 安裝所需軟體包  www.2cto.com  01yum install jpeg*02 03yum install libjpeg*04 05yum install libpng*06 07yum install iconv*08 09yum install libiconv*10 11yum install freetype*12 13yum install gd* 解壓編譯 01tar -zxvf php-5.3.10.tar.gz02 03cd php-5.3.1004 05./configure --prefix=/usr/local/php--with-pgsql=/usr/local/postgresql --with-06 07gd=/usr --with-jpeg-dir=/usr--with-png-dir=/usr --with-zlib --enable-mb08 09string --with-freetype-dir --with-iconv--enable-fpm10 11make && make install複製php.ini  www.2cto.com  1cp php.ini-production /usr/local/php/lib/php.ini2 3cd /usr/local/php/etc/4 5mv php-fpm.conf.default php-fpm.confvim php-fpm.conf 這個配置一般預設就可以啟動 啟動php-fpm /usr/local/php/sbin/php-fpm 5.memcached安裝 安裝所需要的軟體包: yum install libevent* 解壓編譯: 1tar -zxvf memcached-1.4.13.tar.gz2 3cd memcached-1.4.134 5 ./configure --prefix=/usr/local/memcached6 7make && make install6.memcachedphp外掛程式安裝 安裝所需要的軟體包 yum install autoconf 解壓編譯  www.2cto.com  1tar -zxvf memcache-1.5.tgz2 3cd memcache-1.54 5/usr/local/php/bin/phpize6 7./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  www.2cto.com  啟動說明: -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外掛程式的安裝 解壓編譯安裝  1tar -zxvf APC-3.1.9.tgz2 3cd APC-3.1.94 5/usr/local/php/bin/phpize6 7./configure --enable-apc --enable-apc-mmap--with-php-config=/usr/local/php/bin/php-config8 9make && make install配置php.ini  www.2cto.com  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 = 0 apc.write_lock = On 檢測是否安裝成功 /usr/local/php/bin/php -m |grep apc 裝完後 reboot 用phpinfo查看是否都已經載入 8.開機自動啟動  www.2cto.com  1<b>echo"/usr/local/nginx/sbin/nginx" >>/etc/rc.local2 3echo "/usr/local/php/sbin/php-fpm" >>/etc/rc.local4 5echo"/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.測試指令碼  www.2cto.com  Phpinfo 1<?php2 3phpinfo();4 5?>memacache  01<?php02 03$mem = new Memcache;04 05$mem->connect("192.168.10.99",11211);06 07$mem->set('key', 'This is a test!', 0,60);08 09$val = $mem->get('key');10 11echo $val;12 13?>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.