I have a weird situation where I am seeing npm start --production
start up my Ghost blog within my droplet and my website appears, but when I close that port and run service ghost restart
and service nginx restart
I get a 502 Bad Gateway. I’m a bit confused because I thought service ghost start
or service ghost restart
runs the npm start --production command and keeps it running until
stopis called. However this does not seem to be the case. Can anyone point me in the right direction for the logs I should check that might indicate why the command line command run works, but
service` command does not?
Successful command: npm start --production
> ghost@0.7.9 start /var/www/ghost
> node index
Migrations: Up-to-date at version 004
Ghost is running in production...
Your blog is now available on http://www.connordphillips.com
Service start
sudo service ghost start
start: Job is already running: ghost
My only question I have is around the chown
command I ran and if this blocked permissions to the root
user who is running the commands. I ran chown -R ghost:ghost ghost/*
, but I don’t have a ghost user, only a root user which is signed in. Could this mess with anything?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
@connordphillips
Ok, so your Ghost configuration is fine. I tested the exact same on a fresh droplet and it works. The only thing you need to change in the NGINX server block is:
Change
localhost
to127.0.0.1
to match the server defined in Ghosts’config.js
file.You’d then restart NGINX:
service nginx restart
Once NGINX is restarted, you may have to do a hard refresh in-browser, or flush your browser cache. Sounds a bit odd, but I had to do this when I was swapping configuration during testing.
As a reference, this is what I used to setup my test server before using your configuration:
The above uses NodeSource’s NodeJS repositories for 6.x to install NodeJS/NPM, uses NGINX’s repos to install NGINX, downloads and installs Ghost, creates the Ghost init script, and runs the initial setup for Ghost.
From there, I changed this block to use my own domain.
and then used your NGINX server block (inserting my domain in place of the filler you have) and then ran:
@connordphillips
I also need to check your NGINX server block, which would be located in:
or
If those directories do not exist, you’d need to locate where your server blocks are for your domains.
A server block will look like:
… where
...
is the configuration contents. Since NGINX is what’s going to be handling requests on port 80, the default port you connect to when accessinghttp://youdomain.com
, we need to make sure NGINX is setup to proxy requests on Port 80 to your Ghost installation.If NGINX isn’t setup, the only way you’re going to be able to access Ghost is by running it with a Port attached to the URL.
Ghost config.js
The line below should be your actual domain name:
and the following block is what I needed to help you configure NGINX properly:
The above defines how Ghost runs the production server. With the above, the only way you’re going to be able to connect to Ghost is by proxying, which we can do with NGINX, once I see what you’ve got right now :-).
@connordphillips
The
root
user can read from, write to, and execute anything, regardless of whetherroot
owns the directory or file.The default log directory is
/var/log
.Within the above directory, there should be an
nginx
directory containing anerror.log
file and which you can then tail to get the last, i.e.If you could also post your NGINX server block for your domain, we can take a look and see if there’s anything out of place.