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 stop
is 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, butservice` command does not?
Successful command: npm start --production
> email@example.com 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
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.
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:
127.0.0.1to match the server defined in Ghosts’
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:
I also need to check your NGINX server block, which would be located in:
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:
...is the configuration contents. Since NGINX is what’s going to be handling requests on port 80, the default port you connect to when accessing
http://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.
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 :-).
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Sign up now
rootuser can read from, write to, and execute anything, regardless of whether
rootowns the directory or file.
The default log directory is
Within the above directory, there should be an
nginxdirectory containing an
error.logfile 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.