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
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
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: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.cd /tmp
We should have a new file inside of our /tmp directory now named latest.tar.gz, you can check this by using the following commandwget https://wordpress.org/latest.tar.gz
Now with the following command, we will unzip the files using the tar program.ls
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.tar -xzvf latest.tar.gz
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.
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.phpsudo nano wp-config-sample.php
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' );
sudo mv wp-config-sample.php wp-config.phpNow 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.