In this guide, we will learn how to install phpMyAdmin on your macOS. We will use Homebrew to install Apache (the web server) and PHP, and then we will download phpMyAdmin manually from the official source. Let’s go step by step.

Step 1: Install Homebrew

Homebrew is a package manager for macOS that makes it easy to install software.

  1. Open Terminal on your Mac.
  2. Run this command to install Homebrew:
  3. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  4. After installation, run this to make sure Homebrew is set up correctly:
  5. brew --version
    

Step 2: Install Apache

Apache is the web server that will run phpMyAdmin.

  1. In your Terminal, type the following command to install Apache:
  2. brew install httpd
    
  3. Once it is installed, start Apache with this command:
  4. sudo brew services start httpd
    
  5. To check if Apache is running, open a web browser and go to http://localhost. You should see a message that says “It works!”

Step 3: Install PHP

PHP is the programming language used by phpMyAdmin.

  1. Run the following command to install PHP:
  2. brew install php
    
  3. After PHP is installed, start it using:
  4. brew services start php
    
  5. You can check the PHP version with this command:
  6. php -v
    

Step 4: Download phpMyAdmin

Now, we will download phpMyAdmin from the official website.

  1. Open the phpMyAdmin website in your browser: https://www.phpmyadmin.net/
  2. Click on the Download button and choose the latest version in the .zip format.
  3. Once downloaded, unzip the file and move the folder to your Apache server directory. By default, this directory is located at:
  4. /usr/local/var/www/
    
  5. You can move the unzipped phpMyAdmin folder with this command:
  6. sudo mv ~/Downloads/phpMyAdmin-*-all-languages /usr/local/var/www/phpmyadmin
    

Step 5: Configure Apache for phpMyAdmin

We need to tell Apache where phpMyAdmin is located.

  1. Open the Apache configuration file in a text editor:
  2. sudo nano /usr/local/etc/httpd/httpd.conf
    
  3. Look for the line that starts with:
  4. 
    #LoadModule php_module
    
    
  5. Remove the # at the beginning of the line to enable PHP.
  6. Scroll down and add this line to the file to include phpMyAdmin:
  7. 
    Alias /phpmyadmin "https://tecadmin.net/usr/local/var/www/phpmyadmin"
    
    
  8. Save the file and exit the editor (press CTRL X, then Y, and press Enter).
  9. Restart Apache to apply the changes:
  10. sudo brew services restart httpd
    

Step 6: Access phpMyAdmin

You can now access phpMyAdmin in your web browser.

  1. Open your browser and go to this address:
  2. http://localhost/phpmyadmin
  3. You should see the phpMyAdmin login screen. Use your MySQL username and password to log in.
Step-by-Step Guide: How to Install phpMyAdmin on macOS General Articles MacOS phpMyAdmin
phpMyAdmin on macOS

Step 7: Secure phpMyAdmin (Optional)

For security, it’s a good idea to restrict access to phpMyAdmin by adding a login prompt. To do this:

  1. Open the phpMyAdmin configuration file:
  2. sudo nano /usr/local/var/www/phpmyadmin/.htaccess
    
  3. Add this content to the file:
  4. 
    AuthType Basic
    AuthName "Restricted Access"
    AuthUserFile /usr/local/etc/httpd/.htpasswd
    Require valid-user
    
    
  5. Create a password file with this command:
  6. sudo htpasswd -c /usr/local/etc/httpd/.htpasswd yourusername
    
  7. Restart Apache again:
  8. sudo brew services restart httpd
    

Conclusion

You’ve successfully installed phpMyAdmin on your macOS using Apache and PHP! Now, you can manage your MySQL databases easily through phpMyAdmin. If you face any issues, make sure all services are running correctly and double-check the configuration files.