Tips and tricks

Create a local dev Apache Mysql PHP Setup on Mac OS X - Add Virtual Hosts
Posted on October 7 2023 / in WordPress
How to create a local dev Apache Mysql PHP Setup on Mac OS X ‣ Digital Zoom Studio
also, remember to allow vhost_alias_module
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
You can add unlimited virtual hosts just like MAMP adds them. You can just access /private/etc/apache2/httpd.conf and add:
<VirtualHost *:80>
ServerName devsite
DocumentRoot "/Users/123/Dropbox/hosts/devsite"
Protocols h2 h2c http/1.1
<IfModule xsendfile_module>
XSendFilePath "/Users/123/Dropbox/hosts/devsite"
</IfModule>
ServerAlias devsite.*
<Directory "/Users/123/Dropbox/hosts/devsite">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
<IfModule authz_host_module>
Require all granted
</IfModule>
Allow from all
</Directory>
<IfModule wsgi_module>
WSGIDaemonProcess devsite processes=2 threads=15
WSGIProcessGroup devsite
WSGIScriptAlias /devsiteWsgiApp "/Users/123/Dropbox/hosts/devsite/wsgiapp.py"
</IfModule>
</VirtualHost>
Add SSL Virtual hosts
first, you need to go to httpd.conf and enable ssl_module

Informal
remember to add your entry to /private/etc/hosts
127.0.0.1 devsite devsite.local
you can flush dns cache with sudo killall -HUP mDNSResponder
Frequently asked questions
Find apache folder
whereis httpd
Print apache config location
httpd -V
Create certificate for https hosts
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
-keyout videogallery.key -out videogallery.crt \
-subj "/CN=videogallery"
Create certificate with SAN
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
-keyout dzsvideogallery.key -out dzsvideogallery.crt \
-config ./san.cnf -extensions req_ext
san.cnf
[ req ]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn
[ dn ]
C = RO
ST = SomeState
L = SomeCity
O = LocalDev
OU = Dev
CN = dzsvideogallery.me
[ req_ext ]
subjectAltName = @alt_names
[ alt_names ]
DNS.1 = dzsvideogallery.me
DNS.2 = www.dzsvideogallery.me
Restart apache with new config
apachectl restart
Install npm packages globally on mac without sudo
Create a local dev Apache Mysql PHP Setup on Mac OS X - add PHP