Enabling the In-Built Web Server on macOS 14 Sonoma / 15 Sequoia [Updated 2025]

macOS 14 Sonoma provides a robust platform for web development, allowing you to set up a local web server for building and testing your websites before deploying them. This guide will walk you through configuring the Apache server and Perl module on Sonoma, specifically for development purposes.

Important Notes:

  • This guide is macOS 14 Sonoma or later and assumes you haven’t installed any third-party package managers like Homebrew.
  • These instructions are for the client version of macOS, not the server version.
  • A basic understanding of Terminal and web servers is required.
  • You’ll need to be comfortable using a command-line text editor like vi (or nano).
  • Try http://localhost in the browser

Let’s Get Started!

  1. Configure Apache:
  • Open Terminal and edit the Apache configuration file as root:
    sudo vi /etc/apache2/httpd.conf
  • Enable CGI: Uncomment line 174 to enable the mod_cgi module:
    LoadModule cgi_module libexec/apache2/mod_cgi.so
  • Enable User Directories: Uncomment lines 184 and 521 to enable personal websites:
    LoadModule userdir_module libexec/apache2/mod_userdir.so

    Include /private/etc/apache2/extra/httpd-userdir.conf
  • Save and close the file.
  1. Configure User Directories:
  • Open the user directory configuration file:
    sudo vi /etc/apache2/extra/httpd-userdir.conf
  • Uncomment line 16 to include user-specific configuration files:
    Include /private/etc/apache2/users/*.conf
  • Save and close the file.
  1. Create Your Website Directory:
  • If you don’t have a Sites folder in your home directory, create one:
    mkdir ~/Sites
  • Create a simple index.html file:
    echo "<html><body><h1>My site works</h1></body></html>" > ~/Sites/index.html.en
  1. Set Up User-Specific Configuration:
  • Check if you have a user configuration file at /etc/apache2/users/<your short user name>.conf. If not, create it:
    sudo vi /etc/apache2/users/<your short user name>.conf
  • Add the following content, replacing <your short user name> with your actual username:
    <Directory "/Users/<your short user name>/Sites/">
        AddLanguage en .en
        AddHandler cgi-script .cgi .pl .php
        Options Indexes MultiViews FollowSymLinks ExecCGI
        AllowOverride None
        Require host localhost
    </Directory>

  1. Grant Apache Access:
  • Grant the Apache web server (_www user) access to your Sites directory:
    chmod +a "_www allow execute" ~
  1. Start Apache:
  • Check your Apache configuration for errors:
    apachectl configtest
  • If there are no syntax errors, start the Apache service:
    sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
  • If Apache is already running, reload the configuration:
    sudo apachectl graceful
  1. Test Your Website:
  • Open Safari and visit http://localhost/ to see the default “It works!” message.
  • Visit http://localhost/~<your short user name>/ to see your “My site works” message.

Congratulations! You have successfully set up a local web server on macOS 14 Sonoma / 15 Sequoia. You can now use this environment to develop and test your websites locally before deploying them to a live server.

  • Content Management Systems (CMS): Platforms like WordPress, Drupal, or Joomla offer user-friendly interfaces and powerful features for managing website content.
  • Static Site Generators: Tools like Publii, Hugo, Gatsby, or Jekyll generate static websites that are fast, secure, and easy to deploy.
  • GitHub Pages: Host your website directly from your GitHub repository for free and easy collaboration.

If you’re aiming to deploy a production-ready website, consider leveraging cloud platforms like DigitalOcean

DigitalOcean Referral Badge

Here is a tutorial on how to install Apache Server using homebrew and enable PHP

Leave a Reply

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