ecshop搭建nginx+php+mysql+fastcgi环境

2012-02-13 17:14 来源:www.chinab4c.com 作者:ecshop专家

    ecshop搭建nginx+php+mysql+fastcgi环境,我们将ecshop的环境安装在nginx上,这样不但可以发挥ecshop最大的性能,同时也能增强ecshop运行是发生的并发量处理。将你的ecshop通过修改,安装在nginx环境上。

   1:首先先删除linux下默认的程序httpd

    yum remove httpd

     yum update

   2:安装mysql

     yum install mysql mysql-server

   3:加载驱动mysql

     chkconfig --levels 235 mysqld on

     /etc/init.d/mysqld start

   4:设置mysql密码

      mysql_secure_installation

   5:获得安装rpm  

     rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

     rpm -Uvh http://centos.alt.ru/repository/centos/5/x86_64/centalt-release-5-3.noarch.rpm

   6:安装nginx

     yum install nginx

    7:启动nginx

    chkconfig --levels 235 nginx on

     /etc/init.d/nginx start

   8:安装php扩展

   yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy

    9:修改php.ini

      vi /etc/php.ini

       修改cgi.fix_pathinfo = 1

     service php-fpm start

    10:启动php-fpm 参数

    chkconfig --levels 235 php-fpm on

    11:配置nignx.conf

     vi /etc/nginx/nginx.conf

   

  1. server {   
  2.         listen       80;   
  3.         server_name  _;   
  4.         #charset koi8-r;   
  5.         #access_log  logs/host.access.log  main;   
  6.         location / {   
  7.             root   /usr/share/nginx/html;   
  8.             index  index.php index.html index.htm;   
  9.         }   
  10.         error_page  404              /404.html;   
  11.         location = /404.html {   
  12.             root   /usr/share/nginx/html;   
  13.         }   
  14.         # redirect server error pages to the static page /50x.html   
  15.         #   
  16.         error_page   500 502 503 504  /50x.html;   
  17.         location = /50x.html {   
  18.             root   /usr/share/nginx/html;   
  19.         }   
  20.         # proxy the PHP scripts to Apache listening on 127.0.0.1:80   
  21.         #   
  22.         #location ~ \.php$ {   
  23.         #    proxy_pass   http://127.0.0.1;   
  24.         #}   
  25.     
  26.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000   
  27.         #   
  28.         location ~ \.php$ {   
  29.             root           /usr/share/nginx/html;   
  30.             fastcgi_pass   127.0.0.1:9000;   
  31.             fastcgi_index  index.php;   
  32.             fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;   
  33.             include        fastcgi_params;   
  34.         }   
  35.         # deny access to .htaccess files, if Apache's document root   
  36.         # concurs with nginx's one   
  37.         #   
  38.         location ~ /\.ht {   
  39.             deny  all;   
  40.         }   
  41.     }   

  12:重起nginx

   /etc/init.d/nginx restart

  /etc/init.d/php-fpm restart

   13:建立测试php

   vi /usr/share/nginx/html/info.php

   14:修改nginx.conf

     在nginx/conf/nginx.conf   找到:
fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  改为:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;