DEV Community

Cover image for How to Install PHP, MariaDB, and phpMyAdmin on macOS
Parsa Roshani
Parsa Roshani

Posted on

How to Install PHP, MariaDB, and phpMyAdmin on macOS

Setting up a local development environment on macOS can be quite straightforward. In this tutorial, we’ll walk through the steps to install PHP, MariaDB, and phpMyAdmin.


Step 1: Install Homebrew

Homebrew is a package manager for macOS that simplifies the installation of software.

  1. Open Terminal.
  2. Run the following command to install Homebrew:
   /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode
  1. After installation, update Homebrew:
   brew update
Enter fullscreen mode Exit fullscreen mode

Step 2: Install PHP

Once Homebrew is installed, you can easily install PHP.

  1. Run the following command:
   brew install php
Enter fullscreen mode Exit fullscreen mode
  1. Verify the PHP installation:
   php -v
Enter fullscreen mode Exit fullscreen mode

Step 3: Install MariaDB

MariaDB is a popular database server used as an alternative to MySQL.

  1. Install MariaDB:
   brew install mariadb
Enter fullscreen mode Exit fullscreen mode
  1. Start the MariaDB service:
   brew services start mariadb
Enter fullscreen mode Exit fullscreen mode
  1. Secure your MariaDB installation:
   mysql_secure_installation
Enter fullscreen mode Exit fullscreen mode

Step 4: Install phpMyAdmin

phpMyAdmin is a web interface for managing databases.

  1. Install phpMyAdmin:
   brew install phpmyadmin
Enter fullscreen mode Exit fullscreen mode
  1. Configure Apache (or another web server) to serve phpMyAdmin:
    • Locate the phpMyAdmin directory, typically /usr/local/share/phpmyadmin.
    • Add a virtual host configuration in Apache to point to this directory.
  2. Restart your web server:
   sudo apachectl restart
Enter fullscreen mode Exit fullscreen mode

Step 5: Verify Setup

  1. Open your browser and navigate to http://localhost/phpmyadmin.
  2. Log in with your MariaDB credentials.

Conclusion

Congratulations! You have successfully installed PHP, MariaDB, and phpMyAdmin on your macOS system. You can now start developing PHP applications locally.

Top comments (0)