Load Times Under 2s: Adding a WordPress SiteMay 6, 2018 | By admin | Filed in: hosting.
With our current setup, you should be able to add as many sites as you want to hosted on your server. Here’s how to add a WordPress one.
First up, we need to add your domain name to your DNS server, if you haven’t already. First, add your domain to the master zones file:
… add the following contents to the bottom of the file
Next, open the individual file:
… and, copy and paste the following code over to your DNS server, adjusting the serial and other records as needed.
You can adjust any of these records as needed (like the mail IP address), and add in any additional subdomains by listing:
below the records.
Now, test your configuration using
If you see an “OK” at the end, everything should be good to go. Once you get that, you can reload your DNS server.
… and check the status
If you see an “active (running)”. Everything should be loaded properly.
At this point, if you run, from a different computer (like your home one):
You should see your DNS records show up in the “Answer” section. Now, you can add hostnames in your domain name provider for “ns1” to [[Your IP Address]] and “ns2” to [[Your IP Address]] and then to point your domain’s nameservers to ns1.[[Your Domain Name]] and ns2.[[Your Domain Name]] .
In order to avoid having a warning every time our site is loaded over TLS/HTTPS, we need to add a verified SSL certificate. Personally, I use either the 2- or 3-year wildcard certificates available through SSL2Buy, or a free Let’s Encrypt SSL certificate (they are essentially identical).
First up, we need to generate a certificate signing request. To do this, run:
Follow the instructions to enter your organization’s and domain’s information. At this point, you should be able to print your CSR for generating your certificate file (.crt).
When you’re done with getting your certificate information (we need the section “—–BEGIN CERTIFICATE—–”), we can add it to the server. Open up the corresponding .crt file, and paste the contents.
In the case of AlphaSSL and some other certificate providers, you may need to add in an intermediate certificate. In my case, I added the intermediate certificate here: https://www.ssl2buy.com/wiki/alphassl-intermediate-root-ca-certificates to the end of the .crt file.
Same as with our self-signed certificate, we’re going to generate a Diffie-Hellman Group certificate
… and append it to our certificate file
To install a free Let’s Encrypt certificate, first we will need to install the certbot (the tool that will help us verify the certificate.) To do this, run
You will need to copy the following script over to /var/local/src/authenticator.sh using
The script to copy:
And now you can generate the certificate:
This should auto-install and confirm your certificate.
Now, we’re going to need to create a subfolder of the FTP server folder and link our domain directory to it. First, we need to create a subfolder:
… and change the permissions so that the vsftpd can access the folder.
Now, we need to create the link
… and change the permissions of the link so that the web server can access it.
At this point, if you upload a file (say test.php) via FTP to the [[Your Domain Name]] folder, you should be able to see it if you run:
Now, we need to add an Apache configuration file for the new site. Open a new file named /etc/httpd/conf.d/[[Your Domain Name]].conf
and copy in the following contents.
You may wish to change the ServerAdmin email address to your own, or leave it as is. At this point, you can test your Apache configuration using
… and if you see a “Syntax OK”, everything should be good to go. Now you can restart your Apache server and check the status.
If you see “active (running)”, everything should be good to go. If you have your web proxy ports open, you should be able to go to: http://[[Your Domain Name]]:8080/test.php and https://[[Your Domain Name]]:8081/test.php and see your test file (assuming you uploaded them).
Finally, we can copy in our Nginx configuration. This mainly just specifies which of our previous files we need to include, and all of the settings for our site. Open /etc/nginx/conf.d/[[Your Domain Name]].conf
…and copy in the following configuration if you’re using a manual SSL certificate:
or if you’re using Let’s Encrypt:
You can test your configuration by running
You should see something like:
Indicating that everything is set up properly.
At this point, you should be able to restart you Nginx server:
… and check its status:
If you see “active (running)”, everything should be good to go. You should be able to go to: http://[[Your Domain Name]]/test.php and https://[[Your Domain Name]]/test.php and see your test file (assuming you uploaded them).
To upload your MySQL database, export and download it as a single .sql file (the entire database). After you’ve downloaded it from your old server if needed, upload the file via FTP. Once you have the file uploaded, create a database via phpmyadmin with the same name as your old one. Once it’s uploaded, run on your server:
This should upload everything into your new MySQL database. To check, view the database in phpmyadmin, and see if all of the content is loaded properly.
To upload your WordPress site, you can simply upload your files via FTP to your server. They should be available immediately. At this point, if you go to https://[[Your Domain Name]]/ you should be able to view your website.
If you like the result of the tutorial, but run into problems or would just like to have the work done automatically, we can help you with that. We have an automated script that can SSH into your server and run this tutorial from beginning to end (as long as it’s running CentOS 7). If you would like this done for you ($100), please contact us using the form below.
- Part 1: Introduction and Planning
Why it’s important to have your pages load in under 2 seconds, and a plan of how we will set up and configure the server.
- Part 2: Installing Software
Initial setup of the server, including installing CentOS7, installing tools, installing SSH and SSL, enabling repositories, and installing support packages.
- Part 3: MySQL, Apache, PHP7, & Composer
- Part 4: PHPMyAdmin & Redis
- Part 5: SSL Certificate & Apache Configuration
- Part 6: FTP & DNS
- Part 7: Installing Nginx
- Part 8: Configuring Nginx
How to set up Nginx configuration files including (with explanations): nginx.conf, Gzip compression settings, visitor browser caching settings, SSL settings, reverse proxy settings for sending data to the Apache server, reverse proxy connection configurations, file access restrictions, and WordPress configuration settings
- Part 9: Adding a WordPress Website
How to add a WordPress website to the server including configuring the DNS Server, adding a verified SSL certificate, either manually or for free using Let’s Encrypt, setting up FTP for your site, configuring Apache, configuring Nginx, uploading your WordPress site files, and importing your MySQL database.
- Part 10: WordPress Website Speed Improvements
Speeding up your WordPress installation using a Redis plugin and a caching plugin.