There are many options to install the WordPress website. We can quickly install by one-click Vultr or AWS Lightsail, or manually installing using any Compute Service Provider. We can take advantage of Vultr which is one of the founding members of Let’s Encrypt free SSL. We probably install WordPress on AWS EC2 and take advantage of SSL Certificate that we bought already for domain in AWS. This article is a note to do this.
Please follow these steps.
1. We install wordpress on AWS Linux 2023 following this link
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress-aml-2023.html
2. Create Target Group.
We create target group and attach the WordPress instance as usual.
3. Create Load Balancer Rules.
We create rule for HTTP:80, we want to redirect all http to https.
We create rule for HTTPS:443 as usual.
4. Turn on SSL for WordPress.
This is very important step. We can’t access wp-admin or other links in html remaining http if missing this step.
nano /var/www/html/wp-config.php
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
5. Change domain name
Download the wp-cli with the following command (Reference)
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar search-replace 'http://[IP]' 'https://yourdomain' --path=/var/www/html --skip-columns=guid
Restart httpd service. It should be working perfectly.