A few days ago, I moved my VM from CentOS 7 to Ubuntu 18.04 LTS.
Why? I wanted to try something new, including a new webserver (Apache to Nginx), a new database system (MySQL to PostgreSQL) and I am also more comfortable with the Ubuntu firewall tool ufw.
In this article I want to give a checklist for a server switch. The checklist include nearly everything I had to do during this project. If you think, there is something missing - please let me know!
On DigitalOcean you are able to create and run multiple droplets at the same time. I wanted to move all my websites and services to the new server with the lowest downtime possible. To do so, I created another VPS and configured it as it would be a fallback system.
Please BACKUP your whole system to prevent data loss.
- At your Domain Registrar you have to provide the address/domain of your DNS-Server. The DNS-Server stores your DNS domain information (including which IP is serving the content for a domain). Every entry contains a TTL (time to live) value. This is the amount of seconds, these values are checked and not updated (cached). Decrease this time to be able to switch your IP for your domain nearly immediately.
- The next step for me was to install the LAMP/LEMP software stack. This contains the webserver (Apache/Nginx), the database (MySQL) and the binaries of the programming language PHP.
I wanted to move from Apache to Nginx. So I had to migrate the .htaccess configuration files to the Nginx syntax. For this webserver change, I was interested in the difference in speed, memory and CPU usage between Apache and Nginx. I will release an article soon about this topic. If you also interested in the comparison, this is the best time to measure your current server now.
- After installing the database management system MySQL, it is time to configure it. The most important step for me was to set the default collection to general_ci and avoid large binary files.
Don't forget to import all data to your new system. If you are running a service with high data change rate your are not able to export and import without data loss and downtime. One option is to create a replicated system, which can be configured in e.g. phpMyAdmin. This will keep your data in sync.
- Check all of your open ports on your VPS. All these ports should be opened on your new system as well. At this point, you can check if every port is really needed. If not, close it to prevent attacks.
- If you are protecting your system with Fail2Ban (or something similar), copy your rules and register it as a service to let it run automatically on start up.
- A log file contains interactions with your applications. This file can get very large and unhandy. It is a best practice to rotate these files. To configure the integrated Logrotation daemon, you can read my article: https://readfromfile.com/change-http-log-rotation/. Your configuration files should be copied to the new system.
- Another frequently used daemon is the crontab. This executes every commands on a configured time. List all your cron jobs and transfer these to your new VPS.
- The opt folder contains installed third-party applications you installed. Install the required applications on your new system.
- The new VPS should have all UNIX users of the old system. This includes the .bashrc files (user configuration file) and the home folder of the specific user. Another step is to change the ownership and permission of the files on your new system (including group permission)
- Before deleting your data, have a look to your PATH variable. This should be considered as well.
- An important step for me was to transfer all website data (/var/www folder) and services. Keep in mind to change the paths, if the new server has a different filesystem structure.
- The last step was to install certbot and configure all domain certificates. If this is set, I was now able to change the DNS entry and point to the new VPS. If everything works, the TTL can be increased again.
These are the main steps I did during my server switch from CentOS 7 to Ubuntu 18.04 LTS.
Do you have something to add?
Please comment below, if you have any questions.