Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amolkhanorkar/10015965 to your computer and use it in GitHub Desktop.
Save amolkhanorkar/10015965 to your computer and use it in GitHub Desktop.
Setup PHP different framework on Nginx
To install PHP-FPM with nginx please follow the below link
https://sites.google.com/a/weboniselab.com/webonisers/devops/nginx-setup
Setup Cake PHP with nginx
1. Download Cake PHP from : https://github.com/cakephp/cakephp/zipball/2.4.6
2. Extract it at /var/www/<app-name>
3. Create Nginx conf file
server {
listen 80;
server_name example.com;
# root directive should be global
root /var/www/<app-name>/app/webroot/;
index index.php;
access_log /var/log/nginx/log/access.log;
error_log /var/log/nginx/error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Setup Wordpress with Nginx
1. Download WordPress - http://Wordpress.org/latest.tar.gz.
2. Untar it at /var/www/www.example1.com/ : tar -xvzf latest.tar.gz
3. Add the following configuration in Nginx.conf within the http directive:
server {
listen 80;
server_name www.example.com;
root /var/www/www.example.com;
index index.php index.html;
try_files $uri $uri/ /index.php?q=$uri;
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
expires max;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass
127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$
fastcgi_script_name;
include fastcgi_params;
}
}
Setup Drupal with Nginx
1. Download Drupal: http://ftp.Drupal.org/files/projects/Drupal-6.19.tar.gz
2. Untar Drupal to /var/www/www.example1.com/.
3. Add the following to your Nginx.conf:
server {
listen 80;
server_name www.example1.com;
root /var/www/www.example1.com;
index index.php index.html index.htm
try_files $uri $uri/ /index.php?q=$uri;
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
expires max;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$
fastcgi_script_name;
include fastcgi_params;
}
}
Setup Magento with Nginx
1.Download Magento: http://www.magentocommerce.com/getmagento/1.4.1.1/magento-1.4.1.1.zip
2. Untar Magento to /var/www/www.example1.com/.
3. Add this to your Nginx.conf:
server {
listen 80;
server_name www.example1.com;
root /var/www/www.example1.com;
location / {
index index.html index.php;
if (!-e $request_filename) {
rewrite / /index.php;
}
}
location ~ \.php/ {
rewrite ^(.*\.php)/ $1 last;
}
location ~ \.php$ {
include
fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
Setup Yii with Nginx
1.Download Yii from http://www.yiiframework.com/download/
2. Create index.php & do the required changes
3. Create Nginx conf file
server {
access_log /var/log/nginx/access.log;
server_name www.example.com;
#Document root of Application
root /var/www/www.example.com;
set $yii_bootstrap "index.php";
charset utf-8;
location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
#avoid processing of calls to unexisting static files by yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(.*)$;
#let yii catch the calls to unexising PHP files
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}
# prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment