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.
- Open Terminal.
- Run the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- After installation, update Homebrew:
brew update
Step 2: Install PHP
Once Homebrew is installed, you can easily install PHP.
- Run the following command:
brew install php
- Verify the PHP installation:
php -v
Step 3: Install MariaDB
MariaDB is a popular database server used as an alternative to MySQL.
- Install MariaDB:
brew install mariadb
- Start the MariaDB service:
brew services start mariadb
- Secure your MariaDB installation:
mysql_secure_installation
Step 4: Install phpMyAdmin
phpMyAdmin is a web interface for managing databases.
- Install phpMyAdmin:
brew install phpmyadmin
- 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.
- Locate the phpMyAdmin directory, typically
- Restart your web server:
sudo apachectl restart
Step 5: Verify Setup
- Open your browser and navigate to
http://localhost/phpmyadmin
. - 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)