How to install WordPress on MacOS – Step by Step

Categories: Code, Technology

0. Install the web server of your choice (apache, nginx, etc.), in this guide we’ll be working with Nginx

To install Nginx on MacOS, follow this guide:

How to install Nginx on MacOS

1. Install and Configure MySql via Homebrew

To install MySQL and configure MySQL on MacOS, follow this guide:

How to install MySQL on MacOS

2. Download WordPress

Navigate to the following link to obtain a copy of WordPress CMS:

Download latest WordPress here

3. Install and Start PHP

First, check if PHP is already installed using the following command in your terminal:

php -v

If the output is something along the lines of “Command not found”, proceed with installing php via homebrew using the following command:

brew install php
php -v

Start PHP service and then ensure PHP has started:

brew services start php
brew services list

You should see something like this:

Name    Status  User  File
mysql   none          
nginx   none          
php     started ilias ~/Library/LaunchAgents/homebrew.mxcl.php.plist
unbound none 

4. Move the WordPress Directory

Move the WordPress directory that was downloaded to:
/opt/homebrew/var/www/wordpress

5. Modify nginx.conf

Use the following command to modify the nginx.conf file:

nano /opt/homebrew/etc/nginx/nginx.conf

Modify the `location /` block that’s nested under the `server` block to look like this, commenting out or removing root and index keys (in this case I’ve commented them out):

location / {
        #    root   html;
        #    index  index.html index.htm;
        try_files $uri $uri/ /index.php?$args;  # Redirect to index.php if file isn't found
       }

Add the following block under the `location /` block, to handle PHP processing:

# Handle PHP processing
   location ~ \.php$ {
                include fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;  # Or the path to your PHP-FPM socket (e.g., /opt/etc/php/php7.4-fpm.sock)
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

Hit `Control + X` and then `Y` to confirm changes to the nginx.conf file.

6. Restart Nginx for Changes to Take Effect

You may have to run the nginx command as root, using `sudo`

nginx -s stop
nginx

7. Test the Installation

In your browser, navigate to:
http://localhost:8080 (or simply http://localhost if your Nginx server runs on port 80)

You should be presented with the following page. Choose the language and hit Continue.

8. Configure WordPress

Fill out this form:

You may be facing this issue.

Open your terminal back up and type in the following (without comments) and then hit Try Again in the browser page.

mysql -u root -p # Hit the Enter key
# Enter your password
CREATE DATABASE wordpress_local # Or whatever else you've named your database in the previous step

If it worked, you’ll see the following page. Hit the Run the installation button.

From here on, the rest of the steps are self explanatory, meaning that you’re on your way!

If you run into issues, feel free to leave a comment and I’ll do my best to help.




«
»

    Leave a Reply

    Your email address will not be published. Required fields are marked *