I'm trying to setup my Apache on OSX, but I'm not able to make my local url 'awr.local' point to the correct path. I mean whether I type http://localhost or http://awr.local, it always shows me the index.html page in my 'localhost' vhost path. I've restarted my httpd service countless times, with or without sudo.
Any help would be greatly appreciated, thanks :'|
I've been following a tutorial (https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions), here are the steps about Apache :
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
brew install httpd
# changed Listen 8080 to :
Listen 80
[...]
# changed DocumentRoot "/usr/local/var/www" to :
DocumentRoot "/Users/wallace/dev/default"
[...]
# changed <Directory "/usr/local/var/www"> to :
<Directory "/Users/wallace/dev/default">
[...]
# changed AllowOverride None to :
AllowOverride All
# uncommented :
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
[...]
# changed
# User _www
# Group _www
# to :
User wallace
Group staff
[...]
# added the missing line :
ServerName localhost
Until this point everything seemed to be working fine, I've installed PHP and MariaDB without any problem.
Then came the virtual hosts part :
# uncommenting these lines
LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
[...]
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/Users/wallace/dev/default"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/wallace/dev/awr"
ServerName awr.local
</VirtualHost>
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 awr.local
::1 awr.local
VirtualHost configuration:
*:80 is a NameVirtualHost
default server localhost (/usr/local/etc/httpd/extra/httpd-vhosts.conf:25)
port 80 namevhost localhost (/usr/local/etc/httpd/extra/httpd-vhosts.conf:25)
port 80 namevhost awr.local (/usr/local/etc/httpd/extra/httpd-vhosts.conf:30)
ServerRoot: "/usr/local/opt/httpd"
Main DocumentRoot: "/Users/wallace/dev/default"
Main ErrorLog: "/usr/local/var/log/httpd/error_log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/usr/local/var/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/usr/local/var/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="wallace" id=501 not_used
Group: name="staff" id=20 not_used
Well, today when I was preparing to try the answer of Juan, I had something new : instead of serving me the localhost, the awr.local url showed me a 403 forbidden. After a new research & doc reading, I managed to make it work like this :
The Require all granted is the most important part.
<VirtualHost *:80>
DocumentRoot "/Users/wallace/dev/default"
ServerName localhost
<Directory "/Users/wallace/dev/default">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/wallace/dev/awr"
ServerName awr.local
<Directory "/Users/wallace/dev/awr">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I had to restart Apache with sudo for it to work :
sudo brew services stop httpd && sudo brew services start httpd