WordPress Command Line Install

WordPress is a powerful tool that can now be used to create and produce much more then a “blog” or blog like site. You can now create so much that at last check it was above 40% of the internet now uses it as their main sites CMS. Read more here: https://colorlib.com/wp/wordpress-statistics/

So lets assume you have your vps all setup with a webserver running and you have your first page online and it says Hello World! Great, now what is the easiest way to get WordPress on your vps? I mean really before you had to create the db’s, import that db’s, download the core files, ftp or sftp them up to your server, run the installer, all that, and depending on your isp’s speeds it could take you an hour or so as now WordPress is thousands and thousands of files.

Well we no longer have to worry about this. Let me show you how its done.

So first thing we are going to do is connected to your vps, so go ahead and do this.

Now once connected lets run a few commands and then we can have our site on line in a matter of minutes.

So first lets get the WP-CLI Script installed.

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

Great now lets then move into the directory we want the wordpress setup / installed to. In this example we will call it /home/sitedemo.theserveradmin.com. So do the following

cd /home/sitedemo.theserveradmin.com

I am getting ahead of myself, lets get that database setup first as we will need it here in another step

mysql
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL ON wordpress.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'user_password';
EXIT;

Please adjust to your settings for your Database, User, and User Pass

Now we were going to run the following commands.

## Now lets get WordPress installed

wp core download

## Now lets populate the wp-config.php file

wp core config --dbhost=host.db --dbname=prefix_db --dbuser=username --dbpass=password


## Now lets change permissions of the wp-config.php file

chmod 600 wp-config.php

## Next we need to configure wp-config.php and replace information.
wp core install --url=https://yourwebsite.com --title="Your Blog Title" --admin_name=wordpress_admin --admin_password=4Long&Strong1 --admin_email=you@example.com


## That is it!  Your up and running!
## Now lets clear that history as we did past some passwords in clear text.

history -c && exit

Now that this is all done, assuming you have DNS configured correctly and pointed to your vps, you should now be able to access your website and start to build!

By Anthony

Leave a Reply

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