Creating a local web-server on MacOS Big Sur
Start the builtin Apache server
sudo apachectl start
You should now be able to direct your browser to ‘localhost’ or ‘127.0.0.1’ and see in the browser ‘ it works!’. The default Apache configuration reads from
Apple recommends to create a directory ‘Sites’ in your home account and run your local user website from there. First, create the directory for the website in your home directory
mkdir ~/Sites echo '
It works locally too!' > ~/Sites/index.html
Next, navigate to the apache user configuration directory
where you should see a file with your user name ending with ‘.conf’.
<Directory "/Users/developer/Sites/"> Options Indexes MultiViews Require all granted </Directory>
Modify it to
<Directory "/Users/developer/Sites/"> AllowOverride All Options Indexes MultiViews FollowSymLinks Require all granted </Directory>
Navigate to the parent directory, and make a backup of the original ‘https.conf’ file.
cd /etc/apache2 sudo cp httpd.conf httpd.conf.bak cd /etc/apache2/extra sudo cp httpd-userdir.conf httpd-userdir.conf.bak
Edit the file
and uncomment line 16
# Settings for user home directories # # Required module: mod_authz_core, mod_authz_host, mod_userdir # # UserDir: The name of the directory that is appended onto a user's home # directory if a ~user request is received. Note that you must also set # the default access control for these directories, as in the example below. # UserDir Sites # # Control access to UserDir directories. The following is an example # for a site where these directories are restricted to read-only. # #Include /private/etc/apache2/users/*.conf <IfModule bonjour_module> RegisterUserSite customized-users </IfModule>
Next, edit the file
and uncomment line 113
#LoadModule include_module libexec/apache2/mod_include.so
lines 186 and 187
#LoadModule rewrite_module libexec/apache2/mod_rewrite.so #LoadModule php7_module libexec/apache2/libphp7.so
and line 555 (the last line)
Make sure the following lines are also uncommented
LoadModule authn_core_module libexec/apache2/mod_authn_core.so LoadModule authz_host_module libexec/apache2/mod_authz_host.so LoadModule userdir_module libexec/apache2/mod_userdir.so LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Finally, restart the apache server
sudo apachectl restart
Test the configuration by pointing the browser to you local user site
where ‘username’ is your account name. The account name can found by the command
1 thought on “Setting up Apache User Sites Folders on MacOS”
Thanks for putting this together. It helped me out big time. I’m used to doing this on Linux, but never did it on a Mac before. Your guide helped me out. Thanks again.