How to setup Homebrew + Apache + PHP + MariaDB on macOS Ventura 13.0

This guide is intended to assist you in maintaining an up-to-date development environment for macOS using the latest versions of Homebrew, Apache, PHP, and MariaDB.

To set up Apache, PHP, and MariaDB on macOS Ventura 13.0, you will need to follow these steps:

  1. Install Homebrew:

Homebrew is a package manager specifically designed for macOS that simplifies installing and managing software packages. To install Homebrew, open a terminal window and enter the following command:

This command will download and execute the Homebrew installation script. Once the installation is finished, you can confirm that Homebrew is functioning properly by running the following command:

This should print the version number of Homebrew. If it does, then Homebrew is installed and working correctly.

2. Install Apache:

To install Apache, run the following command:

This will download and install Apache and any dependencies it requires. Once the installation is complete, you can start the Apache server by running the following command:

To verify that the Apache server is running, open a web browser and visit the URL http://localhost. You should see the Apache "It works!" page.

Note: If you are using macOS Catalina or later, you may need to adjust the Apache configuration to allow it to bind to the default HTTP and HTTPS ports. You can do this by editing the file /opt/local/etc/apache2/httpd.conf and adding the following lines:

3. Install PHP:

To install PHP, run the following command:

This will install PHP and create a default configuration file at /usr/local/etc/php/8.2/php.ini. You can edit this file to configure PHP as needed.

To set up PHP on macOS Ventura 13.0 using Homebrew, follow these steps:

  1. Install Apache, if it is not already installed on your system. You can do this by running the following command:
  1. Install PHP, if it is not already installed on your system. You can do this by running the following command:
  1. Once Apache and PHP are installed, you need to configure Apache to use PHP. To do this, you will need to edit the Apache configuration file, which is located at /usr/local/etc/httpd/httpd.conf.
  2. Open the Apache configuration file in a text editor and look for the following lines:

If these lines are not present, add them to the end of the file.

  1. Save the configuration file and restart Apache. You can do this by running the following command:
  1. To verify that PHP is working correctly with Apache, create a file called info.php in the Apache document root (usually /usr/local/var/www/htdocs) with the following contents:

Then, open a web browser and visit the URL http://localhost/info.php. This should display a page with information about your PHP installation.

If you see the PHP information page, then PHP is working correctly with Apache on your system.

4. Install MariaDB:

To install MariaDB, run the following command:

This will install MariaDB and create a default configuration file at /usr/local/etc/my.cnf. You can edit this file to configure MariaDB as needed.

5. Start the Apache and MariaDB services:

To start the Apache and MariaDB services, run the following commands:

6. Test the installation:

To test the installation, create a PHP file with the following content:

Save the file as info.php in the Apache document root (usually /usr/local/var/www/htdocs). Then, open a web browser and go to http://localhost/info.php. This should display the PHP information page.

To test the MariaDB installation, run the following command:

This will open the MariaDB prompt. You can run SQL commands here to interact with the database.

That’s it! You should now have Apache, PHP, and MariaDB set up on your macOS Ventura 13.0 system.

--

--

Full Stack Engineer at NASA. Volunteer at Smithsonian’s The Renwick Gallery, and former drummer of #GovernmentIssue. https://www.karlhill.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Karl Hill

Full Stack Engineer at NASA. Volunteer at Smithsonian’s The Renwick Gallery, and former drummer of #GovernmentIssue. https://www.karlhill.com