Wasted a whole afternoon on fixing 502 Bad Gateway for Ghost Blog.
Strange as it appears to be,
npm start --production worked for me yet
service ghost start does not. I did upgrade both
node and Ghost Blog today and I was extremely confused by the symptom of this bug (like what the hell is the difference between
Skip to the conclusion: the problem is caused by upgrading the
node. When I upgraded it, I used
n (it's like a node version manager which allows you to switch between different versions of
node), which changed the directory of the node my OS uses.
If you use
service script to keep the blog online:
which nodeto find the directory of node, mine gives:
vim(or nano as you may like)
mine appears to be:
PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Ghost" NAME=ghost GHOST_ROOT=/var/www/ghost GHOST_GROUP=ghost GHOST_USER=ghost DAEMON=/usr/bin/node DAEMON_ARGS="$GHOST_ROOT/index.js" PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME export NODE_ENV=production # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0
DAEMON=/usr/local/bin/nodeand everything will be fine again.
Subscribe to The WOrLd
Get the latest posts delivered right to your inbox