Blog: Server Migration
Published: 2023-05-11 15:02:26

## Backstory

I'll start this by saying that yes, i have been a server administrator since 2010 but no, i am no expert!
It was more of a necessity to host the LiteRECORDS community but on the surface it appears like i'm an experienced pro in LAMP stack 🤥.

Since 2022 i code more with MERN stack so, as NodeJS is a big part of it i needed somewhere suitable to deploy my projects. I could have hosted LiteRECORDS with a public company back in 2010, i could host my apps with public companies like Netlify or Render, but why be a client when i can _hold all the apples_?. Anyway, the point of this server migration was to have all the hosting options i need available to me. At this point i might add that i neither have a working server (old or new) and i haven't tested any Node apps on it to ensure this works as it should. I'll keep editing/updating this log with progress reports.

So, here's my report so far!

## Installing Software

My currently server runs on Linux CentOS-6 and it has done since it's birth back in 2010 (or there-abouts). I wanted NodeJS installed on the server but there were errors. I needed a later OS so, being hosted with DigitalOcean i looked at upgrading to CentOS-7 with redhat. I looked through a couple of tutorials and aside from being technical beyong my knowledge it was ill advised to do so, new idea needed!

DigitalOcean hosts servers as "droplets" and charges by data usage instead of monthly/annually etc. I created a new droplet with the latest CentOs available - version 9. It only takes a few minutes and i'm online and logged-in to SSH. I run the NodeJS installation, all looks fine.

I've always used WHM/cPanel for web management and i knew i'd need it for LiteRECORDS so i go to the docs and get the curl path, here we go! cPanel, Error! cPanel doesn't support CentOs-9, great!..
  **-Destroy Droplet-**
Build new droplet on CentOS-8.. SSH.. install Node, that works.. cPanel, Error! cPanel doesn't support CentOs-8!..
  **-Destroy Droplet-**

At this point i decided to change my priority from Node to cPanel as this is the immediate issue - save some time.

I found the EOL (end-of-life) roadmap from cPanel on OS versions and CentOS-7 was the latest and support ends in 2024 but there were other Linux systems available. After some discussions with tech friends i was recommended Ubuntu.
Build new droplet on Ubuntu.. SSH.. Curl cPanel.. installing! Great! Node installed, <u>double great</u>! Next was other software required to run LiteRECORDS. I tried installing WHMSonic which runs our ShoutCast service, Error. The package couldn't install some dependencies. After some more Googling and a ticket request i was told WHMSonic only runs on CentOS 👎🏼. Back to the drawing board.

I wanted to use the most up-to-date OS to avoid problems in the near future but it seems the software i need won't allow me to do so. CentOS-7 it is. Everything installs fine: cPanel, WHMSonic, Node - Okay, here we go.

## Server Is Running

WHM was installed and it sent me to my login
`https://serverIP.cprapid.com:2087`
Although there were some commands i could use to copy my old server files i'm not well practiced in server CLI so i went back to cPanel Backup Wizard. I could download a full account backup instead of individual 'home', 'MySQL', 'email forwards'. That seemed like the way to go to make this new server as much of a duplicate as possible.
  **-short break for food-**
I have the backup .tar.gz so i go to restore it to the new cPanel, oh.. cPanel doesn't support full account restoration? Why have it as a backup option then?!! Not a big problem, i'll decompress the backup, locate the user folder and upload it SFTP on FileZilla. 250,000 files uploading!
  **-long break for sleep-**
I wake up to an 'overwrite, are you sure?' prompt with 32,000 files left. Annoying but what can you do?

Everything from my old ~user is now on my new server. That sounds like the hard part is over, perfect (update: LOL).

Accessing a droplet should be as easy as `domain/~user` but that wasn't the case. I'm told it's because the server and the user used the same IP neither with domains attached. I went and bought lazyre.co.uk from names.co.uk for £1.00, changed the DNS on the domain host and within a few hours we were live.

## vBulletin

My homepage is just a white screen, nothing in console.log (damn you PHP and your cryptic troubleshooting). Back to Google it is, surely many others have had this issue when migrating (update: they had).

I had to go into Apache and change the PHP version down to 7.x, now i'm seeing something.. "Database Error" (no other information provided). Googles some more. Ahh, i need some PHP plugins for vBulletin to run so after some trial and error i get to a vBulletin message. It was a vBulletin error but at least vBulletin is running 🤷🏻‍♂️. I can't remember the errors but i remember repairing the MySQL and it magically started working, hurray!

### Update

I can't get the domain sitting so the snowball effect is some images aren't loading because the {img_path_misc} use an insecure HTTP 😠.
(update: i should have known at this point it was an SSL issue duhh).

## Domains & SSH

Last night litere.co.uk connected to the new server and vBulletin was running. The old server was still broken, i couldn't connect SSH and the recovery console wouldn't launch either so i opened a support ticket with DigitalOcean. In the mean time i decided it was time to swap the domains over and have literecords.com point to the new server. I thought that this time i would host the DNS on DigitalOcean. It saves me going to 2 different platforms for host management.

Within an hour literecords.com was up and running, i disabled the forum boards until i'm able to download a MySQL database and restore it.
  **-saved, bedtime-**

This morning literecords.com was 404! I don't understand. Maybe it's because i've hosted the DNS on DigitalOcean instead of GoDaddy??

### Update

Remember early i mentioned i downloaded a full account backup? The .sql backup was in there (obviously)! Restored the backup and we're up-to-date 🤓.

The 404 turned out to be the SSL certificates weren't installing on their own, after a manual install everything was running peachy!

## Email

When creating, modifying or deleting email accounts in cPanel i was getting a 'Permission Denied' error. I tried CHMOD and chown but new permissions wouldn't seem to stick. It's been a tough couple of days so i opened a ticket with cPanel support with SSH login.

They logged-in and sorted it out but when i refreshed the page i lost access to WHM and cPanel plus SSH with a 'Permission Denied' 😐.

After some Googling and a few failed attempts i managed to get this sorted by:
```
# vim ~/.ssh/config // "PasswordAuthorizedLogin: NO"
# vim ~/.ssh/authorized_keys // removed all and added my local public key
# systemctl restart sshd
```

## Additional Updates

I used Sphinx Search for vBulletin search which i remember being a problem installing at the beginning, infact i hired a developer to resolve it. Lot's of commands later i cannot get Sphinx installed properly.

After one potential success i changed vBulletin search type to Sphinx and rebuild the counters/indexes. All pages have a 30-45 second refresh time, that's not good.
  **-uninstalls Sphinx, reverts back-**

## Result

This morning i destroyed the old droplet, it was time and i still couldn't access it without knowing the ins-and-outs of shell and Linux. Goodbye old girl.
LiteRECORDS is up and running with nothing broken! I never did get Sphinx to work but the regular vBulletin search works so.. nothing lost.

This concludes my painstaking experience migrating servers, i don't plan to do it again for another decade!