Get DevWP - WordPress Development Theme
Local WordPress Development with MAMP for macOS

Local WordPress Development with MAMP for macOS


Why MAMP for macOS?

When it comes to developing WordPress themes locally on macOS, you have several options and it can be confusing which one to use. I’ve personally used most of the main options and consistently come back to using MAMP on macOS because of it’s simplicity, and its easy to configure to match my production server environment.


When on Windows I use XAMPP for local WordPress Development, but on macOS, MAMP just works the way I like it.

This article is part of a series of articles and videos dedicated to teaching people how to code their own custom WordPress Themes with DevWP.

Here are some resources:

When it comes to local WordPress development on macOS, MAMP is a popular choice among developers. MAMP provides a streamlined setup process for Apache, MySQL, and PHP, making it easy to create a local development environment. In this guide, we’ll walk you through the process of setting up MAMP and configuring it for optimal WordPress development.

Installation and Configuration

  1. Download MAMP from the official website.
  2. Run the installer and follow the installation wizard. Choose a suitable installation directory (e.g., /Applications/MAMP).
  3. Once the installation is complete, launch the MAMP application.

Determining Your Shell Environment

On macOS, the two most commonly used shells are Bash and Zsh. To find out which shell you’re using, run the following command in your terminal:

echo $0

To locate your shell executable, use these commands:

which bash
which zsh

You can open your shell configuration files with these commands:

open ~/.bash_profile
open ~/.zshrc

Adding PHP to Your Path

To ensure PHP is in your system path, follow these steps:

  1. Open your ~/.bash_profile or ~/.zshrc file with the commands above.
  2. Add the following line to the top of the file:
  3. export PATH=/Applications/MAMP/bin/php/php8.2.0/bin:$PATH

    Replace php8.2.0 with the actual PHP version you’re using.

  4. Apply the changes by running the appropriate command for your shell:
  5. source ~/.bash_profile
    source ~/.zshrc

To verify your PHP setup, use the following commands:

  • Check PHP version:
    php -v
  • Check PHP location:
    which php

Fine-tuning the PHP Configuration

To optimize your WordPress development environment, you can fine-tune the php.ini file. On macOS, the php.ini file is located at:

/Applications/MAMP/bin/php/php[version]/conf/php.ini

You can also find the location of your php.ini file by running:

php --ini

Open the php.ini file in your code editor and adjust the following settings:

memory_limit = 2048M
max_execution_time = 300
max_input_time = 240
post_max_size = 64M
upload_max_filesize = 64M

Ensure your system has enough resources to support these values.

Setting Up Document Root and URL

The document root is the directory where your WordPress installations will be located. By default, the document root for MAMP is /Applications/MAMP/htdocs.

This is where you’ll place your WordPress installations. Here are some examples:

  • /Applications/MAMP/htdocs/wordpress
  • /Applications/MAMP/htdocs/dev

MAMP’s default URL is http://localhost:8888. However, you can change it to http://localhost by modifying the Apache port settings in the MAMP preferences.

For example, if you have a WordPress installation in /Applications/MAMP/htdocs/wordpress, you can access it by visiting http://localhost/wordpress in your web browser.

Starting and Stopping MAMP Services

To start the MAMP services (Apache and MySQL), click on the “Start Servers” button in the MAMP control panel. You can also access the MAMP control panel by clicking on the MAMP icon in the menu bar and selecting “Preferences”.

To stop the services, click on the “Stop Servers” button in the control panel.

Troubleshooting

If you encounter any issues while setting up or using MAMP, here are a few common solutions:

  • Make sure you have the latest version of MAMP installed.
  • Ensure that no other web servers or services are conflicting with MAMP’s ports (e.g., Apache uses port 80 and MySQL uses port 3306).
  • Check the MAMP error logs located in /Applications/MAMP/logs for any specific error messages.
  • Verify that your firewall or antivirus software is not blocking MAMP.

If you’re still facing problems, consult the MAMP documentation or seek support from the MAMP community forums.

Conclusion

Setting up MAMP on macOS provides a powerful and flexible local development environment for WordPress. By following these steps, you’ll ensure that your setup is optimized and ready for developing high-quality WordPress themes.



View Our Themes