How to Install WordPress via Command Line on Ubuntu

Install WordPress Using Command Line
Install WordPress – WP CLI

Most of the people when they install WordPress on their server would do the following: Download the archive from the WordPress site, extract the contents locally, upload the files on to their server, then open the website and follow the installation instructions.

It works fine as this is the standard way of installing WordPress on your website. However, each time having to download the file, extraction and then installing the website is a cumbersome process.

There’s another way of installing WordPress which is considerably faster, but it requires that you have access to your server’s command line console. In comparison, it is also faster.

In this article, we’ll be exploring two ways to install WordPress without accessing the installation website.

1. Automate (Commandify) the Traditional Way

This does not involve any sort of extra software needed to install WordPress. We’ll simply automate or do what we do manually, but in the form of Linux commands. Before we start, please make sure that you have the following ready:

  • Website URL
  • Database Credentials
  • Desired Website Credentials

Step 1: Download and Extract WordPress

$ wget;
$ tar xfz latest.tar.gz;
$ mv wordpress/* ./;
$ rmdir ./wordpress/;
$ rm -f latest.tar.gz;

Make sure that you replace YOUR_BLOG_DIRECTORY with the actual path to your web-root directory (in most of the cases, /var/www).

Step 2: Configure the Database Credentials

$ sed -i s/database_name_here/YOUR_WORDPRESS_DATABASE_NAME/ wp-config.php;
$ sed -i s/username_here/YOUR_WORDPRESS_DATABASE_USER/ wp-config.php;
$ sed -i s/password_here/YOUR_WORDPRESS_DATABASE_USER_PASSWORD/ wp-config.php;

You’re required to edit the replace the following values with YOUR_WORDPRESS_DATABASE_NAME, YOUR_WORDPRESS_DATABASE_USER, and YOUR_WORDPRESS_DATABASE_USER_PASSWORD with the appropriate values.

Step 3: Install WordPress

$ curl -X POST -d 'weblog_title=YOUR_WEBSITE_NAME&user_name=DESIRED_USER_NAME&admin_email=YOUR_EMAIL_ADDRESS&admin_password=YOUR_PASSWORD&admin_password2=YOUR_PASSWORD&pw_weak=1' 'http://YOUR_WEBSITE.COM/wp-admin/install.php?step=2';

Don’t forget to replace your website’s name, desired administrator username, email address, password and website URL. Once that’s done, your WordPress installation would have been completed. That’s it!

2. Using WP-CLI to Install WordPress

WP-CLI is a powerful tool available for server administrators to manage multiple WordPress installations efficiently, but in our case, it can also help us install WordPress quickly without any hindrance.

Step 1: Install WP-CLI

$ wget;
$ chmod +x wp-cli.phar;
$ mv wp-cli.phar /usr/local/bin/wp;

Step 2: Download WordPress Files

Make sure that you execute the following commands after changing directory to your web-root which, in most of the cases, is /var/www.

$ wp core download;

Step 3: Configure Database Credentials

$ wp config create --dbname=DATABASE_NAME --dbuser=DATABASE_user --dbpass=DATABASE_PASSWORD;

Step 4: Install WordPress

$ wp core install --url="" --title="WEBSITE NAME" --admin_user="DESIRED_USERNAME" --admin_password="DESIRED_PASSWORD" --admin_email="YOUR_EMAIL";

That’s it! Your WordPress blog should now be available for use.

WP-CLI is an excellent tool if you’re looking to make your life easier; it helps you manage your WordPress websites efficiently, install themes and plugins and activate them without any hassle. It can also be used to install and update WordPress installations.

For example, if you were to download and install the theme Graphy (the one we are using as of now), you would have to execute the following two commands:

$ wp theme install graphy;
$ wp theme activate graphy;

In addition to this, you can also search for plugins and themes available on the WordPress repository with this tool. You can find the complete list of all available commands on this page.

Having Troubles Installing WordPress?

Maybe, you aren’t exactly a technical guy and facing trouble trying to install WordPress on your hosting platform. We at JetWP can definitely help you with that in a matter of some minutes.

We provide a fully managed WordPress hosting platform where we handle all the technical stuff while you focus purely on blogging.

So, you can stop trying to install WordPress now and simply head to our Managed WordPress Hosting page where you can select your favorite hosting plan and get started with your WordPress blog in minutes without having to install WordPress or deal with any technical matter.

Find us at

Leave a Comment

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