Hey there, fellow WordPress enthusiasts! Today, I’m going to walk you through the process of setting up a WordPress site
on Ubuntu. We’ll be using a domain (in this case, slashism.com
) and configuring Nginx. Don’t worry if you’re not a tech
wizard - I’ll break it down into manageable steps.
1. Creating a Home for Your Site
First things first, let’s create a cozy little directory for your new WordPress site:
2. Getting WordPress Up and Running
Now, let’s download WordPress and set it up in its new home:
3. Setting Up a Database
Time to create a database for your site. Fire up MySQL::
Inside the MySQL shell, run the following commands:
Remember to replace ‘your_secure_password’ with something strong and unique!
4. Configuring Nginx
Let’s tell Nginx about your new site. Create a new configuration file:
Copy and paste this configuration (adjust as needed):
5. Activating Your Site
Let’s make your site configuration active:
6. Checking and Reloading Nginx
Always good to double-check our work:
7. Installing and Configuring Certbot for SSL
Now, let’s secure our site with SSL using Certbot. This nifty tool makes it a breeze to set up Let’s Encrypt certificates. Here’s how:
Step 1: Install Certbot and the Nginx Plugin
First, let’s make sure we have the latest packages and install Certbot with its Nginx plugin:
For more details, you can refer the official Certbot website.
Step 2: Obtain and Install SSL Certificate
Run the following command to get your certificate:
Certbot is pretty smart - it can also detect the domains in your Nginx config if you run the below command:
Above command will ask for some info like your email address (for important notifications) and agreement to the Terms of Service.
Certbot will automatically install the SSL certificate and configure Nginx. It’ll ask if you want to redirect all HTTP traffic to HTTPS. I’d recommend saying “yes” to this.
Step 3: Set Up Automatic Renewal
Let’s Encrypt certificates are valid for 90 days, but don’t worry - Certbot’s got your back. It sets up a cron job or systemd timer to automatically renew your certificates before they expire. It’s like having a personal assistant for your SSL!
You can also set up the cron job yourself to automatically renew your certificates. Open the crontab editor:
In the editor, add this line to run the renewal command twice daily:
You can also test the renewal process (without actually renewing) using:
To manually check and renew your certificates:
- Check existing certificates:
- Renew the certificate:
8. Firewall Adjustment
If you’re using a firewall (and you should be!), make sure it’s configured to allow HTTPS traffic:
This opens up port 443 for HTTPS and closes port 80 for HTTP - keeping things nice and secure.
9. Finalizing WordPress Installation
Now, head over to https://slashism.com
in your browser and finish setting up WordPress using the database details we created earlier.
Troubleshooting SSL Redirects
If you run into any redirect issues with HTTPS, don’t panic! Add these lines to your wp-config.php
file:
And there you have it! You’ve successfully set up WordPress on Ubuntu with SSL. Remember, this guide assumes you’ve already got PHP and MySQL/MariaDB installed on your server. If you run into any hiccups, feel free to reach out or check the official documentation.
Happy blogging! 🚀💻📝