As a beginner in WordPress theme development, I understand the struggles that come with it. That’s why I want to share my experience with you and help you navigate through the process. In this article, I’ll be discussing the steps to install WordPress on a Mac and set up a multisite WordPress installation.
To begin, I recommend using MAMP (Mac Apache MySQL PHP) for local installations of WordPress on a Mac. You can download MAMP for free from their website and install it like any other program by dragging the folder into your applications folder.
Once you have MAMP installed, you’ll need to adjust your default MAMP settings. Open MAMP and click on the “Preferences” button. This will open a second screen where you can click on the “Ports” button to update the values selected. It’s recommended that you use 80 for your Apache Port and 330 for your MySQL Port.
Adjusting the ports will allow you to exclude the port number from your localhost URL and protect your local host respectively. While you’re in your preferences, you’ll also want to set your PHP to the latest version and choose a document root location for Apache.
Now it’s time to start up your servers and add a database. Open MAMP and click on “Start Servers.” You will see a welcome screen where you can click on phpMyAdmin. This will take you to a new screen where you can create a new database. Think about what you want to name your database and enter the name before clicking create.
With MAMP and your database set up, you’re now ready to download WordPress. WordPress is famous for its easy installation process. To start, download the latest version of WordPress from their site and double click to extract the folder. Open the “WordPress” folder and drag all of the other contents into your Applications/MAMP/htdocs folder.
Before you can complete the WordPress installation, there are two more steps you need to take. First, you need to edit your hosts file. Open Terminal and type “sudo nano /private/etc/hosts.” You’ll be prompted for your admin password, so enter it and hit enter. You’ll then be taken to a screen where you can use the down arrow to go to the bottom of the list and add (with a tab in between) “127.0.0.1 test.” Hit “control + x” to exit the menu and make sure to enter “Y” when asked to save your changes.
Next, you need to edit wp-config-sample.php. Go to MAMP/htdocs and rename the “wp-config-sample.php” file to “wp-config.php” and open it up. Edit the files using the name of the database you created as well as “root.” Save the file and go to your home directory (which should be http://whatever-your-database-name-is) and follow instructions to complete installation.
With WordPress installed locally, you can now set up a multisite WordPress installation. Multisite is a great functionality you’ll want to use with your localhost when developing WordPress themes. This way you can create many test site environments where you can immediately see changes you make to your themes without having to use a live site.
To enable multisite, you need to show hidden files by entering the following code in Terminal: “defaults write com.apple.Finder AppleShowAllFiles true” and “killall Finder.” This resets Finder to show all of your hidden files, including the .htaccess file which we’ll be editing.
Open up your wp-config.php file again and add in the following code to turn on WordPress’ step-by-step instructions for adding multisite:
Make sure your MAMP servers are running and login to your localhost site. Under tools, there should be a network option where you can choose to use sub-directories or sub-domains and continue with network setup. The next page should ask you to add a site name and admin email. Click install and let WordPress work its magic.
You’ll then be presented with a screen where you can continue to follow the directions. Open up the wp-config.php file and paste in the related code, and do the same with the .htaccess file.
Now all you have to do is log back into your WordPress dashboard and go to “My Sites,” network admin, and then sites to add new ones. From here, you can add your desired site name, title, and admin email.
With a multisite WordPress installation set up, you can now install any network-enabled themes on your new site(s) for testing. Create as many or as few sites as you’d like and get developing!