Wordpress Local Mamp



MAMP is an application you can install on your Mac or Windows PC that allows you to have access to a local server that is running PHP and MySQL. Essentially, MAMP gives you all of the tools you need to run WordPress on your machine, for development and testing purposes. To install MAMP, go to https://www.mamp.info/en/downloads/. In this post, we will learn how to run WordPress locally on your Mac using MAMP. MAMP stands for Mac, Apache, MySQL, and PHP. It provides the full stack you need to quickly get your development site running locally so you can start working on your WordPress site. To get started, download MAMP from the website. Then run the installer. MAMP is an application you can install on your Mac which allows you to have access to a local PHP server and MySQL server. Essentially, MAMP gives you all of the tools you need to run WordPress on your machine, for development and testing purposes.

Topics

  • Other WordPress Development Tools

Getting WordPress installed on your own computer, as if your computer was a webhost’s server, is easy on a Mac with MAMP. If you are on a Windows PC you can use XAMPP. Setting up MAMP and installing WordPress. The following video shows you how to install WordPress on your Mac using MAMP. This can be done in 5 minutes. If you're looking to code with PHP or become a WordPress Developer, then you're going to need a local web server like MAMP. MAMP is one of the most popular l.

Why set up a development environment? Why set up a development environment?

When developing themes, it is best to do it in an environment identical to the production server which will eventually host your WordPress installation. Your development environment can either be local or remote. Configuring a local environment to work on your WordPress theme is beneficial for several reasons:

  • You can build your theme locally without relying on a remote server. This speeds up your development process and allows you to see changes instantly in your browser.
  • You do not need an Internet connection to build your theme.
  • You can test your theme from a variety of perspectives. This is important, especially if you plan on releasing your theme to a larger audience and want to ensure maximum compatibility.

Your WordPress local development environment Your WordPress local development environment

For developing WordPress themes, you need to set up a development environment suited to WordPress. To get started, you will need a local server stack and a text editor. There are a number of options, including:

Local Server Stack

  • A local server stack, such as LAMP (Linux Apache MySQL/MariaDB PHP) or WAMP (Windows Apache MySQL/MariaDB PHP) is a server (much like the server that runs on your web server), which you will configure on your local machine. You can install pre-bundled programs that contain all of these, like MAMP (for Mac), or XAMPP (Mac or Windows) to quickly setup your environment.

Virtualized Environment

Wordpress Local Mamp
  • A virtualized such created with Vagrant and VirtualBox allows you to create easily reproducible development environments. Varying Vagrant Vagrants (VVV) is a popular Vagrant option which creates a WordPress development environment.

Text Editor

In addition to a local server environment, you also need a text editor to write your code. Your choice of text editor is personal, but remember that a good text editor can speed up your development process. Your text editor can be everything from a basic tool for writing code to a fully integrated development environment (IDE) with tools for debugging and testing. It’s worth doing research, and some even include support for WordPress development. Popular choices are Atom, Sublime Text, and PhpStorm.

You can find a list of tutorials for setting up development environments at the bottom of the page.

Supporting older versions of WordPress Supporting older versions of WordPress

It’s standard practice for WordPress themes to support at least two versions back to ensure a minimum of backward compatibility. For example, if the current version of WordPress is at 4.6, then you should also make sure that your theme works well in versions 4.5 and 4.4 as well.

You can refer to the WordPress Releases page to access older versions of WordPress. Then you can download and install older WordPress versions, creating multiple development sites, each running different WordPress versions for testing.

WP_DEBUG WP_DEBUG

Configuring debugging is an essential part of WordPress theme development. WordPress provides a number of constants to support your debugging efforts. These includes:

WP_DEBUG

The WP_DEBUG PHP constant is used to trigger the built-in “debug” mode on your WordPress installation. This allows you to view errors in your theme. To enable it:

1. Open your WordPress installation’s wp-config.php file

2. Change:


to

Note: While normally set to ‘false’ in the wp-config.php file, development copies of WordPress—alpha and beta versions of the upcoming release—WP_DEBUG is already set to ‘true’ by default.

WP_DEBUG_DISPLAY and WP_DEBUG_LOG

WP_DEBUG_LOG and WP_DEBUG_DISPLAY are additional PHP constants which extend WP_DEBUG.

WP_DEBUG_LOG is used in conjunction with WP_DEBUG to log all error messages to a debug.log within your WordPress /wp-content/ directory. To enable this functionality set WP_DEBUG_LOG to true within your wp-config.php file.

WP_DEBUG_DISPLAY is used to control whether debug messages display within the HTML of your theme pages. To display error messages on the screen as they occur, configure this setting to ‘true’ within your wp-config.php file.

With the WP_DEBUG and WP_DEBUG_DISPLAY enabled, error messages will display at the top of your site pages.

Note: Errors will display in the frontend and admin areas of your site. These debug tools are meant for local testing and staging installs, not for live sites.

Other WordPress Development Tools Other WordPress Development Tools

In addition to WP_DEBUG, the following plugins and unit test data sets are an important part of your development toolset and help you develop better WordPress themes.

Test DataTest Data

WordPress.org Theme Unit Test Data

WordPress.org Theme Unit Test Data is an XML file containing dummy test data that you can upload to test how themes perform with different types and layouts of content.

WordPress.com Theme Unit Test Data

WordPress.com Theme Unit Test Data is dummy test data that you can upload to a WordPress installation to test your theme, including WordPress.com-specific features.

PluginsPlugins

Debug Bar(WordPress plugin)

Debug Bar adds an admin bar to your WordPress admin providing a central location for debugging.

Query Monitor(WordPress plugin)

Query Monitor allows debugging of database queries, API request and AJAX called used to generate theme pages and theme functionality.

Log Deprecated Notices(WordPress plugin)

Log Deprecated Notices logs incorrect function usage and the use of deprecated files and functions in your WordPress theme.

Monster Widgets(WordPress plugin)

Monster Widget consolidates the core WordPress widgets into a single widget allowing you to test widgets styling and functionality in your theme.

Wordpress Local Mamp

Developer (WordPress plugin)

Developer helps optimize your development environment by allowing easy installation of tools and plugins that help in troubleshooting and ensuring code quality.

Theme-Check (WordPress plugin)

Theme-Checktests your theme for compliance with the latest WordPress standards and practices.

WordPress Theme Review Guidelines WordPress Theme Review Guidelines

In addition to the above development tools, it’s a good idea to stay up to date on the WordPress.org Theme Review Team’s Guidelines for theme submission and guidance on meeting WordPress Coding Standards. These guidelines are the “gold standard” for quality theme development and are useful, even if you don’t plan on releasing a theme on WordPress.org.

Further Resources Further Resources

  • Developing WordPress Locally With MAMP (Mac, MAMP)
  • How to Setup a WordPress Development Environment for Windows (Windows, XAMPP)
  • WordPress Theme Review VVV: A Quick Vagrant Setup for Testing Themes (Cross-platform, Vagrant)
  • Setting up your Development Environment (WordPress.com VIP)
  • wptest.io – an exhaustive set of WordPress test data derived from WordPress’ Theme Unit Test

In this lesson, you will learn how to install WordPress locally on your own computer.

Prerequisite Skills

Participants will get the most from this lesson if they have familiarity with:

  • Experience downloading and installing programs on their computer.
  • Administrative access to their local machine.
  • Familiarity with the file system of their computer.

Objectives

After completing this lesson, participants will be able to:

  • Download, install and configure MAMP.
  • Start MAMP servers.
  • Create a database.
  • Download and install WordPress.

Materials Needed

Screening Questions

  • Have you ever used WordPress?
  • Have you created posts and pages in WordPress?
  • Have you changed a theme in WordPress?
  • Have you ever wanted to look under the hood of WordPress?

Notes for the Instructor

  • Ahead of the lesson, make sure you take a look at your own computer setup. If you have MAMP or MAMP Pro already installed on your machine, you may want to run this demo on a virtual box to avoid conflicts with existing software and local sites that you may want to keep on your machine.
  • Sometimes it can take a while to download large files like MAMP or WordPress core. You may want to have a copy of MAMP and the current version of WordPress downloaded and stored on a thumb drive that can be passed around the class before you start the lesson. In the context of the demo, you would still show where to download these files but would skip the actual live download.
  • MAMP is updated quite often. Please be sure to walk through the lesson plan with a fresh install to be sure it is still up to date.

Lesson Overview

To run WordPress locally, you need to have a server. In this lesson, you will learn to set up a server, create a database and install WordPress on your computer.

Install MAMP

MAMP stands for My Apache, MySQL, and PHP. MAMP is an application you can install on your Mac or Windows PC that allows you to have access to a local server that is running PHP and MySQL. Essentially, MAMP gives you all of the tools you need to run WordPress on your machine, for development and testing purposes.

  1. To install MAMP, go to https://www.mamp.info/en/downloads/.
  2. Download the version of MAMP that corresponds with your machine (Mac OS X or Windows).
  3. Double click on the downloaded file. This will open the installation dialog.
  4. Next, we’ll follow the prompts in the dialog to complete the installation. This course uses the default settings recommended by the install dialog.

Open and configure MAMP

  1. Now that MAMP is installed, let’s open it up! MAMP has a button to start servers when first started. By clicking on “Preferences” you can select an option to start the Apache HTTP Server and MySQL database server upon starting MAMP.
  1. Click on the “preferences” icon. You’ll see that there are several tabbed menu items available.
  2. Click the “Web Server” tab and find the “Document Root.” This path is where MAMP expects to find the files associated with your local website. In this case, this is where the WordPress files will need to be located to run them on the server. You may change this directory to whatever you want. The default is “/Applications/MAMP/htdocs” on a Mac and “C:/MAMP” on Windows.

Set up a Database

  1. Next, we will create a database on your new MAMP server. This database will become the database for the locally installed WordPress site.
  1. Go back to the MAMP dialog and click “Start.”
  1. Using the menu bar at the top of the page, click “Tools -> phpMyAdmin.”
Wordpress
  1. The phpMyAdmin dialog will appear.
  1. Click the “New” link in the left menu sidebar.In the following dialog, use the name “mydatabase” to name the database:
  1. Leave the “Collation” option as default.
  2. You now have a database called “mydatabase.” Congratulations!

Install WordPress

  1. Now we’re ready to install WordPress on our local machine! Go to https://wordpress.org/download/ to download the most recent version of WordPress. Once you download and copy the WordPress files to your computer, you will be able to install WordPress using the traditional 5 Minute Install.
  1. Move the downloaded zip file to the default server directory, “/Applications/MAMP/htdocs.” You could expand the zip file in your downloads folder and move the expanded folder and its contents, but sometimes the “hidden” system files that are included in WordPress (like the .htaccess file) fail to copy over to new folders if the contents are unzipped. For that reason, we’ll leave our zip file zipped while we’re moving it.
  1. In the new”/Applications/MAMP/htdocs” location, double click the WordPress zip file and it will expand. Remove the zip file and the index.php file.
  1. Go back to your web browser, and in the black menu bar, click the link “My Website.”
  1. The link will take you to a list of websites installed in the directory. Click the “WordPress” link. This link will take you to the 5 minute WordPress install.
  1. Get ready to enter your database information:
  • Your “Database Name” is: mydatabase
  • Your “User Name” is: root
  • Your “Password” is: root
  • Your “Database Host” is: localhost
  • You can leave the “Table Prefix” as the default: wp_
  1. Now, let’s click the “Submit” button to run the install.
  1. Click the “Run the install button” and then choose a username and password on the next screen. That’s it! You’re ready to log in!
  2. The link for your new site: http://localhost:8888/wordpress/. You will log in at this URL: http://localhost:8888/wordpress/wp-login.php.

Exercises

The following exercises reinforce the skills needed to install WordPress locally:

Practice Using phpMyAdmin

Installing Wordpress On Mamp

  • Navigate back to phpMyAdmin on your localhost.
  • Click on the name of your database to view the contents of your database now that you have installed WordPress.
  • When looking at the database tables, scroll to the bottom of the page and click the “check all” box. Then in the dropdown that says “With Selected” choose “Export” and follow the prompts to practice backing up your database.
  • Practice making a new database within phpMyAdmin.

Try Installing a Second WordPress Local Site

Go through the exercise demonstrated in this lesson again and try setting up a second instance of WordPress on your local machine in a new location.

  • Make sure the document root matches wherever you’ll keep your files for the second instance of WordPress.
  • Set up a new database using phpMyAdmin.
  • Extract the WordPress files in a new location on your computer.
  • Run the famous 5 minutes install for your new local site.

Assessment

What does “MAMP” stand for?

  1. My Computer, Apple, MySQL, PHP
  2. My Computer, Apache, MySQL, PHP
  3. My Apache, MySQL, PHP
  4. Macintosh, Apple, MySQL, PHP

Answer: 3. Macintosh, Apache, MySQL, PHP

What is the user name and password for any named local install?

  1. username: root; password: localhost
  2. username: localhost; password: localhost
  3. username: root; password: root
  4. username: localhost; password: root

Answer: 3. username: root; password: root

What systems can MAMP run on?

  1. Macintosh
  2. Windows
  3. Macintosh and Windows
  4. Linux
  5. Macintosh, Windows and Linux

Wordpress Local Xampp

Answer: 3. Macintosh and Windows

Additional Resources

Free Mamp

  • WordPress Installation Techniques @ Codex