Reputation: 610
I tried to configure dnsmasq with a fresh clean macOS High Sierra 10.13.2
Apache Version
Server version: Apache/2.4.28 (Unix)
Server built: Oct 9 2017 19:54:20
apachectl configtest
Syntax OK
I used to have it and worked fine. But I think I'm missing something, because I'm getting 403 forbidden error on localhost, 127.0.0.1 and any project like home.test or anything.test
Forbidden
You don't have permission to access / on this server.
I uncommented the necessary files to make it work:
httpd.conf
Include /private/etc/apache2/extra/httpd-vhosts.conf
Include /private/etc/apache2/extra/httpd-userdir.conf
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule php7_module libexec/apache2/libphp7.so
User absolutkarlos
Group staff
ServerName localhost
Directory > AllowOverride None
Directory > Options FollowSymLinks Multiviews Indexes
dnsmasq.conf
address=/test/127.0.0.1
absolutkarlos.conf
Directory "/Users/absolutkarlos/DOC/www/sites/"
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
httpd-userdir.conf
UserDir sites
Include /private/etc/apache2/users/*.conf
httpd-vhosts.conf
<Directory "/www">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Virtualhost *:80>
VirtualDocumentRoott "/Users/absolutkarlos/DOC/www/home/wwwroot"
ServerName home.test
UseCanonicalName Off
</Virtualhost>
<Virtualhost *:80>
VirtualDocumentRoot "/Users/absolutkarlos/DOC/www/sites/%1/wwwroot"
ServerName sites.test
ServerAlias *.test
UseCanonicalName Off
</Virtualhost>
error_log
AH01630: client denied by server configuration: /Users/absolutkarlos/DOC/www/home, referer: http://home.test/
AH01630: client denied by server configuration: /Users/absolutkarlos/DOC/www/home, referer: http://localhost/
AH01630: client denied by server configuration: /Users/absolutkarlos/DOC/www/home, referer: http://127.0.0.1/
Any ping works fine
ping
ping -c 1 home.test
PING home.test (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.035 ms
--- home.test ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.035/0.035/0.035/0.000 ms
Upvotes: 1
Views: 472
Reputation: 126
if you're doing this while using dnsmasq (not creating dynamic vhosts, but adding each one to your httpd-vhost file), make sure in your httpd.conf file, the DocumentRoot directive points to one dir above the one you are creating your projects in.
i.e. : /Users/MyUser/Projects/
in your httpd-vhosts.conf file
<VirtualHost *:80>
DocumentRoot "/Users/MyUser/Projects/blog"
ServerName blog.test
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/MyUser/Projects/project2"
ServerName project2.test
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/MyUser/Projects/testproject"
ServerName testproject.test
</VirtualHost>
then, in httpd.conf (around line 248):
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Users/MyUser/Projects/"
<Directory "/Users/MyUser/Projects/">
If your projects are not directly under /Users/MyUser/Projects, Apache will fallback to your system access directives, which, by default, deny access (around line 230):
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
Upvotes: 1