Develop Wordpress Locally Mac

broken image


  • 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.
  • 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.

There was a time when getting a WordPress-friendly local development environment working was an arduous job reserved for masochists, command line wizards, or both. These days, fortunately, it's a relatively straightforward task, and the basic setup is beginning to rival the speed of WordPress' own famous 5-Minute Install.

Welcome to the how to install WordPress on localhost mac guide! But before we get into the actual steps, it makes sense to give a brief explanation of why would we want to install WordPress locally in the first place.

To begin with, installing WordPress locally means downloading the CMS (Content Management System [Wordpress]) to your computer and working with it there… locally. If you are a web developer, you know really well why we do it, but if you're not, you may be scratching your head and thinking to yourself – 'why?' Well, there are two main reasons.

Download our FREE guide >>>7 SMART STRATEGIES TO GROW YOUR BLOG TRAFFIC FASTER!<<<

One of my friends recently wanted to start his own blog, but because he was low on money, he could not afford to pay for a domain name and a hosting plan just yet. Nonetheless, he was eager to learn how to use WordPress. As a result, I told him that we can install it on his computer and he can start picking a theme and making tweaks right away.

The nice part is that you can do pretty much all of the same things on a local version of WordPress as you would be doing on an online one.

So, I told my friend, by the time he buys a domain name and a hosting plan, he will already know how to use the CMS. This was the first reason why you would want to install WordPress locally.

The second reason is, of course, the development itself.

Recommended:

Potentially, any change that you do, whether it is updating your blog, tweaking the code or even installing a new plugin, can break your website. Obviously, we don't want our precious visitors coming to a website that looks like a white blank page. Yes, in most cases these things can be easily fixed. or not. but either way, we want our blog up and running flawlessly 24/7.

In other words, the procedure should be the following: you first do the needed changes on your local version, and if everything looks ok and isn't broken, you drag those changes to your live version. As simple as that.

Now, let's get to the part that you actually came here for! 💪

How to Install WordPress on Localhost Mac

1. Download and install MAMP

So what is MAMP?

The thing is that when you own a website online, you have a hosting provider that hosts your website on their server. You need a server for your website to work. However, even if you have a website running locally on your computer, you still need a server for it to work. This is where MAMP comes into play. MAMP creates a virtual server for your website on your computer.

Recommended hosting provider: Bluehost

Go to: https://www.mamp.info/en/downloads/and pick the version for a MAC.

P.S. If you have a Windows computer, installing WordPress works a little differently. I would recommend that you download XAMPP instead of MAMP.

Once you have downloaded the file, install MAMP.

2. Download WordPress.org

Now that you have MAMP downloaded, time to download WordPress.org.

Note: you go to WordPress.ORG, not WordPress.COM. WordPress.com is a whole different story, we don't want that!

Go here: https://wordpress.org/download/

3. Find a place for your WordPress folder

Now that you have downloaded the WordPress zip file, time to unzip it and place the folder somewhere on your computer.

It is important to find a place on your computer where the WordPress folder will not be moved from because MAMP will be linking to it. In other words, I would not recommend having it on the desktop. The Documents folder on your MAC is a decent place for it.

4. Configure MAMP

Time to configure your MAMP application.

Open MAMP. Once MAMP has been started, in the upper left corner of your monitor, where the Apple logo is located, you will see the word 'MAMP'. Click on it and choose 'Preferences'.

You will see a little screen open up. Choose the 'Ports' tab and click on 'Set Web & MySQL ports to 80 & 3306'.

The next step is to choose the 'Web Server' tab. Click on 'Select' and search for the WordPress folder that you relocated in step #3. In my case, my WordPress folder is in my Documents, so that is where MAMP should be pointing to as well. This is how it looks like for me:

That's it, click on OK.

5. SQL Database

Now it's time to configure the database of your local WordPress website.

Open MAMP and click on 'Start Servers'.

Note: If you get the following error: Apache couldn't be started. Please check your MAMP installation and configuration., then it might be so that you have to change the ports again. Simply go back to: Preferences -> Ports -> and replace both of the '80' values with '8080'. Click on 'Start Servers' again.

If your server has been started successfully, you should see a page open in your browser. At the top menu, you will see 'TOOLS'. Click on it and pick 'PHPMYADMIN'.

Then, on the left side, you should see the word 'New'. Click on it and give it a name. Give it a name that can be relatable to your future website. In my case, I called it Demo, since this is a demo tutorial.

Recommended:

6. Final step – Install WordPress

This is the final step of the 'how to install WordPress on localhost mac' guide.

You can now close this page and return to the browser page that was previously automatically opened. There, click on 'MY WEBSITE' in the top menu. Alternatively, you can click here if you used the 8080 port. http://localhost:8080/MAMP/?language=English

You will be taken to your WordPress website. Now we need to configure it.

Pick your language.

For Database Name, enter the name that you previously gave to your new database inside of the phpMyAdmin page. In my case it was demo.

Username and Password need to be 'root'. That is the default value.

Click Submit.

This is what my database connection details screen looks like:

Run the installation.

In the next screen, you will be asked to enter the title of your new website, the username, password, etc. Here, the only things that matter are the username and password. You will need those to log in. Everything else can be changed later and is not really important for a website that is not on the internet.

Once you fill in all the fields, you can proceed to log into your WordPress website.

And voilà!! That was it! Easy, isn't it? 🙂

Download our FREE guide >>>7 SMART STRATEGIES TO GROW YOUR BLOG TRAFFIC FASTER!<<<

Now you are free to play around with WordPress, test out various plugins (some may not work properly because they are meant to be used online), themes and even tweak the code that is located inside your WordPress folder.

NOTE #1: In order for your local version to work, you need to have MAMP running all the time. This means that if you have stopped the servers at some point, you need to open MAMP and click on 'Start Servers' again.

NOTE #2: If you used port 80 in your MAMP preferences, that means you can find your website simply by typing 'localhost' in the browser search bar. However, if you used some other port (8080 in my case), then you need to type – 'localhost:8080 Visual studio for mac tutorial. ' (replace 8080 with the port that you picked).

To log into your WordPress admin screen, type either 'localhost/wp-admin/' or 'localhost:8080/wp-admin/' if you had some other port.

Available

I hope you found this post 'Why and How to Install WordPress on Localhost Mac – Full Guide' useful. If you have any other questions for me about WordPress, feel free to leave them in the comment section below. I will be sure to reply. 🙂

Thank you for stopping by and good luck!

Please click below to subscribe and to follow us on social media:

Click here to follow us via E-mail!
Click here to follow us on Facebook!
Click here to follow us on YouTube!
Click here to follow us on Instagram!
Click here to follow us on Twitter!
Click here to join our Facebook group!

5/5(1 vote )

This is a guide on how to set up Laravel Valet on macOS for a WordPress local development environment. Using Valet as a WordPress local development solution has the main benefits of speed, being lightweight and using fewer configurations to go wrong than say a solution like Vagrant.

There is a 2nd related article that looks at getting WordPress themes, plugins and settings already installed and ready to deploy.

Valet runs only on macOS and runs directly on top of the operating system, not in a virtual container.

The key software components needed are Homebrew; a package manager and Laravel; a PHP framework.

Valet itself has an Nginx, PHP 7.3 and DnsMasq and by default uses the .test domain name, you add in a database MariaDB or MySQL. Once the software is all installed Valet itself will launch automatically on startup of macOS.

Set Up Local Development Environment

Install Homebrew

First up is to install Homebrew so the key parts of the web stack such as PHP and MySQL/MariaDB can get installed easily.

This will install the Homebrew package manager and Xcode command line tools if not already installed.

Install composer with Homebrew

Get PHP and MySQL set up

Install PHP

For the database you can choose between MariaDB and MySQL and which version of MySQL, since version 8 is not supported at a number of hosting panels, version 5.7 maybe safer – otherwise drop the @5.7 suffix. For mariaDB I would use 10.3 as 10.4 has some root password changes.

Also if you are using a version of the app using @10.3 etc, after install you need to add the path to your shell as it is an older Homebrew formula, you are remonded of this at the shell prompt after Homebrew installs – example below of path with mariaDB path in .bash_profile

Install MySQL/MariaDB – background service works after restart

or…

Start it as background service

MySQL/MariaDB installs as user root with no password.

Get Laravel Valet set up

Install Valet with composer

Make sure your macOS shell path has the following location, this will allow you to easily use valet commands on the command line – if you don't include it you will need to prefix all valet commands with ~/.composer/vendor/bin/

Install valet

Now it will install dnsmasq and set up Nginx and PHP and start valet, some basic valet commands below…

Do a ping test to a fictitious domain, look for some pingbacks from 127.0.0.1

A responding ping will verify dnsmasq and the other components have been successfully set up.

Confirm you have dnsmaq, mysql, Nginx and php running…

Develop Wordpress Locally Mac Os

Output should be…

To update Laravel Valet

Webroot & park

Vsdx file open. Probably the best method for a webroot directory is to use the Sites folder in your home, this was a traditional webroot in the past of the macOS user account filing system – if one is not there either make one in the Finder or via the Terminal

Develop Wordpress Locally Mac Login

Register the Sites folder with Valet, so any top level folders will be treated as a serving site – use the park command

There is also a valet link command that allows a directory somewhere else in the filing system to serve its content as a webroot, it does so by putting a symbolic link in the park directory – Sites.

WordPress and Valet

So the best code to serve up ready made WordPress sites is wp-cli-valet-command it can spin up sites very quickly and can be further enhanced taking advantage of bash scripting.

First of all, you need to have wp-cli installed, use Homebrew to install or manually this guide can cover that process.

Increase your PHP memory size, especially if you installed PHP with Homebrew – otherwise, a fatal error will occur when installing wp-cli-valet-command package, find your PHP memory limits .ini config file

Change limits to 2048M in all 3 places

Also, make sure your MySQL or mariadb is running…

Once you have wp-cli add the wp-cli-valet-command package

Once this is installed you are ready to create some WordPress sites…

To install a new site, move into your Sites folder and run a wp valet command

This will set up https://newsitename.test ready to go WP-Admin defaults are admin/admin for username and password.

All new sites are by default set up with https – to set one up just as http – run…

Wordpress

I hope you found this post 'Why and How to Install WordPress on Localhost Mac – Full Guide' useful. If you have any other questions for me about WordPress, feel free to leave them in the comment section below. I will be sure to reply. 🙂

Thank you for stopping by and good luck!

Please click below to subscribe and to follow us on social media:

Click here to follow us via E-mail!
Click here to follow us on Facebook!
Click here to follow us on YouTube!
Click here to follow us on Instagram!
Click here to follow us on Twitter!
Click here to join our Facebook group!

5/5(1 vote )

This is a guide on how to set up Laravel Valet on macOS for a WordPress local development environment. Using Valet as a WordPress local development solution has the main benefits of speed, being lightweight and using fewer configurations to go wrong than say a solution like Vagrant.

There is a 2nd related article that looks at getting WordPress themes, plugins and settings already installed and ready to deploy.

Valet runs only on macOS and runs directly on top of the operating system, not in a virtual container.

The key software components needed are Homebrew; a package manager and Laravel; a PHP framework.

Valet itself has an Nginx, PHP 7.3 and DnsMasq and by default uses the .test domain name, you add in a database MariaDB or MySQL. Once the software is all installed Valet itself will launch automatically on startup of macOS.

Set Up Local Development Environment

Install Homebrew

First up is to install Homebrew so the key parts of the web stack such as PHP and MySQL/MariaDB can get installed easily.

This will install the Homebrew package manager and Xcode command line tools if not already installed.

Install composer with Homebrew

Get PHP and MySQL set up

Install PHP

For the database you can choose between MariaDB and MySQL and which version of MySQL, since version 8 is not supported at a number of hosting panels, version 5.7 maybe safer – otherwise drop the @5.7 suffix. For mariaDB I would use 10.3 as 10.4 has some root password changes.

Also if you are using a version of the app using @10.3 etc, after install you need to add the path to your shell as it is an older Homebrew formula, you are remonded of this at the shell prompt after Homebrew installs – example below of path with mariaDB path in .bash_profile

Install MySQL/MariaDB – background service works after restart

or…

Start it as background service

MySQL/MariaDB installs as user root with no password.

Get Laravel Valet set up

Install Valet with composer

Make sure your macOS shell path has the following location, this will allow you to easily use valet commands on the command line – if you don't include it you will need to prefix all valet commands with ~/.composer/vendor/bin/

Install valet

Now it will install dnsmasq and set up Nginx and PHP and start valet, some basic valet commands below…

Do a ping test to a fictitious domain, look for some pingbacks from 127.0.0.1

A responding ping will verify dnsmasq and the other components have been successfully set up.

Confirm you have dnsmaq, mysql, Nginx and php running…

Develop Wordpress Locally Mac Os

Output should be…

To update Laravel Valet

Webroot & park

Vsdx file open. Probably the best method for a webroot directory is to use the Sites folder in your home, this was a traditional webroot in the past of the macOS user account filing system – if one is not there either make one in the Finder or via the Terminal

Develop Wordpress Locally Mac Login

Register the Sites folder with Valet, so any top level folders will be treated as a serving site – use the park command

There is also a valet link command that allows a directory somewhere else in the filing system to serve its content as a webroot, it does so by putting a symbolic link in the park directory – Sites.

WordPress and Valet

So the best code to serve up ready made WordPress sites is wp-cli-valet-command it can spin up sites very quickly and can be further enhanced taking advantage of bash scripting.

First of all, you need to have wp-cli installed, use Homebrew to install or manually this guide can cover that process.

Increase your PHP memory size, especially if you installed PHP with Homebrew – otherwise, a fatal error will occur when installing wp-cli-valet-command package, find your PHP memory limits .ini config file

Change limits to 2048M in all 3 places

Also, make sure your MySQL or mariadb is running…

Once you have wp-cli add the wp-cli-valet-command package

Once this is installed you are ready to create some WordPress sites…

To install a new site, move into your Sites folder and run a wp valet command

This will set up https://newsitename.test ready to go WP-Admin defaults are admin/admin for username and password.

All new sites are by default set up with https – to set one up just as http – run…

To remove a site…

Develop Wordpress Locally Mac Software

For more commands and options check out the GitHub repo for wp-cli-valet and also you can create custom sites with a certain theme, plugins, etc by rolling your own bash scripts.

Toggle SSL

To toggle between whether or not a site uses an SSL cert.

or

Terminal output

phpMyAdmin

To deal with MySQL via phpmyAdmin – create a new site

So now you have a https://phpmyadmin.test – remove all the WordPress files and download and move into the folder the latest phpmyadmin files – if your MySQL install is no password then change the config file as prompted to AllowNoPassword. Now all your databases are easily accessible.

You can take WordPress site installation further with Valet by adding a bash script that includes further refining the install with plugins and themes tailoring – see the next article on Valet, wp-cli and bash scripting.

mariaDB 10.4 ERROR 1698 (28000): Access denied for user ‘root'@'localhost'

Since v10.4 mariadb has had some root/password major changes, if you are getting this error when creating new sites with valet use your macos shortname instead with a db user variable like so…

So a new site ‘sitename' is created with the macOS shortname of the account ‘admin'

Develop Wordpress Locally Mac Free

Toggling PHP Versions

The initial PHP Hombrew downloaded version is 7.3, you can add other PHP versions and set Valet to use a different version…

Valet will download PHP7.2 via HomeBrew and use it, you can also use…

Using PHP 5.6

To use PHP 5.6 you need to add an unofficial Homebrew tap as these have been removed from regular Homebrew taps.

Then try Valet

If you get a syntax error .composer/vendor/illuminate/support/Collection.php on line 103 – run…

Using Valet without an admin password

The default behaviour is for an admin password to be requested for each valet command, this can be surpasses with…

Which allows both valet and Homebrew commands to be password free.

References





broken image