Today we are going to go over how to properly and quickly setup your new WordPress website from scratch. This will include setting up the database, adding and editing the main WordPress files as well as setting your salts. By the end of this tutorial we will have a fully functional WordPress install setup and ready for us to get a basic site up and running.

Assumptions

We will assume a few things before we officially begin this tutorial, these assumptions include the following:

  • You have a server setup previously, if you have not done this please see ( Server Setup )
    • You will need: nginx, php-fpm, mysql, and dns setup to complete this tutorial
  • You have and know how to use WinSCP, Filezilla, putty, or some other ssh client.
  • You have a basic understanding of the terminal and how to use basic commands to move, create, and edit files, not required but helpful
  • You have basic common sense and are able to follow along with a tutorial

We will of course provide detailed instruction on setup for people with little or no terminal experience, other settings such as dns, database setup, ect are outside the scope of this tutorial and will not be covered.

WordPress Logo Image

Getting Logged In

We can start getting everything ready by logging into our server via ssh. Once we are logged in, we will follow a few simple paths for our files.

  • Nginx Files
    • /etc/nginx/nginx.conf – Main nginx.conf file
    • /etc/nginx/sites-available/ – Where our site config files live
    • /etc/nginx/sites-enabled/ – This will be a “Symlink” to the config file in the sites-available folder
  • Web Root
    • /srv/www/ – Our main directory for our webroot
    • /srv/www/example.com – Our website root folder
    • /srv/www/example.com/public_html/ –  This is where our files will reside to be accessible to the public

If you have questions on these paths or how to get setup originally, please see the tutorial linked above for “Server Setup”

Now that we know where everything is we are working with, and we know the paths we will be using we can finally start.

Getting Our Files

In this section we will download and get all the files we need for our WordPress installation.

Lets move into our temp directory to get started:

cd /tmp

Now that we are in our tmp directory we can download our wordpress install file by firing off this wget command. Wget is a small program that we can use from the terminal to download web resources from a remote location easily without having to dead with (s)ftp gui’s.

wget https://wordpress.org/latest.tar.gz

We should have a new file inside of our /tmp directory now named latest.tar.gz, you can check this by using the following command

ls

Now with the following command, we will unzip the files using the tar program.

tar -xzvf latest.tar.gz

After that we will move all the files we require into our public webroot and we will have finished up getting our files downloaded and moved around.

sudo cp -a /tmp/wordpress/. /srv/www/example.com/public_html

Generating Salts

Now before we continue, we need to generate our salts for our wordpress install. We will do this from the terminal to ensure this is not cached in our browser. We can generate our salts by using the WordPress salt api and curl.

First thing first, what and why? 

Salts used in WordPress are there to enable your install to be able to ‘hash’ your data. This will help keep your data secured if you ever have a database breach by not allowing attackers to access your data.

Now that we understand what and why, we can actually ‘do’. This is a short and simple process with a simple command that will print out some long keys. We will take the output and use this when editing our files.

curl -L https://api.wordpress.org/secret-key/1.1/salt/

You should be left with something that looks like the following in the terminal, you will need to copy the full block for the next step when we edit our main files.

WordPress Salt Generation

Editing Files

Now that we have our main tasks completed for our WordPress install, we can continue on to editing our files. We will need to only make a few edits to get our site running and installed.

In order to continue beyond this point, you will need to have your dns settings setup. You will also need to have a database setup and ready for use along with the username and password. If the mysql database is remote, you will also need the host or ip address. For our install we will assume the mysql is local to the website it self (same server) and setup accordingly. 

To get started, lets move to our public_html folder and start by editing our wp-config-sample.php

sudo nano wp-config-sample.php
You will see the following sections inside this file, you will need to edit in the values you have for your database and the salts we generated earlier.

define( 'DB_NAME', 'database_name_here' );
define( 'DB_USER', 'username_here' );
define( 'DB_PASSWORD', 'password_here' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );


Now after we finish getting the edits made we can rename our file and start the install process for WordPress. This will be a short and simple process as well, upon renaming this file it will make the actual WordPress installation almost automatic. We will first rename this file, in Linux based system the way to do this is to actually move the file to a new filename. So this is what we will do:

sudo mv wp-config-sample.php wp-config.php

Now that we have move this file, we can start the actual install.

You will need to visit your website and you will be redirected to the installer for WordPress. Pending a mistype inside the wp-config.php file you should be greeted with a language screen and then asked for an email and password for login. Once this is entered WordPress will setup everything and install all the tables required to run the software.

Wrapping Up

We now have a fully functional WordPress install. Now we just need to install a theme if you want and work on adding some content. As you continue on learning and messing with your new install you WILL make mistakes and break things, but this is all a part of learning and gaining experience. In future tutorials we will touch on adding and removing plugins and themes. We will also add in some tutorials on getting started with making your own plugins or themes and where to get started on such a huge undertaking.

Until next time, enjoy your new WordPress install and feel free to break, explore and expand your new website. You can always just reinstall and start from scratch at any time!

Pin It on Pinterest