Skip to content

Instantly share code, notes, and snippets.

@orumad
Last active December 23, 2021 09:59
Show Gist options
  • Save orumad/8837e21eeb01f7cb8feb7dd160db21be to your computer and use it in GitHub Desktop.
Save orumad/8837e21eeb01f7cb8feb7dd160db21be to your computer and use it in GitHub Desktop.
How to install Wordpress from command line in Valet

How to install Wordpress from command line in Valet

I use Valet as my local web development environment (PHP, Laravel, Wordpress, ...)

This gist is my own recipe to install Wordpress from the command line to use it with Valet. Maybe this is useful for you too.

Install 'WP-CLI' command line tool

If you don't have installed 'WP-CLI' tool yet, it can be done (in macOS) with:

$ brew install wp-cli

Install Wordpress

First we must to create a new project folder, download Wordpress and uncompress it... with this single command:

$ wp core download --path=MyWordpress

Now we can cding into our MyWordpress new folder and we can see all the Wordpress stuff right here!

$ cd MyWordpress
$ ls
index.php            wp-admin             wp-config.php        wp-links-opml.php    wp-settings.php
license.txt          wp-blog-header.php   wp-content           wp-load.php          wp-signup.php
readme.html          wp-comments-post.php wp-cron.php          wp-login.php         wp-trackback.php
wp-activate.php      wp-config-sample.php wp-includes          wp-mail.php          xmlrpc.php

It's time to setup our database info. As I said above, I'm using Valet, so I setup my user as root and no password:

$ wp core config --dbname=mywordpress --dbuser=root

Next we will create the database:

$ wp db create

And finally we will make the 'famous five minutes Wordpress install' using:

$ wp core install --url=http://mywordpress.app --title="My Wordpress Site" --admin_user=superadmin --admin_password=supersecret [email protected] --skip-email

That is!

BONUS: Install WooCommerce

$ wp plugin install woocommerce
@jasontucker
Copy link

@notflip
Copy link

notflip commented Apr 27, 2018

Thanks for this! I had to change the following to get it to work with the latest Valet

  • .app is not .test by default
  • I had to replace localhost with 127.0.0.1 in wp-config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment