Almost Blew It! 012718

I almost blew it today! If you are familiar with WordPress you may already know what happens when you type the wrong URL info into the General Settings. That’s right, your entire WordPress website is completely unreachable. Well, I did just that late afternoon yesterday. All of a sudden all of the work I put into this WordPress project over the past 6 weeks was completely hosed, and I didn’t have a clue how to fix it.

Nerve Wracking!

Talk about nerve wracking. This is probably the worst jam I’ve gotten into.

Saturday evening I decided to register the “www.k6hr.com” domain name. It was so inexpensive at $24 I couldn’t resist. This included Dynamic DNS service. In my haste, I misconfigured the site URL’s in the WordPress SQL database. I also made some assumptions that almost wrecked the entire webserver configuration. At one point the server stopped working!

My first mistake was thinking all I had to do was change the name of my server to ‘k6hr.com’ and run the ‘homing beacon’ and I would be good to go. Big mistake. It took me hours to figure out it wouldn’t work that way. Of course, now I would have to undo everything I changed. I kept a note pad next to me and wrote down every command and edit I had performed. A changelog so to speak, so I could successfully undo it in the event of further disaster.

Database Edit Breakthrough

After several more hours of research (leading into today) and more trial and error, I found out that editing the SQL database was the only way to fix this mess. Hours of searching brought me here, and I was able to locate, backup, edit, and restore the database. Unbelievable! It looked like I could fix it. After all, to the best of my knowledge, so far I had only damaged the SQL database file, all my content etc. was completely intact. I had to learn database editing right now if I was going to be able to fix this thing.

When you don’t know exactly what you’re doing make a backup!

I created a backup file:

sudo mysqldump -p db_filename > /backup/db_filename.sql

Then I opened the backup file (as root) using the Midnight Commander file browser, (I’d be lost without “mc”) and did a search for “k6hr.com” and found the two entries I needed to change. I typed in the corrected URL info, saved the backup file, and then replaced my hosed WP database with the edited version of the backup and crossed my fingers.

sudo mysql -u <user> -p < /backup/db_filename.sql

I restarted mysqld, then attempted to load the WP admin page from my original  working ampr.org domain webserver…

It worked! What a relief!

I had successfully recovered the database after working some 14+ hours. I could now login to my WP website again! But, there was another problem, no other WP webpages would load. Only the admin page would open. I was off to a great start either way, as I had no access whatsoever a minute ago.

It turned out the first thing I changed yesterday was the last thing that needed to be reset today. It was the “homing beacon”. I noticed when trying to connect to WP pages using my original working hostname, which I just got done restoring, were timing out with an error message saying “k6hr.com” was unreachable. The URL was being redirected from gw.k6hr.ampr.org to k6hr.com and of course this could never work.

A Working Solution

I figured out that I had to uninstall the homing beacon, and delete all the DNS records it had created. On the ChangeIP.com website I found the DNS Manager and deleted everything. That was it! This WordPress website had been successfully recovered. Good thing, because I was sick over the idea of losing it to such a bonehead mistake.

Brian N1URO advised me on several aspects of getting this working:

  • Add DNS A and CNAME records pointing to my server IP address
  • Eliminate use of the Secondary HTTP port 8080
  • Add a Virtual Host to the Apache2 configuration

Updates and/or additions to DNS records can take up to 24 hours to propagate through all the nameservers on the web. So possibly by 10pm tomorrow night “www.k6hr.com” will be alive and well on the web!

Back To The Front

Two New Domains Registered

Over the weekend I registered two new domains:

I chose ChangeIP.com based on price. They are hereby HIGHLY RECOMMENDED! I experienced very fast responses to all the tickets I opened to ask questions.

Two New Domains through ChangeIP.com
ChangeIP.com

I had no experience dealing with DNS records, and I was fairly certain the DNS records were a big part of the problem I was having.

I decided to reach out to a few friends and ask for advice. Special thanks once again to longtime ham radio friend and guru of ‘All Things Internet’ Brian N1URO. Brian laid it out in simple terms, and I quickly realized I was just a few steps away from everything working perfectly.

Brian told me to:

  1. Reconfigure my Apache2 server to listen on port 80 (instead of 8080)
  2. Create 2 DNS records: An A record and a CNAME record
  3. Add a Virtual Host to the Apache2 server

All the changes Brian suggested were well documented on the web.

Years ago I used an ISP that blocked incoming packets for port 80. I was told they did this to discourage home based web servers. I discovered that they had not blocked the Secondary HTTP port at 8080, so I told my Apache2 server to listen for connection requests on port 8080. I continued to use port 8080. Since it was working, I never thought about changing it back.

Simple:

  • Edited the /etc/apache2/ports.conf file and changed the port number back to 80.
  • Logged into my account at ChangeIP.com and created the 2 DNS records
  • Copied, edited and renamed /etc/apache2/sites-available/default to /etc/apache2/sites-available/k6hr.com
  • Enabled the site with the command ‘sudo a2ensite k6hr.com’

To create the DNS entries I used ChangeIP.com’s DNS Manager. It’s a web interface that allows you to directly edit and update your DNS records. I clicked on my new domain and there was a button to “Add A Record”. Then, a drop down menu to select the “Record Type” followed by two data entry fields. After selecting A record, the first field to be entered is hostname, and the second is the IP address of your webserver. This was the same for both the A and CNAME records. Once I save the changes they take effect in just seconds.

An important step in setting up your new virtual host is creating the configuration file in the /etc/apache2/sites-available/ directory. This file contains the all important “Document Root” entry which defines the directory where all your virtual hosts’ webpages, images etc. will be stored. Typically this directory will be found in your /var/www/ directory. After running the command to activate the virtual host, an entry appears in /etc/apache2/sites-enabled/ directory and your new virtual host is ready to accept connections. The two new domains have been enabled in Apache and ready to test.

Everything is working brilliantly! Now if i could just figure out how to successfully “verify my property” in the Google Search Console I think I’ll be in business. I currently have little to no search results anywhere.

Tomorrow I plan to cut the desktop. Unless something unexpected comes up, the furniture portion of the remodel should be complete. I’m sick with a terrible cold, But I need to get the furniture squared away.

Click here to go back to the future