13th April
written by simplelight

If you’re getting 502 Bad Gateways from your WordPress site when using Nginx then the following cron job might help:

Add a .sh script with this content and set it to trigger every ten minutes:

PHPCOUNT=`ps aux | grep ‘.php.sock’ | grep ‘php5.cgi’ | wc -l`
while [ "$PHPCOUNT" -eq 0 ]
/etc/init.d/nginx startphp
PHPCOUNT=`ps aux | grep ‘.php.sock’ | grep ‘php5.cgi’ | wc -l`

That should check the number of processes, and if it’s not correct restart them.

The script is /root/nginx_php.sh

The cronjob is installed under root, and this is the content:

ps19952:/var/spool/cron/crontabs# crontab -l
*/10     *       *       *       *       /bin/sh /root/nginx_php.shps19952:/var/spool/cron/crontabs#

3rd August
written by simplelight

If you’re getting this error:

Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

When you try to execute a migration, it might be worth trying:

rake db:migrate RAILS_ENV=production

I’m sure this could be solved in a configuration file – database.yml (?) – but that worked for me.

Also, on Dreamhost, make sure to add the following line

‘host: mysql.<dbhostname>.com’ to your database.yml file (under the production environment)