Skip to content

Instantly share code, notes, and snippets.

@tidus2102
Last active January 22, 2017 18:48
Show Gist options
  • Save tidus2102/192ebeef1c08f6b63773cb220df0ef0b to your computer and use it in GitHub Desktop.
Save tidus2102/192ebeef1c08f6b63773cb220df0ef0b to your computer and use it in GitHub Desktop.
PHP-FPM NGINX Config
#/etc/nginx/conf.d/default.conf
server {
server_name domain.com;
rewrite ^(.*) http://www.domain.com$1 permanent;
}
server {
#listen 000.000.000.000:80;
server_name www.domain.com;
root /var/www/www.domain.com;
index index.php index.html index.htm;
access_log off;
# access_log /var/www/www.domain.com/logs/access.log;
error_log off;
# error_log /var/www/www.domain.com/logs/error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_pass php-fpm; #Use php-fpm upstream
fastcgi_index index.php;
#fastcgi_buffer_size 32k;
#fastcgi_buffers 8 16k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#/etc/nginx/conf.d/php-fpm.conf
upstream php-fpm {
#server 127.0.0.1:9000;
server unix:/run/php-fpm/www.sock;
}
#/etc/php.ini
#Find & change content as below
cgi.fix_pathinfo = 0
short_open_tag = On
date.timezone = UTC
#/etc/php-fpm.d/www.conf
#Find & change content as below
;listen = 127.0.0.1:9000
listen = /run/php-fpm/www.sock
listen.acl_users = nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment