xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew install bash-completion
brew update && brew upgrade
vi ~/.bash_profile
Add following lines
##
# Homebrew
##
export PATH="/usr/local/bin:$PATH"
export PATH="/usr/local/sbin:$PATH"
##
# Homebrew bash completion
##
if [ -f $(brew --prefix)/etc/bash_completion ]; then
source $(brew --prefix)/etc/bash_completion
fi
DNSMasq is used to resolve all domains that end with .dev to 127.0.0.1. So you don´t need to touch hosts-File anymore.
brew install dnsmasq
curl -L https://gist.githubusercontent.com/munho/0bad10573910da0bbae2148aa4bf6c2f/raw/63c19470ef3ff480345090afc7e09fdf265e6251/dnsmasq.conf -o /usr/local/etc/dnsmasq.conf
sudo curl -L https://gist.githubusercontent.com/munho/0bad10573910da0bbae2148aa4bf6c2f/raw/63c19470ef3ff480345090afc7e09fdf265e6251/dev -o /etc/resolver/dev
# Start
brew services start dnsmasq
# Stop
brew services stop dnsmasq
# Restart
brew services restart dnsmasq
dig testing.a.domain.that.should.point.to.localhost.dev @127.0.0.1
brew install php@7.4
vi /usr/local/etc/php/7.4/php-fpm.d/www.conf
user = YOUR_USERNAME
group = YOUR_GROUP || staff
start php-fpm
brew services start php@7.4
show running processes
lsof -Pni4 | grep LISTEN | grep php
brew install nginx
## Start Nginx
brew services start nginx
## Check if Nginx is running on default port
curl -IL http://127.0.0.1:8080
Output should look like this
HTTP/1.1 200 OK
Server: nginx/1.10.0
Date: Sat, 07 May 2016 07:36:32 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 26 Apr 2016 13:31:24 GMT
Connection: keep-alive
ETag: "571f6dac-264"
Accept-Ranges: bytes
brew services stop nginx
####Configure
Create missing directories
mkdir -p /usr/local/etc/nginx/sites-available && \
mkdir -p /usr/local/etc/nginx/sites-enabled && \
mkdir -p /usr/local/etc/nginx/conf.d && \
mkdir -p /usr/local/etc/nginx/ssl
Configure nginx.conf
# Remove default
rm /usr/local/etc/nginx/nginx.conf
# Copy mine
curl -L https://gist.githubusercontent.com/munho/0bad10573910da0bbae2148aa4bf6c2f/raw/63c19470ef3ff480345090afc7e09fdf265e6251/nginx.conf -o /usr/local/etc/nginx/nginx.conf
Start and Test Nginx
## Start Nginx
brew services start nginx
## Check if Nginx is running on default port
curl -IL http://localhost
## Output should look like this
HTTP/1.1 200 OK
Server: nginx/1.19.7
Date: Tue, 23 Feb 2021 06:23:01 GMT
Content-Type: text/html
Content-Length: 53
Last-Modified: Mon, 22 Feb 2021 04:03:55 GMT
Connection: keep-alive
ETag: "60332d2b-35"
Accept-Ranges: bytes
Create a folder for our SSL certificates and private keys:
mkdir -p /usr/local/etc/nginx/ssl
Generate 4096 bit RSA keys and the self-sign the certificates in one command:
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=State/L=Town/O=Office/CN=localhost" -keyout /usr/local/etc/nginx/ssl/localhost.key -out /usr/local/etc/nginx/ssl/localhost.crt
These are working presets. But you need to edit Document-Root
curl -L https://gist.githubusercontent.com/munho/0bad10573910da0bbae2148aa4bf6c2f/raw/63c19470ef3ff480345090afc7e09fdf265e6251/default -o /usr/local/etc/nginx/sites-available/default && \
curl -L https://gist.githubusercontent.com/munho/0bad10573910da0bbae2148aa4bf6c2f/raw/63c19470ef3ff480345090afc7e09fdf265e6251/default-ssl -o /usr/local/etc/nginx/sites-available/default-ssl
Activate Virtual Hosts
ln -sfv /usr/local/etc/nginx/sites-available/default /usr/local/etc/nginx/sites-enabled/default
ln -sfv /usr/local/etc/nginx/sites-available/default-ssl /usr/local/etc/nginx/sites-enabled/default-ssl
Create info.php for testing
echo "<?php phpinfo();" > /path/to/your/document/root
Test
sudo brew services restart nginx
curl -IL http://localhost/info.php
# Output should look like this
HTTP/1.1 200 OK
Server: nginx/1.19.7
Date: Tue, 23 Feb 2021 06:23:24 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/7.4.15