I’m installing the whole LAMP stack through Homebrew (Apache, PHP, MySQL, Dnsmasq).
Here’s a brief summary of the config:
ServerName localhost
Listen 80
DocumentRoot "/Users/your_user/Sites"
<Directory "/Users/your_user/Sites">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
With just these, everything works fine.
On the next part when I try to add virtual host using a config I know to have worked in the past, I encounter errors.
LoadModule vhost_alias_module libexec/mod_vhost_alias.so
<VirtualHost *:80>
DocumentRoot /Users/elzi/Sites
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName dev
ServerAlias *.dev
VirtualDocumentRoot /Users/elzi/Sites/%-2+
</VirtualHost>
At this point I’m not even worried about PHP/MySQL/DNSMASQ. I just need one of my virtualhost configs to work first. Using the bottom rule I should be able to access any site in my ~/Sites
folder, provided I make an entry for them in my hosts file.
I can access site at http://localhost
and see an index of whatever I set the DocumentRoot
(or VirtualDocument
) root to be, but I cannot access wildcard ServerAlias
. For example,
http://test.dev
does not resolve in Apache, despite:
- It existing in my host file.
- Being able to ping it.
I’m starting to think the problem is not strictly Apache related? Maybe DNS/IPv6 issues?
Here's a dump of netstat -amp tcp | grep 80
tcp4 0 0 192.168.0.108.49632 151.101.193.69.80 ESTABLISHED
tcp4 0 0 192.168.0.108.49608 151.101.193.69.80 ESTABLISHED
tcp6 0 0 ::1.49567 ::1.80 CLOSE_WAIT
tcp4 0 0 192.168.0.108.49566 192.168.0.101.8060 CLOSE_WAIT
tcp46 0 0 *.80 *.* LISTEN
tcp4 0 0 127.0.0.1.18800 *.* LISTEN
Output of sudoapachectl -v
Server version: Apache/2.4.23 (Unix)
Server built: Dec 22 2016 18:07:11
Output of cat /etc/resolv.conf
nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
Output of brew services list
Name Status User Plist
httpd24 started elzi /Users/elzi/Library/LaunchAgents/homebrew.mxcl.httpd24.plist
jack started elzi /Users/elzi/Library/LaunchAgents/homebrew.mxcl.jack.plist
mongodb started elzi /Users/elzi/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
mysql started elzi /Users/elzi/Library/LaunchAgents/homebrew.mxcl.mysql.plist
php70 started elzi /Users/elzi/Library/LaunchAgents/homebrew.mxcl.php70.plist
Output of sudo apachectl -S
VirtualHost configuration:
*:80 is a NameVirtualHost
default server localhost (/usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf:3)
port 80 namevhost localhost (/usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf:3)
port 80 namevhost dev (/usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf:8)
wild alias *.dev
ServerRoot: "/usr/local/opt/httpd24"
Main DocumentRoot: "/Users/elzi/Sites"
Main ErrorLog: "/usr/local/var/log/apache2/error_log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/usr/local/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/usr/local/var/run/apache2/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="elzi" id=501
Group: name="staff" id=20
/Users/elzi/Sites
, but you want connections toexample.dev
to use/Users/elzi/sites/example/
but connections towww.example.dev
should use/Users/elzi/Sites/www.example
. Is that right? Can you give an example of what you tried and what happened?www.example.dev
resolving, justexample.dev
This was a config that worked fine with apache 2.2. It's straight up magic when it works, I just create a new folder in my ~/Sites and I can automatically access it with the wildcard * rule and the%-2+
string formatting. Now nothing resolves. Even when I manually add a VirtualHost rule directly to a folder it does not resolve.brew install --with privledged-ports
2) Do not bother with installing hisco.echo.httpdfwd.plist
launch daemon since 2.4 can use privledged ports. and 2a) 80 instead of 8080 where applicable.