close up photo of programming of codes

Lightsail – Fix default WordPress URL

If you install WordPress on AWS Lightsail, you may notice in WP admin under General>Settings then you cannot change the default URL’s to be your domain rather than the public IP address. They are greyed out and cannot be edited.

To fix this:

Log in to your AWS account and identify the instance that must be changed. Click the SSH connect icon.

In the terminal window type:

“cd stack/wordpress/“ (without quotes) and hit RETURN

Type “dir” (without quotes) and hit RETURN key. You should see among the listed files wp-config.php

type: “vim wp-config.php” (without quotes)
use the down arrow on your keyboard to find the lines that contains the code:

define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/’);
define(‘WP_HOME’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/’);

type the letter i – This will allow you to edit the code within the file.

Edit the following lines and add your desired URL.

define( ‘WP_HOME’, ‘https://www.yourdomain.com’ );
define( ‘WP_SITEURL’, ‘https://www.yourdomain.com’ );

press ESC then type “:wq” (without quotes) and press ENTER. Doing this will write the changes and quit the editor.

close the Terminal window.

Go back to the instance page and click reboot.

Once the site restarts, log into WordPress admin, go to Settings>General and the updated URL should be present.

Additional Resources

Reset WordPress user password

Enable HTTPS on your WordPress instance in Lightsail