WordPress on Laravel Valet
Valet is the latest product in the Laravel ecosystem.
It’s described as “A Laravel development environment for Mac minimalists. No Vagrant, No Apache, No Nginx, No /etc/hosts file”.
Run a command in the terminal and you’re up and running with a server running PHP 7. It also promises to take care of virtual hosts for you.
It sounds like MAMP Pro, but even easier. Or is it?
The introduction video looks promising:
But as every developer knows, nothing is as simple as it seems. How hard is it to install a WordPress site using Valet instead of MAMP Pro?
It’s quite easy actually. The following is a description of how I did it and which problems I encountered.
This should be very easy according to the documentation. I just have to run a few commands in the terminal.
$ brew update No problems.
$ brew install homebrew/php/php70 So far so good. Wow, this was quite amazing by the way. Suddenly, PHP 7 instead of 5.6 on my system.
Okey, next up:
$ composer global require laravel/valet
Here’s where I encountered my first bump in the road. I got this error message when I ran
zsh: command not found: valet
The reason was that the
./composer/vendor/bin directory wasn’t included in my PATH in this computer. So I simply added the following line into my
Then I ran
valet install again, and voilá!
Okey, Valet was successfully installed on my computer. Now what?
I could either run
valet park or
valet link. I found that the second option was the most apropriate for the time.
Time to see if Valet was actually working!
$ mkdir valet-test && cd $_ I navigated to
$ echo '<?php phpinfo();' >> index.php
$ valet link valet-test
http://valet-test.dev in my browser and expected to see the typical PHP info screen. But instead I got a 403 forbidden error.
I turned to my friend Google and asked for help about
laravel valet 403 forbidden, but I didn’t find anything useful.
Then I remembered reading something about port 80 in the documentation:
“Before installation, you should make sure that no other programs such as Apache or Nginx are binding to your local machine’s port 80.”
So I closed MAMP Pro and Homestead, but the 403 forbidden error remained.
Finally, I realized that I hadn’t ran the
valet start command after the installation.
The WordPress part
With Valet installed and running, it was time to see if I simply could install WordPress without running into any new problems.
I love how easy it is to download WordPress with wp-cli by the way.
$ wp core download
This worked as expected, but what about the database? The Valet documentation says that you should install MariaDB.
$ brew install mariadb
Next, I created a new database:
$ mysqladmin create valet-test -u root
Then I could install WordPress with these credentials:
Password: ’empty string’ Database: valet-test
Problems with vhosts
One problem I got after playing around with Valet was that none of my virtual hosts worked anymore.
I got this error message in Chrome:
It turned out to be a missing dot after
127.0.0.1 localhost in my
/etc/hosts file. It’s supposed to look like this:
I ran into this very same issue on one of my other computers after installing Valet.
Beside from this, it was fairly easy to get WordPress up and running on Laravel Valet. It’s even quicker than setting up a new project with MAMP Pro and Sequel Pro!