Amazon.co.uk Widgets

Log in

X
Local Development 101: Create an Apache Server on macOS Sequoia Using Homebrew

Setting up an Apache server with Homebrew on macOS Sequoia 15 can enhance your local development and testing capabilities significantly. This guide serves to walk you through the necessary steps to install Apache, make the required configuration adjustments, and enable your environment for local testing of websites. Importantly this method does not interfere with the system version of Apache which is made complex by Apple. If you have not yet installed Homebrew, you may first want to do so as it simplifies package management on macOS.

TL:DR – The installation of Apache on macOS Sequoia 15 with Homebrew is straightforward and involves editing configuration files, setting permissions, and ultimately testing your server. This setup is designed for local development, allowing you to test your websites, and in my case Joomla content management system extensions, before deployment. Follow each step diligently, and you’ll have your server operational in no time. I wouldn't recommend macOS for production web site hosting anymore though. Best to use a hosting provider for that.

Pre-requisites for setting up Apache

Before diving into the installation and configuration of the Apache server, it is crucial to ensure that your macOS environment is prepared. The first step is to check whether you have Homebrew installed. Homebrew is a user-friendly package manager for macOS that simplifies the installation of various software.

Homebrew

To check if Homebrew is installed, you can run the command brew --version in the Terminal. If it returns a version number, consider yourself fortunate; you can skip to the next step. Should it come back with 'command not found', you will need to install it with the command provided on the official Homebrew website, which involves pasting a command into the terminal. You can see how to do that in the article Installing wget with Homebrew on macOS here on this site.

% brew --version
Homebrew 4.4.26

 Once Homebrew is installed, it is wise to ensure that it is up to date. You can do this by executing brew update. This ensures that you have the latest packages available, which is particularly helpful when installing Apache, as it may have had updates that improve performance or security.

 % brew update
==> Updating Homebrew...
Already up-to-date.

 Lastly you can always check your Homebrew installation using brew doctor, and then following any notices it may present. Remember that warnings are just that - and might not need attention. 

% brew doctor                          
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  openssl@1.1

Installation of Apache via Homebrew

With Homebrew at your disposal, the installation of Apache becomes a rather straightforward process. Open your terminal and type brew install httpd. This command initiates the installation process, retrieving the latest version of Apache from Homebrew’s repositories. Theres a lot of console information here but heres the main part.

% brew install httpd
...
==> Fetching httpd
==> Downloading
...
################################################################ 100.0%
==> Installing dependencies for httpd: ca-certificates
...
==> Installing httpd
==> Pouring httpd--2.4.63.arm64_sequoia.bottle.tar.gz
==> Caveats
DocumentRoot is /opt/homebrew/var/www.

The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in
/opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.

To start httpd now and restart at login:
  brew services start httpd
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND

 Upon the completion of the installation, you can verify that Apache has been installed correctly by running httpd -v. This command will display the version number of the Apache HTTP server that has been installed. If you are seeing output, congratulations, you have successfully installed Apache.

% httpd -v
Server version: Apache/2.4.63 (Unix)

Now you need to start the web server using brew services start httpd. You should see a success message. The next stage is to kick the Apache server into gearusing brew services start httpd to load the server. You should see a success message. This will ensure Apache starts automatically whenever you boot your machine, which is nice.

If you encounter errors while attempting the above command, it is possible that Apache is already running, perhaps from a previous installation. In such a case, restart Apache using sudo brew services restart httpd to apply the changes made to the configuration files.

% brew services start httpd
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)

By default, Apache will listen on port 8080 with Homebrew. If you attempt to visit http://localhost:8080 in your web browser after installation, you should see an Apache default page confirming that Apache is up and running. You’ll notice that this differs from the standard port 80, which is commonly used for web traffic. This is because macOS may already be using port 80 for another service, so by default it is installed by Homebrew out of the way.

Safari connected to localhost:8080 showing the default website 'It works!' page
Safari connected to localhost:8080 showing the default website 'It works!' page

 

Configuration of Apache

After successfully installing Apache, the next step is to configure the server settings according to your development requirements. Configuration files for Apache are to be found in /opt/homebrew/etc/httpd/httpd.conf when using Homebrew. To edit this file, you can use your preferred text editor—however, if you're a command line person, vi will do just fine. 

To open the configuration file, use the command: sudo vi /opt/homebrew/etc/httpd/httpd.conf You may need to enter your password as this command privileges elevated permissions to edit system files.

In the configuration file, you can set a variety of directives.

DocumentRoot is set by default to /opt/homebrew/var/www. You can change this once you get a little further but its a perfectly good place away from any interference by macOS itself.

The default ports are been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in /opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.

Not enabling user directories

The built-in configuration for Apache user directories in macOS uses the ~/Sites folder. Since this is our own Homebrew installation of Apache I would recommend avoiding user directories altogether. This is a development server after all, lets keep it simple.

Document Root

Instead of user directories, the Homebrew installation has set the document root to /opt/homebrew/var/www which is a good location for it, out of the way of the macOS system, and manageable by the local admin user. You can change this and make this more complex with virtual hosts if you wish but for now lets leave it as it is.

% ls /opt/homebrew/var/www
cgi-bin    index.html
% cat /opt/homebrew/var/www/index.html 
<html><body><h1>It works!</h1></body></html>
% 

 After configuring permissions and directories, it is prudent to perform a sanity check to ensure that the Apache configuration file syntax is valid. Execute apachectl configtest. If the output states 'Syntax OK', proceed to start the server.

% apachectl configtest
AH00557: httpd: apr_sockaddr_info_get() failed for mac
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

Enabling PHP in Apache for Joomla

Installing PHP via Homebrew

Joomla requires PHP. If it isn't installed you can install it using Homebrew using brew install php. This installs the latest stable version. If you need multiple PHP versions for testing this won't be the right thing to do but for me its fine. Check you have PHP using php -v Note that it tells you it came from Homebrew.

% php -v
PHP 8.4.5 (cli) (built: Mar 12 2025 01:55:56) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.5, Copyright (c), by Zend Technologies

Enabling PHP in the Apache configuration file

Now edit /opt/homebrew/etc/httpd/httpd.conf and find the line #LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so. You can make this active by removing the #. Joomla can make use of mod_rewrite which is a rule-based rewriting engine to rewrite requested URLs on the fly. Below this line add the enabling module for PHP #LoadModule php_module /opt/homebrew/opt/php@8.4/lib/httpd/modules/libphp.so. Those two lines should look like this:

LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
LoadModule php_module /opt/homebrew/opt/php@8.4/lib/httpd/modules/libphp.so

Allowing PHP to be handled and served by the web server

If you try to load your PHP page right now you'll just see source code. So you have to tell Apache to serve the page as the index for a directory. Look for DirectoryIndex index.html in the httpd.conf file and change it to include PHP

Original no PHP

Apache will only look for index.html to serve if the directory is requested.

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

 PHP Directory indexes

Apache will look for index.php if the directory is requested.

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

 FilesMatch directive

Now add a FilesMatch directive to ensure that PHP files are handled correctly. 

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Restart the web server and test

Save your configuration files, create a PHP info page and restart the web server to test.

info.php

Create a file called info.php in your document root folder with one line in it <?php phpinfo();".

Restart Apache

Stop your server using % brew services stop httpd 

% brew services stop httpd
Stopping `httpd`... (might take a while)
==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd)

Restart using % brew services start httpd

% brew services start httpd
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)

 Now if you load http://localhost:8080/info.php you should see the PHP info page - you can see if was built by Homebrew too.

Safari with PHP for Apache on macOS 15 Sequoia built by Homebrew
Safari with PHP for Apache on macOS 15 Sequoia built by Homebrew

Install a MySQL compatible database with Homebrew

Im going to use MariaDB which is fully supported by Joomla but you can use MySQL if you prefer. MariaDB Server can be installed using this command brew install mariadb

Install MariaDB 

% brew install mariadb
...
==> Fetching mariadb
...
==> Downloading 
==> Installing mariadb
...
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

MySQL is configured to only allow connections from localhost by default

To start mariadb now and restart at login:
  brew services start mariadb
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/mariadb/bin/mariadbd-safe --datadir\=/opt/homebrew/var/mysql

Start MariaDB

After installation, start MariaDB Server using mysql.server start, and to auto-start MariaDB Server, you can again use Homebrew's services functionality, which configures auto-start with the launchctl utility from launchd using brew services start mariadb

% mysql.server start
Starting MariaDB
/opt/homebrew/Cellar/mariadb/11.7.2/bin/mysqld_safe: Deprecated program name. It will be removed in a future release, use 'mariadbd-safe' instead
250328 13:43:03 mysqld_safe Logging to '/opt/homebrew/var/mysql/mac.err'.
250328 13:43:03 mysqld_safe Starting mariadbd daemon with databases from /opt/homebrew/var/mysql
.. SUCCESS! 
% brew services start mariadb
==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb)

Sign in to MariaDB

After MariaDB Server is started, you can log in as your user using mysql or as root using sudo mysql -u root.

% sudo mysql -u root
Password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 11.7.2-MariaDB Homebrew

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

Install Joomla 5.2 or later

Unzip the full package from https://downloads.joomla.org/ into your document root folder and go ahead and run the installer by loading the index.php and you can install your test and development site.

Joomla Installer

Run the installer by loading the index.php in your browser http://localhost:8080/index.php. Set the language if the default isn't what you want, and set the site name. This is on a Mac so you can use the bonjour name for your Mac ending in .local and avoid DNS altogether for now.

Joomla 5.2.5 Installer - Login Data - on macOS 15 Sequoia
Joomla 5.2.5 Installer - Login Data - on macOS 15 Sequoia

Joomla Login Data

Enter the data which you will use to Login as the Super user for your new Joomla site, real name, username, password and email address.

Joomla 5.2.5 Installer - Login Data - on macOS 15 Sequoia
Joomla 5.2.5 Installer - Login Data - on macOS 15 Sequoia

Joomla Database Configuration

Enter database information for your MariaDB database. Use localhost and your Mac computer username and password.

Joomla 5.2.5 Installer - Database information - on macOS 15 Sequoia
Joomla 5.2.5 Installer - Database information - on macOS 15 Sequoia

Joomla Site is ready

Because this is a development install, you'll see errors on this page. This is because a PHP setting Display Errors is set to on. You can turn it off if you wish or leave it for debugging. Notice that Joomla recommends it be off, especially for production sites.

Joomla 5.2.5 Installer - Site ready, display errors and output buffering on - on macOS 15 Sequoia
Joomla 5.2.5 Installer - Site ready, display errors and output buffering on - on macOS 15 Sequoia

Cassiopeia

If you click Open Site you'll get the blank Cassiopeia Template and your Joomla site is up!

Joomla 5.2.5 Site - Cassiopeia Template - on macOS 15 Sequoia
Joomla 5.2.5 Site - Cassiopeia Template - on macOS 15 Sequoia

Welcome to Joomla Admin tour

If you click Open Administrator you'll get the Admin dashboad welcome to Joomla tour.

Joomla 5.2.5 Installer - Admin tour - on macOS 15 Sequoia
Joomla 5.2.5 Installer - Admin tour - on macOS 15 Sequoia

Joomla Dashboard

Dismiss the tour and the Joomla Admin is fully available to you right on your development Mac computer.

Joomla 5.2.5 Installer - Admin dashboard - on macOS 15 Sequoia
Joomla 5.2.5 Installer - Admin dashboard - on macOS 15 Sequoia

If you got this far you have a local development Joomla site. Not too painful I hope.

Final thoughts on local development

This development setup allows for HTML and CSS testing, as well as for testing of extensions written for Joomla and PHP applications. Joomla is a content management systems written in PHP which makes for the start point for excellent content based websites. Having a development environment that is close to the production environment streamlines the development process too, allowing you to use tools that cannot be used in production to improve your software see Using Xdebug to improve PHP development with Joomla! 

When your local projects are ready for deployment in production, managed services providers such as Rochen (who we use, and are rock solid and provide cPanel, automatic free Let's encrypt, site security and a whole host of other goodness along with stellar support) can offer scaling options that are necessary for production environments. Or you can roll your own infrastructue on cloud services such as AWS or Azure. 

Utilising Apache on macOS for local testing remains a simple and effective method for developing web applications. Keep exploring and improving upon your setup, adding Let's encrypt for https support, virtual hosts and Joomla if you wish, and consider other programming languages, databases, and tools that fit your needs. 

Homebrew is a godsend in this because it avoids all the pitfalls of Apple macOS idiosyncracies, without precluding their use or lessening macOS Sequioia security and it does that in a way that is familiar to users of Unix and unix-like operating systems by putting things carefully away out of the way in /opt

Conclusion

The steps outlined in this guide provide an easy way to set up a local Apache server on macOS Sequoia 15 using Homebrew. With the successful installation and configuration of Apache, you can efficiently develop and test your static websites and joomla websites locally before deploying them in more significant operational environments.

Remember, proper configuration and permissions are crucial in avoiding common pitfalls, and regular checks will keep your development environment running smoothly. While the basics have been covered, don't hesitate to explore further configurations, installations of PHP, or even other web technologies that cater to your specific developmental needs.

Best not to allow traffic from the Internet into a Web server on your Mac computer though. Make sure its not accessible and be careful if its a laptop on a coffee shop WiFi.