It is a common practice and recommended way that you setup and test your site content locally on your computer or Mac before publishing it live on internet. MAMP is an application (both free and Pro versions are available) allows you to install Apache, PHP and MySQL on your local Mac OS X to develop WordPress sites.
MAMP stands for My Apache, MySQL and PHP.
This article explains the step by step process of installing WordPress on local Mac using MAMP. Below are the summary of steps involved:
- Installing MAMP on Mac
- Configuring MAMP Apache Server and Ports
- Creating Database using MAMP phpMyAdmin
- Installing WordPress on Mac
- Connect WordPress to Local Database
- Configure WordPress Login Details
- Launching MAMP and WordPress Dashboard
Step1 – Installing MAMP on Mac
Go to MAMP site and download the latest MAMP for Mac OS X.
Installer package will start downloading to your “Downloads” folder; once download is completed double click on the file to open the installer. Click on “Continue” button to proceed with each step of the installation. The standard install of this installer by default will install MAMP and 14 days free trail version of MAMP PRO. If you do not want MAMP Pro then deselect that option by clicking on “Customize” button when you reach “Installation Type” section.
Once installed successfully, you will see the following icons are added in your Launchpad.
Do not move MAMP out of the Applications folder or rename it once it is installed.
When you upgrade to new MAMP version, the old application will be renamed like “MAPM_Curent_Date_Time” and new application will be created with the name MAMP. All existing folders and files inside “htdocs” folder will be transferred to new MAMP folder hence you can just delete the your old installation “MAMP_Current_Date_Time” after upgrading.
Step2 – Configuring MAMP
Once installed successfully, launch MAMP from Launchpad or from application folder (/Applications/MAMP/MAMP). Click on the “Preferences…” button to configure MAMP for configuring local server’s access.
There are four settings available under preferences: Start/Stop, Ports, PHP and Web Server.
Set the actions to be carried when you start and stop MAMP. If you add a URL in the favorite link, there will be a “favorite link” tab appear when start page opens.
Choose your web server as Apache.
MAMP added NginX server as an experimental feature from version 3.0.6. Selecting NginX without appropriate configuration will results in a 502 – Bad Gateway error when you open you localhost site.
The document root is the place where all your HTML, PHP and image files are stored. Either you can use default document root “/Applications / MAMP / htdocs” or choose another location.
It is necessary to define ports in order to access server programs through network so that multiple programs can run on a same server. There are two options to set ports for Apache / MySQL servers in MAMP:
- Set Web & MySQL ports to 80 & 3306 – when you click on this button the following ports will be set:
Apace Port – 80
Nginx port – 80 (change this to some port other than 80)
MySQL Port – 3306
Since 80 is the commonly used port for internet access, if you save this settings you will be prompted to enter your Mac administrator password for starting and stopping Apache server. You can access your site with the URL as http://localhost. (This is the settings we use for our further discussion).
- Set MAMP ports to default – when you click on this button following ports will be set:
Apace Port – 8888
Nginx port – 7888
MySQL Port – 8889
If you use this settings then your local site to be accessed with the URL http://localhost:8888 and you do not need to enter password for starting and stopping server.
Choose the PHP version under PHP tab; the available versions depend on the version of your MAMP installation. (Here we choose the latest available version 5.6.2).
Caching is the option to speed up the execution of PHP codes and by default it is switched off. You can turn on to any available caching methods under drop-down.
Step3 – Creating Database for WordPress
Now that you have configured MAMP to access Apache and MySQL servers, launch MAMP and click on the “Start Server” option to launch servers. If you have selected “Start WebStart Page” under “Start/Stop” preference settings as explained above then start page will open by default. Or else click on “Open WebStart page” option in the MAMP screen or open the link http://localhost/phpMyAdmin/.
Under “Databases” tab enter database name and click on “Create” button to create a database. Remember the database name, this is the name you need to use for WordPress installation. You do not need to choose “Collation” option, which will be automatically assigned during WordPress installation.
Step4 – Installing WordPress on Mac
Go to wordpress.org site and download the latest WordPress version to your local Mac. Extracting this zipped file with the default Mac “Archive Utility” will create a folder named “wordpress”. Open this folder, copy all files/folders and paste them inside document root folder defined in MAMP preference settings under “Web Server” tab. By default the document root folder is “/Applications / MAMP / htdocs /” and paste all files/folders here.
If you paste the complete “wordpress” folder inside “htdocs” folder then you will be installing WordPress under a sub-directory called “wordpress” and your WordPress access URL should be http://localhost/wordpress.
If you copy and paste the content of “wordpress” folder then you are installing WordPress in root directory of “htdocs” and hence your WordPress access URL should be http://localhost.
Step5 – Connect WordPress to Local Database
Now that you setup MAMP servers, database and installed WordPress as well and guess what next? You need to connect WordPress installation to the MAMP MySQL database so that WordPress can save your content in that database tables. In order to do that, open “htdocs” folder in your Mac and locate “wp-config-sample.php” file. Right click on the file name, select “Duplicate” to create a copy of the file and change the name to “wp-config.php”. Open “wp-config.php” file and add the following details under MySQL settings section:
- Database name – Same name which you created in step3.
- User name – root
- Password – root
- Hostname – localhost
The code in “wp-config.php” file will be looking something like below:
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', Database name as you created in step3); /** MySQL database username */ define('DB_USER', 'root'); /** MySQL database password */ define('DB_PASSWORD', 'root'); /** MySQL hostname */ define('DB_HOST', 'localhost');
Edit “wp-config.php” file with simple text editor like “TextEdit” and do not use word processors like Pages or Word to avoid the quotes being changed to different style resulting in not able to open your WordPress site.
If you try to open your localhost URL without setting up “wp-config.php” file then you will see a message like below:
Click on the “Create a Configuration File” to create “wp-config.php” file by providing database details and then again click on “Run Install” button in the next screen to go to next step.
Step6 – Configure WordPress Login Details
Launch MAMP and start servers if not started automatically.
Open your localhost URL http://localhost (or http://localhost:8888) in Safari or any other browser. You will see a welcome screen from WordPress asking you to provide login details for WordPress admin dashboard.
Enter required details and click on “Install WordPress” button, you will be seeing a success message after completion of installation as below:
Open localhost URL in a browser to see the look of your new WordPress local site or click on “Log In” button to logon to your WordPress admin dashboard.
Step7 – Opening WordPress Admin Dashboard
Now you have setup everything and ready to build your WordPress site. Ensure you launched MAMP and Apache / My SQL servers are started successfully. The WebStart page will show you the success message and MySQL database details along with options to access your locally hosted site, favorite link and tools like phpMyAdmin.
Open WordPress admin URL http://localhost/wp-admin/ (or http://localhost:8888/wp-admin/), enter user name and password you have provided in step6 to login to WordPress admin dashboard.
WordPress admin dashboard provides you unlimited capabilities to start building your site.