Adventures in Ubuntu

I know I’ve posted about my different adventures with Linux, but I have learned so much about it recently. I switched my media server over to the current Long-Term Release of Ubuntu because I wanted to use a Debian based distro. Debian is more widely used than Red Hat and answers are just easier to find. On top of that, Ubuntu has made Linux easy for a long time. I know a lot of people don’t like them, but I sure do.

I got to thinking about whether or not I could get rid of my web hosting account. It’s $15 a month and all I ever really use it for is my journal and a place to post my weather station junk. I began looking at what I could do and came up with a quick solution.

The first thing I had to do was iron out my Internet connection. I have what amounts to a DSL modem/router (which sucks) connected to my router. Essentially, I had put myself behind two layers of NAT. I figured out how to bridge the modem to my preferred router and make it connect. (I think that was the scary part.) It only took me a couple of hours and things went smoothly.

The next thing I had to iron out was DNS. Dynamic DNS has been a thing for a long time, but all I knew was that sites like DynDns.com charged a big fee for it. I stumbled across another site called Dynu who offered it for free. I eventually stumbled across the fact that Google Domains provides the same service for free, as well. I bought a new domain for testing and got to work.

I had to find a way to make the server check it’s public IP from time to time and report it to Google. A little Google-Fu later and I found ddclient was the Linux standard. It only took a few minutes to configure and my domain was pointed at me. I put up a little HTML page to make sure and it worked beautifully.

The next thing I had to do was figure out how to deal with multiple domains. Apache2, which is installed on Ubuntu by default, actually makes it really easy; you don’t even have to install a DNS service! Apache2 uses virtual hosts that you can enable and disable from the command line. All I had to do was create a document root for each of the domains. I pointed my old bigjaytx.com domain to my server, as well. Again, it worked beautifully.

Now for the harder part. I have this domain and a subdomain of it that I use for different things. I decided to tackle the weather part of it first. I had to make Weewx on the Pi publish the site to my server instead of the web host. I scratched my head for a few hours to figure out the best way. I ended up creating a new user account on the server so it would have a home folder. I then symlinked the folder to the document root for the subdomain. It made the files move over, but I would get a 403 when I tried to view them. The solution was to add the Apache user to the weather user group and the weather user account to the apache2 group and it worked!

The last thing I had to tackle was the WordPress. Now, I’ve moved dozens of WordPress installations from server to server. That’s pretty easy to do when you’re on cPanel. It’s another story when it’s you doing it from the command line. Now, I had played around with installing WordPress on my play & break server. I knew how to make a database, user, connect the two, and make it work.

I downloaded a backup of my WordPress database and a zipped file of the document root for the installation. I went through the steps to import the db and yada, yada, yada. I was excited that it appeared to work just fine! All my posts were there, and things were displaying. The only problem I had was that not all the menus were available when I tried to make a post.

WordPress has a nice Site Health tool to help you troubleshoot. It was running into a REST API issue. I had no clue what that was. I did the usual of disabling all plugins, nope. Rebuilt my permalinks, nope. Switched themes to a default and back again, nope. Repaired the database, nope. Reset the .htaccess, nope. I was about ready to pull my hair out. I FINALLY found the answer; it was a rewrite statement missing. I had to add a few lines to the virtual host file for the site and restart Apache2. Fixed!

So, all three of my domains are pointed at my computer at the house and I closed my hosting account at A2. They’re a good service, but I just don’t need $15 a month for it. I had to give up email capability for now, but it’s not a big deal. I don’t allow users or comments on my WordPress. I have my primary Gmail account I use for everything. Long story short, that’s how I became my own webhost.