Skip to content

Instantly share code, notes, and snippets.

@ross-humphrey
Last active February 11, 2020 22:17
Show Gist options
  • Save ross-humphrey/f3b79c3901ba5f6655a9e57bcc7a69c5 to your computer and use it in GitHub Desktop.
Save ross-humphrey/f3b79c3901ba5f6655a9e57bcc7a69c5 to your computer and use it in GitHub Desktop.
Install Nginx in Mac OSX
# in terminal
brew install nginx
# running on default port you can run without sudo
nginx
# fancy running nginx evertime you start the machine?
# brew services start nginx
# check its running - http://localhost:8080
# stop the nginx server if it's running
sudo nginx -s stop
# if apache running must also be stopped
sudo apachectl stop
# change default port to port 80
vi /usr/local/etc/nginx/nginx.conf
========================================
# change :
server {
listen 8080;
server_name localhost;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
# to this:
server {
listen 80;
server_name localhost;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
# save and relaunch
========================================
# again run nginx - sudo not required
nginx
# default location for serving files from homebrew install is: /usr/local/Cellar/nginx/<version_number/html
# move the output of your 'build' i.e where the index.html (root) files sit into this directory for nginx to serve them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment