Skip to content

Instantly share code, notes, and snippets.

@edigu
Last active November 1, 2018 10:38
Show Gist options
  • Save edigu/c6908d10f41c9e78a608dbf0a7389a43 to your computer and use it in GitHub Desktop.
Save edigu/c6908d10f41c9e78a608dbf0a7389a43 to your computer and use it in GitHub Desktop.
OSX Hombebrew & Nginx + Ekstralar

Problem: OSX el capitan üzerinde Homebrew ile nginx'in built-in gelen formülü kullanarak (brew install nginx) kurulursa production ortamına göre çok basic kalıyor.

Ekstra modül ihtiyacında nginx'i elle derlemek yerine homebrew üzerinden temiz kurulum için;

$ brew update
$ brew tap homebrew/nginx
$ brew unlink nginx
$ brew options nginx-full
$ brew install nginx-full \
    --with-geoip \
    --with-status \
    --with-websockify-module \
    --with-upload-progress-module \
    --with-redis2-module \
    --with-realip \
    --with-http2 \
    --with-gzip-static

Home: homebrew/nginx

# VHOST
# dev.demosite.com
#
# REPLACE ALL $HOMEDIR WITH YOUR HOME:
# Ex: /Users/username/Sites
server {
listen 80;
server_name dev.demosite.com;
# Redirect trailing slashes to
rewrite ^/(.*)/$ /$1 permanent;
root $HOMEDIR/demosite.com/public;
# Make sure that /Users/username/Sites/logs exists
access_log $HOMEDIR/logs/dev.demosite.access.log;
error_log $HOMEDIR/logs/dev.demosite.error.log notice;
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
include fastcgi.conf;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
fastcgi_intercept_errors on;
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param APPLICATION_ENV development;
# Add the original fastcgi_params
include fastcgi_params;
fastcgi_read_timeout 5000;
fastcgi_pass http-servers;
fastcgi_index index.php;
}
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
worker_processes 2;
events {
worker_connections 1024;
}
http {
charset UTF-8;
include mime.types;
default_type application/octet-stream;
sendfile on;
# tcp_nopush on;
keepalive_timeout 20;
# prevent 413 - Request Entity Too Large errors
client_max_body_size 10M;
# Persist request bodies which larger than x to /tmp
client_body_temp_path /tmp;
# Enable gzip compression
gzip on;
gzip_comp_level 5;
gzip_proxied any;
gzip_types text/plain text/css text/javascript application/json application/x-javascript text/xml application/xml application/xml+rss image/x-icon;
# A security belt
index index.html index.php;
# Use upstream to pass php requests socket
upstream http-servers {
server unix:/tmp/php-fpm.sock;
}
fastcgi_buffers 4 32k;
fastcgi_buffer_size 32k;
include sites-enabled/*;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment