Skip to content

Instantly share code, notes, and snippets.

@kdankov
Last active November 17, 2020 22:15
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 kdankov/e323be38c473b801c8657d67800a0770 to your computer and use it in GitHub Desktop.
Save kdankov/e323be38c473b801c8657d67800a0770 to your computer and use it in GitHub Desktop.
NGINX with PHP with Homebrew
server {
listen 80;
listen [::]:80;
server_name local.givingforce.com;
root /Users/koko/Sites/gfadmin;
index index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9004;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
}
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
client_max_body_size 50M;
keepalive_timeout 65;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
server {
listen 80 default_server;
server_name localhost;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include servers/*;
}

Stop Apache and remove it from starting on login

$ sudo apachectl -k stop
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Install nginx

$ brew install nginx

Install php

$ brew install php php-fpm

Edit php-fpm config

/usr/local/etc/php/7.4/php-fpm.d/www.conf

This allows us to run multiple versions of php on different ports :)

listen = 127.0.0.1:9004

Start nginx service

$ sudo brew services start nginx

Start php service

$ brew services start php

config files

  • /usr/local/etc/
  • /usr/local/etc/nginx/
  • /usr/local/etc/php/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment