Skip to content

Instantly share code, notes, and snippets.

@jmfayard
Last active December 26, 2015 15:19
Show Gist options
  • Save jmfayard/7172230 to your computer and use it in GitHub Desktop.
Save jmfayard/7172230 to your computer and use it in GitHub Desktop.
Here is my /etc/nginx/nginx.conf on a self hosted Debian server I want to be able to use nginx+php5-fpm Even a simple php script doesn't work I want to use dokuwiki and dotclear once it works
# Sources that didn't help
# http://serverfault.com/questions/406158/nginx-php5-fpm-file-not-found
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/IfIsEvil
# https://gist.github.com/internaciulo/7172230
# http://kemovitra.blogspot.fr/2013/10/enabling-status-page-for-php5-fpm.html
user www-data;
worker_processes 2;
pid /var/run/nginx.pid;
error_log /var/log/nginx/error.log debug;
events {
worker_connections 768;
# multi_accept on;
}
# Keeps the logs free of messages about not being able to bind().
#daemon off;
events {
worker_connections 1024;
}
http {
# rewrite_log on;
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
# tcp_nopush on;
keepalive_timeout 3;
# tcp_nodelay on;
# gzip on;
#php max upload limit cannot be larger than this
client_max_body_size 13m;
index index.php index.html index.htm;
# Upstream to abstract backend connection(s) for PHP.
upstream php {
#this should match value of "listen" directive in php-fpm pool
server unix:/tmp/php-fpm.sock;
# server 127.0.0.1:9000;
}
include sites-enabled/*;
## Per Site configuration
# Redirect everything to the main site. We use a separate server statement and NOT an if statement - see http://wiki.nginx.org/IfIsEvil
server {
server_name _;
rewrite ^ $scheme://articles.eloge-de-la-folie.fr$request_uri redirect;
}
# Per-site configuration
## Le blog fièrement parait-il propulsé par Wordpress
## include sites-available/wordpress.eloge-de-la-folie.fr;
## Wiki eloge de la folie
server{
server_name wiki.eloge-de-la-folie.fr ;
root /srv/data1/wiki.eloge-de-la-folie.fr ; # avant : /var/www
listen 80;
listen 443 ssl;
location / {
index index.html index.php doku.php;
try_files $uri $uri/ @dokuwiki;
}
location @dokuwiki {
rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
rewrite ^/(.*) /doku.php?id=$1 last;
}
location ~ ^/(data|conf|bin|inc)/ { # secure wiki.eloge-de-la-folie.fr
deny all;
}
location ~ ^/.*\.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $uri; #necessary for URL rewrite
}
# serve static files
location ~ ^/lib/ {
expires 30d;
}
}
## Internet Libre
server {
server_name internet-libere.eloge-de-la-folie.fr ;
location / {
proxy_pass https://docs.google.com/document/d/1Qp77913Ow-I7np2R7pcBlCVreBLt10hBCdAGTXITK34/edit?usp=sharing ;
}
}
server {
server_name il.eloge-de-la-folie.fr ;
location / {
proxy_pass https://docs.google.com/document/d/1Qp77913Ow-I7np2R7pcBlCVreBLt10hBCdAGTXITK34/edit?usp=sharing ;
}
}
# tester rapidos un script php
server {
server_name test.eloge-de-la-folie.fr;
root /srv/data1/test;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#include /etc/nginx/fcgiwrap.conf;
}
# Articles
server {
server_name articles.eloge-de-la-folie.fr;
root /srv/data1/articles.eloge-de-la-folie.fr ; # avant : /var/www
# include global/restrictions.conf;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
# end of the main block
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment