Skip to content

Instantly share code, notes, and snippets.

@liverbool
Forked from ZipoKing/symfony2_nginx.conf
Last active August 29, 2015 14:10
Show Gist options
  • Save liverbool/862f7f24e59335d1a112 to your computer and use it in GitHub Desktop.
Save liverbool/862f7f24e59335d1a112 to your computer and use it in GitHub Desktop.
## ------ Check List ------- ##
# set server timezone
sudo dpkg-reconfigure tzdata
(to Asia/Bangkok)
# install php
apt-get update
apt-get install php5-cli
apt-get install php5-curl
apt-get install php5-intl
apt-get install php5-gd
apt-get install php-apc #note http://www.binarytides.com/install-nginx-php-fpm-mariadb-debian/
apt-get install git
# config php-cli
max_execution_time = 0
max_input_time = -1
date.timezone = Asia/Bangkok
# /etc/php5/fpm/php.ini
date.timezone = Asia/Bangkok
expose_php = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
html_errors = On
log_errors = On
max_input_time = 60
output_buffering = 4096
register_argc_argv = Off
request_order = “GP”
upload_max_filesize = 5M
# setup nginx
see above ..
# disable nginx token — /etc/nginx/nginx.conf
server_tokens off
## ------ End Check List ------- ##
server {
listen 80;
server_name XXX;
root /var/www/XXX/web;
error_log /var/log/nginx/XXX.error.log;
access_log /var/log/nginx/XXX.access.log;
# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ /$1 permanent;
# hide /bundles/ to /b/
rewrite ^/b/(.*)$ /bundles/$1 permanent;
location / {
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ ^/(app|app_dev|apc-.*)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
# cache control for images
location ~* ^.+\.(jpeg|gif|png|jpg)
{
add_header Cache-control "public";
access_log off;
expires 90d;
}
}
##server {
## listen 443;
## server_name XXX;
## root /var/www/XXX/web;
## ssl on;
## ssl_certificate /etc/ssl/certs/XXX.crt;
## ssl_certificate_key /etc/ssl/private/XXX.key;
## error_log /var/log/nginx/symfony2.error.log;
## access_log /var/log/nginx/symfony2.access.log;
# strip app.php/ prefix if it is present
## rewrite ^/app\.php/?(.*)$ /$1 permanent;
## location / {
## index app.php;
## try_files $uri @rewriteapp;
## }
## location @rewriteapp {
## rewrite ^(.*)$ /app.php/$1 last;
## }
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
## location ~ ^/(app|app_dev|apc-.*)\.php(/|$) {
## fastcgi_pass unix:/var/run/php5-fpm.sock;
## fastcgi_split_path_info ^(.+\.php)(/.*)$;
## include fastcgi_params;
## fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
## fastcgi_param HTTPS off;
## }
## location ~* ^.+\.(jpeg|gif|png|jpg)
## {
## add_header Cache-control "public";
## access_log off;
## expires 90d;
## }
##}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment