The setup of a Linux server is the best way to save a lot of money and also to better apprehend your server, its security, the possible glitch, to less depend on the support. It won’t be easy because you will be pratically alone, alone to deal with a down server, with hackers, DDoS attacks, with database issues, with corrupted files, alone to do backups, etc… but when you will have mastered a Linux server, you will be very comfortable with the work on your websites.
What Linux distribution to choose ?
The most popular distributions are Ubuntu and Debian. Ubuntu gives us much more results when you search it in Google. However I have to admit that several times, I haven’t found solutions for specific issues with this one. So, I have decided to install Debian on my servers instead. With Debian, I have pratically always been able to resolve the problems that we can encounter with a server. So, I would suggest Debian. The SSH commands are almost the same. Guides for Ubuntu will be compatible with Debian most of the time.
After a fresh installation of a Linux server or VPS (virtual private server) :
1. Update the Linux distribution and change the root password.
2. Setup the Apache web server.
3. Setup the MySQL server.
4. Setup phpMyAdmin.
5. Setup PHP.
6. Setup a FTP server.
7. Add a website in Apache (adds several with virtual hosts).
8. Add a shortcut to phpMyAdmin (in your www/html directory).
9. Setup an editor.
10. Link the ftp sever to virtual hosts.
11. Setup Exim4 (mail module).
– You can use Nginx instead of Apache, but I don’t recommand it as setting virtual hosts (if you want to add several websites) is much more complicated with Nginx. And configuring https with Nginx is also another difficult task as you have to setup packages like php-fpm that requires custom parameters. Personally, I have not been able to work properly with Nginx. You can still try it and later come back to Apache if you failed.
– Replace sendmail with Exim4. Exim4 will make less issues.
Additional setup for advanced cms (vBulletin, phpBB3, WordPress) :
– Fail2Ban is the best firewall program to ban IP addresses that constantly tries to guess your password. Hacker robots are excellent nowadays, they will find your root password in less than 1000 of tries. It requires some tweaks with addition of jails. The firewall alone is not enough. The hackers will break your server if you don’t setup the SSH RSA key solution, and your web hosting provider will have to close your account as you will get too much abuse reports. Your server will indeed hack other servers due to a malicious code in your Linux folders.
– The SSL certificate is very difficult to install. There is no complete guide on the Web yet for the free SSL certificates like Let’s Encrypt, with the correct configuration of Apache or Nginx. Personally I have failed for the moment. The problem will be that all your https url won’t work if you decide to remove the SSL certificate. You should let it and redirect the internet users to http. But sometimes when you setup https, http doesn’t work anymore. So be aware of that and test it first on a demo server. Be sure when you have the lock to try it deeply, by modifying files on your website, by surfing on it.
22. Create backup.sh.
Some how to guides :
– File and folder.
– Group and user.
– RSA key.
– Other Linux.