How to Fix URL Change When Hosting on Raspberry Pi – WordPress

Recently when setting up my WordPress website on my Raspberry Pi, One mistake I made was to change the URL to the website to “192.168.1.24.com” instead of “192.168.1.24”, which means that if I try to connect to the website, it’s just going to redirect to a non-existent URL. Thus I could not connect to it via web address at all. But after about an hour of googling and researching, I was able to fix it, and here are instructions just in case you happened to run into the same issue:

Instructions:

 

First, ssh into your Pi, then type

cd /var/www/wordpress/wp-content/themes/yourtheme

(This changes the directory to the themes directory) and replace “yourtheme” with the name of your theme. Then type:

sudo nano functions.php

once in paste this code right after the “<?PHP” line:

update_option( 'siteurl', 'http://example.com' );
update_option( 'home', 'http://example.com' );

(this code overwrites the already chosen URL in the admin webpage) and, of course, don’t forget to replace the HTTP//:example.com with your desired URL. After that, press CTRL+X to exit, then hit Y to save the code. Now restart the Apache with:

sudo service apache2 restart

or if you are using Nginx, do:

sudo systemctl restart nginx

For additional help, visit these links:

https://wordpress.org/support/article/changing-the-site-url/

https://www.raspberrypi.org/forums/viewtopic.php?t=33246

And that’s all if you have any questions or want to contact me an email: [email protected].

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *