Wordpress Logo

Install WordPress from command-line

I never tried it before but today I needed to install WordPress… From command line only. And there is a way to do this with wp-cli.

WP-CLI installation

First some requirements (as root):

apt-get install php5-cli php5-mysql mysql-client curl

And now installation of wp-cli (as root too):

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp

Check if it’s working:

$ wp --version
WP-CLI 0.22.0

WordPress installation

Now you should switch to user of your web application, ex. like this:

su - www-data -s /bin/bash

And install WP:

wp core download --path=/var/www/wordpress

wp core config --path=/var/www/wordpress \
  --dbname=wordpress \
  --dbuser=wordpress \
  --dbpass=wordpresspass \
  --dbhost=localhost \
  --locale=pl_PL

wp core install --path=/var/www/wordpress \
  --url="http://example.com" \
  --title="Example blog" \
  --admin_user=never_use_admin_here \
  --admin_password=admin_pass \
  --admin_email=admin@example.com \
  --skip-email

Here you may find more about wp-cli configuration and commands.

Leave a Reply

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