Contents
Installing WordPress on macOS with MAMP
Deploying a local WordPress environment on macOS using MAMP is an excellent way to develop, test and experiment with themes and plugins before going live. MAMP provides a preconfigured Apache, MySQL and PHP stack, simplifying the setup process. This guide offers a comprehensive, step-by-step approach, from initial installation through troubleshooting and security best practices.
Table of Contents
- Prerequisites
- Downloading and Installing MAMP
- Configuring MAMP
- Creating a MySQL Database
- Downloading and Setting Up WordPress
- Running the WordPress Installer
- Troubleshooting Common Issues
- Security Best Practices
- Conclusion
1. Prerequisites
Before you begin, ensure your system meets the following requirements:
- macOS version: 10.13 (High Sierra) or later recommended.
- Free disk space: At least 500 MB for basic WordPress files, plus space for backups and media.
- Administrator access: You must be able to install applications and modify system configurations.
- Internet connection: To download MAMP and WordPress.
2. Downloading and Installing MAMP
MAMP bundles Apache, MySQL and PHP in one package. Follow these steps:
- Visit the official MAMP website at https://www.mamp.info/en/.
- Click Download to get the latest MAMP MAMP PRO package. (The free MAMP version suffices for local development.)
- Open the downloaded .pkg file and follow on-screen instructions:
- Accept the license agreement.
- Select the default installation directory (
/Applications/MAMP
). - Authenticate with your macOS credentials.
- After installation, open the MAMP application from
/Applications/MAMP/MAMP.app
.
3. Configuring MAMP
Adjust server settings to optimize your local environment:
Setting | Recommendation |
---|---|
Apache Port | 80 (requires sudo privileges) or 8888 (default) |
MySQL Port | 3306 (standard) |
Document Root | /Applications/MAMP/htdocs |
PHP Version | Use the latest stable (e.g., PHP 7.4 or 8.0 ) |
To change these, click Preferences in the MAMP window, then navigate to Ports and PHP tabs.
4. Creating a MySQL Database
WordPress requires a MySQL/MariaDB database. Create one via phpMyAdmin:
- Start MAMP servers by clicking Start Servers.
- Click Open WebStart page, then phpMyAdmin in the left menu.
- In phpMyAdmin, click Databases. Under Create database, enter:
- Database name:
wordpress_db
(or your preferred name) - Collation:
utf8mb4_unicode_ci
- Database name:
- Click Create. Note the database name for later.
5. Downloading and Setting Up WordPress
Get the latest WordPress package and prepare your project folder:
- Download WordPress from the official site: https://wordpress.org/download/.
- Unzip the wordpress-x.x.x.zip file.
- Rename the extracted folder to
mywp
(or a name of your choice). - Move
mywp
into/Applications/MAMP/htdocs
.
Directory structure example:
/Applications/MAMP/htdocs/ └── mywp/ ├── wp-admin/ ├── wp-content/ ├── wp-includes/ └── index.php
6. Running the WordPress Installer
Now connect WordPress to your database and complete the setup:
- Open a browser and navigate to:
http://localhost:8888/mywp/
(orhttp://localhost/mywp/
if Apache is on port 80). - Select your language and proceed.
- On the database setup screen, enter:
- Database Name:
wordpress_db
- Username:
root
- Password:
root
(default for MAMP) - Database Host:
localhost
- Table Prefix:
wp_
(change for security if desired)
- Database Name:
- Click Submit, then Run the installation.
- Fill in site details:
- Site Title: e.g., My Local WordPress
- Username: choose a secure admin username
- Password: strong and unique
- Your Email: valid address
- Click Install WordPress. Upon success, click Log In.
7. Troubleshooting Common Issues
- Error Establishing a Database Connection: Verify database credentials in
wp-config.php
. - 404 Not Found: Check the document root path and URL port number.
- Port Conflict: If Apache or MySQL fails to start, change their ports under MAMP Preferences → Ports.
- PHP Version Mismatch: Ensure WordPress supports the selected PHP version switch in MAMP’s PHP tab.
8. Security Best Practices
Even for a local environment, following security measures can prevent bad habits when migrating to production:
- Change the default MySQL
root
password via phpMyAdmin. - Set a non-standard table prefix in
wp-config.php
(e.g.,wp_ab12_
). - Use strong, unique passwords and consider a password manager.
- Disable file editing in the dashboard by adding
define(DISALLOW_FILE_EDIT, true)
towp-config.php
. - Regularly back up your local database and
wp-content
folder.
9. Conclusion
Setting up WordPress on macOS with MAMP is straightforward and provides a fully functional development environment. You’ve learned how to install MAMP, configure ports, create a database, install WordPress and follow essential security practices. With this local setup, you can build and test sites quickly, ensuring a smooth transition to live servers.
For further reading and official documentation, refer to:
© Your Name or Company. All rights reserved.
|
Acepto donaciones de BAT's mediante el navegador Brave 🙂 |