OK, now you have your web project ready, up and running. It is using apache (or nginx) as a web server and mysql (or postgres, or whatever) as a database engine. Everything is working fine and you are completely happy. However, there can be a situation when:
- one of your services (mysql, apache, nginx , php-fpm or whatever is of a vital importance) goes down
- one of your services (again, mysql, nginx, apache, php-fpm, etc) is overloaded, meaning that CPU used by the process is almost 100%
In this case your web application won’t be available any more. In a good scenario, you’ll notice the outage yourself or one of the angry users will drop you a line via email or twitter. In a bad scenario your website won’t be available for hours. So what do you do?
- First of all, make sure that all processes that are needed to run your website smoothly are added to the autoload. Meaning, that after server reboot they are available automatically and there is no need to manually start them. How to do that, really depends on your server OS. Just google “add apache to autoload ***your OS name goes here***”.
- I would recommend installing and configuring some kind of software that would be monitoring processes running on your server and in case some of them go down or are consuming too much of resources, start/restart them automatically. There is a good open source solution for *nix systems called Monit. It is easy to install and configure and even sends you emails when something goes wrong. Don’t forget to add Monit to the server boot load list.