Skip to content

Instantly share code, notes, and snippets.

@iflamed
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iflamed/52e07ef4704ce79320e7 to your computer and use it in GitHub Desktop.
Save iflamed/52e07ef4704ce79320e7 to your computer and use it in GitHub Desktop.
one nginx server and multiple app(folder) share one fastcgi
##
# also you can seprate the php's fastcgi configration,then integrate to the test.example.com.conf
##
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
## With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
server{
server_name test.example.com;
access_log /var/log/nginx/test.example.com_access.log;
error_log /var/log/nginx/test.example.com_error.log;
index index.php;
root /home/pi/project/test;
location / {
##
# it's compatible with thinkphp pathinfo mode
##
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location /app {
alias /home/pi/project/test/laravel/public/;
##
# the app path at the location and the rewrite below must be the same
##
if (!-f $request_filename){
rewrite ^(.*)$ /app/index.php?$query_string;
}
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
##
# the default php fastcgi,it's compatible with thinkphp and laravel those i have test.
##
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
## With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment