Local webserver on Mac OS Big Sur 11.4

Big Sur OS version 11.4 comes with pre-installed Apache and php:

  • Apache : 2.4
  • Php : 7.3.x

Start apache server using cmd :

sudo apachectl start

After starting apache, check http://localhost in browser, should show “It works!”

That’s Default Document Root, lets enable User Level Root to run sites @ http://localhost/~{username}/

Note : {username} is placeholder, please replace it with your valid username.

Create Sites folder @ root of account, /Users/{username}

Add {username}.conf at /etc/apache/users/ with following content

<Directory "/Users/{username}/Sites/">
  AllowOverride All
  Options Indexes MultiViews FollowSymLinks
  Require all granted

Load apache modules modifying httpd.conf file :

Open httpd.conf file :
sudo vi /etc/apache2/httpd.conf
Uncomment following modules: 
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule include_module libexec/apache2/mod_include.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so

Find and uncomment following line : 
Include /private/etc/apache2/extra/httpd-userdir.conf
Then open following file :
sudo vi /etc/apache2/extra/httpd-userdir.conf
and uncomment line :
Include /private/etc/apache2/users/*.conf

Restart apache 
sudo apachectl restart
Check http://localhost/~{username}/ in browser,
should list all files and directories in Sites folder.

Leave a comment

Your email address will not be published. Required fields are marked *