Install a Basic WordPress Site with WP-CLI

  • Service Provider

    WP-CLI is an open source command line for WordPress. Here we will demonstrate a very basic install of WordPress assuming that we have a working web server and PHP stack with MariaDB or MySQL already installed. And assuming that you have installed WP-CLI and have it in your path as wp.

    First change directory into your default web directory:

    cd /var/www/html

    In my example I am using CentOS, RHEL or Fedora. But the idea is the same regardless. Now we need to download the WordPress files.

    wp core download

    Once downloaded, we need to make a wp-config.php file, which we can do by copying the wp-config.php.sample file and filling in our credentials for our database server. We need only the server name (normally just localhost) and a username and password that have been set up with access to create databases on our server. You can specify here a dedicated database name (not yet created) or one that is already created and specify an unused prefix OR.... we can do this with WP as well...

    wp core config --dbname=databasename --dbuser=databaseuser --dbpass=databasepassword --dbhost=localhost --dbprefix=prfx_
    wp db create

    This command takes the details in the wp-config.php file and creates the database that we need based on the specifications there. If you are doing this multiple times with a single database, most of these details can simply be copied from another installation.

    Once the database is ready, we are free to set up our site:

    wp core install --title="My Cool Site" --admin_user="admin" --admin_email="[email protected]"

    That's it. Your site should be up and running assuming that your infrastructure is ready for it. A very simplistic example, but just three commands from blank LAMP (or similar server) to working WordPress install.

Log in to reply

Looks like your connection to MangoLassi was lost, please wait while we try to reconnect.