Have had to reboot server twice in two days

December 25, 2013 4.8k views
Hi, I set up a WordPress blog on Digital Ocean and I've had to reboot the server twice in two days. After setting up the blog, and posting one story successfully, I returned to admire my beautiful work two hours later only to see the message (Error Establishing Database Connection). I then rebooted the server and got it working again, posted another heartbreaking story successfully, and, after waiting a period of time, I returned to admire my first two stories only to see Error Establishing Database Connection again, which I was able to fix by rebooting the server. I used the tutorial on your website to setup wordpress with Apache and Mysql. Is this expected behavior? Is there anything I could do to prevent this from happening?
10 Answers
Maybe you have to optimize your web server / sql stuff? I'm doing fine and I'm using WP as well.
If I was you I will just set up cron to restart AMP every 2 hours etc.
"Error Establishing Database Connection"

That's a very common problem w/Apache + MySQL residing on the same server. That's why WordPress.com (the inventors of WordPress) dumped Apache -- in favor of Nginx -- years ago (not to mention that every premium/dedicated WordPress-hosting company also uses Nginx instead of Apache).
Thanks, can you post a gist explaining how to do the cron job every two hours?
That is not Windows to restart it every time you get in trouble. It's a server, so read mysql/apache logs and fix the issue or hire someone to do it for you.
What folder are the apache and mysql logs in? I"m just a hobbyist developer trying to learn about servers etc. I can't hire someone
If you are using CentOS then

/var/log/httpd/*.log for Apache
/var/log/mysqld.log for mysql
I don't recommend adding a cronjob to restart your server every two hours. In fact, you should never need to do that.

Your droplet is most likely running out of memory, try adding swap:
by Etel Sverdlov
Linux swaps allow a system to harness more memory than was originally physically available. Here's how to set up a linux swap file on Ubuntu 12.04
Most people would not tolerate buying a Porsche that needed to be restarted every 2 hours (moving from shared hosting to a VPS is like upgrading from a Chevy Cavalier to a Porsche). Unless you know more about WordPress and web servers than the inventors of WordPress, why not mimic what they do? Check out:

1.) How To Migrate a WordPress Installation from Apache to Nginx on an Ubuntu VPS;

2.) How To Configure Single and Multiple WordPress Site Settings with Nginx;

3.) How To Install Wordpress, Nginx, PHP, and Varnish on Ubuntu 12.04.
by Etel Sverdlov
Varnish is an HTTP accelerator and a useful tool for speeding up a server, especially during a times when there is high traffic to a site. It works by redirecting visitors to static pages whenever possible and only drawing on the server itself if there is a need for an active process. This tutorial covers installing wordpress on a LEMP stack (with nginx instead of apache), and then installing varnish.
Thanks, the solution provided by Kamal helped! Will also look at nginx. Thanks Pablo
Check out 10 Million hits a day with WordPress using a $15 server (but notice that the author of that blog post now uses a $10/mo. DigitalOcean VPS).
Have another answer? Share your knowledge.