nginx+php-fpm+xcache

線上環境,centos6.3的系統。php

 

1.安裝nginxhtml

wget   http://www.nginx.com.cn/download/nginx-1.3.9.tar.gzmysql

wget  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gzxcachenginx

wget  http://zlib.net/zlib-1.2.8.tar.gzsql

wget http://www.openssl.org/source/openssl-1.0.0j.tar.gzcentos

wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz   圖片緩存模塊api

 

 ./configure --user=www  --group=www   --prefix=/usr/local/nginx  --with-openssl=../openssl-1.0.0j --with-zlib=../zlib-1.2.8 --with-pcre=../pcre-8.30  --with-http_ssl_module  --add-module=../ngx_cache_purge-2.1 --with-http_sub_module --with-http_stub_status_module  --with-http_gzip_static_module緩存

 

make   && make installcurl

 

2.安裝完成以後,就能夠啓動nginx了。socket

/usr/local/nginx/sbin/nginx

 

3.查看nginx有沒有啓動

netstat -napt  | grep  nginx     

 

4.而後經過ip訪問

5.因爲本機上已經有mysql了,這裏就忽略掉

6.咱們直接安裝php了

安裝php以前,咱們得先安裝庫文件.這裏就用yum安裝吧

yum  -y  install   libmcrypt* mhash* libxml2* libpng* freetype* libjpeg* bzip* libcurl* 

 

./configure --prefix=/usr/local/php \
--with-mysql=/usr/local/mysql --with-openssl --enable-fpm \
--enable-sockets --enable-sysvshm  --with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir \
--with-libxml-dir=/usr --enable-xml  --with-mhash --with-mcrypt  --with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl
7.中途編譯的時候出現了configure: error: mcrypt.h not found. Please reinstall libmcrypt.的錯誤信息
若是yum沒法解決的話,就用編譯安裝吧
./configure  && make  && make  install
而後從新配置,編譯,安裝 就行了 
8.爲php提供配置文件
cp php.ini-production /etc/php.ini
9.爲php-fpm提供Sysv init腳本,並將其添加至服務列表
cp sapi/fpm/init.d.php-fpm  /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
10.爲php-fpm提供配置文件
cp /usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
11.編輯php-fpm的配置文件,配置fpm的相關選項爲你所須要的值,並啓用pid文件:
pm.max_children =150
pm.start_servers =8
pm.min_spare_servers =5
pm.max_spare_servers =10
pid = /usr/local/php/var/run/php-fpm.pid
12.啓動php-fpm進程,並使用以下命令來驗正(若是此命令輸出有中幾個php-fpm進程就說明啓動成功了):
service php-fpm restart
ps aux | grep php-fpm

13.編輯/usr/local/nginx/conf/nginx.conf,整合nginx和php,並啓用以下選項:

 location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
 }


        location / {
            root   html;
            index  index.html index.htm  index.php;
        }

 

14.改完這幾處地方就差很少了,重啓下nginx

15.測試下php是否是能正常顯示了

16.接下來開始編譯xcache

wget http://xcache.lighttpd.net/pub/Releases/3.0.3/xcache-3.0.3.tar.gz

 ./configure --enable-xcache --enable-xcache-coverager  --with-php-config=/usr/local/php/bin/php-config

make  && make install

17.編輯php.ini,整合php和xcache

mkdir /etc/php.d

cp xcache.ini /etc/php.d

18.編輯/etc/php.d/xcache.ini,找到extension開頭的行,修改成以下行:

extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache.so

19.從新啓動php-fpm進程

service php-fpm restart

chkconfig php-fpm on

20.從新打開測試頁面,就能夠看到了

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息