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:
- 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:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
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:
brew --version
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:
brew install httpd
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:
brew services start httpd
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:
Listen 80
Listen 443
3. Install PHP:
To install PHP, run the following command:
brew install php
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:
- Install Apache, if it is not already installed on your system. You can do this by running the following command:
Copy code
brew install httpd
- Install PHP, if it is not already installed on your system. You can do this by running the following command:
Copy code
brew install php
- 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
. - Open the Apache configuration file in a text editor and look for the following lines:
Copy code
LoadModule php8_module libexec/apache2/libphp8.so
AddType application/x-httpd-php .php
If these lines are not present, add them to the end of the file.
- Save the configuration file and restart Apache. You can do this by running the following command:
brew services restart httpd
- 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:
<?php
phpinfo();
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:
brew install mariadb
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:
brew services start httpd
brew services start mariadb
6. Test the installation:
To test the installation, create a PHP file with the following content:
<?php
phpinfo();
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:
mysql -u root
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.