Monday, August 23, 2010

[PHP+FPM+NGINX] Installtion/Compilation/Confiuration.

Its  Installtion/Compilation/Confiuration of PHP+FPM+NGINX.

Please Follow The Steps One By One, Its Working Configration Tested By Me :0). IF The Any Issue Please Contact Me.

wget http://museum.php.net/php5/php-5.2.8.tar.gz
tar -xvf php-5.2.8.tar.gz
cd php-5.2.8
=========================================
./configure  --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring  --with-pgsql --with-curl --disable-debug --enable-pic  --disable-rpath --enable-inline-optimization --with-bz2 --with-xml --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable-memcache --enable-zip --with-pcre-regex --with-curl  --with-curlwrappers --with-ncurses --with-openssl --with-openssl-dir=/usr --with-pdo-mysql=/usr --cache-file=./config.cache' '--with-pcre-regex=/usr --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-gdbm --with-gettext --without-gmp --without-kerberos --enable-mbstring --with-mcrypt --with-mhash --enable-sockets --with-openssl --with-openssl-dir=/usr --with-gd=/usr --with-db4
=========================================
vi /etc/init.d/php-fastcgi

#!/bin/bash
BIND=127.0.0.1:9000
USER=root
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=1000

#PHP_CGI=/usr/bin/php-cgi
PHP_CGI=/usr/local/bin/php-cgi

PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0

start() {
      echo -n "Starting PHP FastCGI: "
      start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}
stop() {
      echo -n "Stopping PHP FastCGI: "
      killall -q -w -u $USER $PHP_CGI
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}

case "$1" in
    start)
      start
  ;;
    stop)
      stop
  ;;
    restart)
      stop
      start
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL

=============================================
vi /etc/nginx/servers/magento.conf

server {
    listen 80;
    server_name domain.com;

        root /home/magento/;

    location / {
        index index.html index.php; ## Allow a static html file to be shown first
      #  try_files $uri $uri/    @handler; ## If missing pass the URI to Magento's front handler
        expires                                 max; ## Assume all files are cachable
        error_page                              404 = @handler;
                log_not_found                   off;
    }

    location ~ /(.*)/index\.php$ { ## strip index.php from product urls
        if (!-e $request_filename) { rewrite ^(.*)/index\.php$ $1/ permanent; }
        }

    location /minify/ { ## Needed for Fooman Speedster
        rewrite ^/minify/([0-9]+)(/.*\.(js|css))$
/lib/minify/m.php?f=$2&d=$1 last;
    }

    ## These locations would be hidden by .htaccess normally
    location /app/                { deny all; }
    location /includes/           { deny all; }
    location /lib/                { deny all; }
    location /lib/minify/         { allow all; }  ## Deny is applied after rewrites so must specifically allow minify
    location /media/downloadable/ { deny all; }
    location /pkginfo/            { deny all; }
    location /report/config.xml   { deny all; }
    location /var/                { deny all; }

    location /var/export/ { ## Allow admins only to view export folder
        auth_basic           "Restricted"; ## Message shown in login window
        auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
    }

    location  /. { ## Disable .htaccess and other hidden files
        return 404;
    }

    location @handler { ## Magento uses a common front handler
        rewrite / /index.php;
    }

    location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*\.php)/ $1 last;
    }

    location ~ \.php$ { ## Execute PHP scripts
        expires                 off; ## Do not cache dynamic content
      #   fastcgi_param   HTTPS $fastcgi_http;
        fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO $fastcgi_script_name;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param  MAGE_RUN_CODE  base;
        fastcgi_param  MAGE_RUN_TYPE  website;
        include                 fastcgi_params; ## See /etc/nginx/fastcgi_params
    }

}

====================================