Multiple Ghost sites with ghost-cli on same server

I installed one ghost site using the ghost CLI tool. It worked great!

Then, I installed another one, with all the same configuration and commands except different:

  • Database info
  • port
  • domain & folder

…and that second site returned an Nginx error.

Is there something else I need to do when installing Ghost to more than one domain/directory with the ghost CLI tool on the same server?


Answers consulted

Answers here don’t help because I already did that.

Docker solutions aren’t solutions because Docker is for load balancers like Kubernetes (until Kubernetes wasn’t) and massive servers to create single apps en masse. Docker is not for Vue & JS cocktail chefs to solve problems with a jackhammer, though that seems to be a well-kept secret.

This other question addresses DigitalOcean one-click app droplets. That’s not what I’m doing, and the main link-only answer is broken.

I don’t think the CLI is really equipped to install Ghost on multiple subdirectories, but I might be mistaken. If you’re not installing multiple instances on to a single site, there are a couple of things to check:

  • Is the new instance running? You can check with ghost ls
  • Are both instances trying to use the same port? You can also check this with ghost ls

They are different domains hosted on the same server. Does that change anything?

Should I use the ghost command to indicate a different Ghost session is running?

The docs say ghost start [name], but [name] doesn’t seem to work. If I give each a different name, will that solve it? How would I do that?

You can get the names from ghost ls

You must cd into the subfolder for each Ghost instance ( ghost ls works outside.)

However, I notice you posted elsewhere about a manual systemd setup. This could be the source of the problem.

Sharing error messages for Nginx and ghost start would be helpful.

I found this helpful when sorting how to run multiple ghosts on same server

tl;dr

Culprit: developer mode

I got it working. The .service file needed to be this:

/lib/systemd/system/ghost_domain-tld.service :

[Unit]
Description=Ghost systemd service for blog: domain.tld
Documentation=https://ghost.org/docs/

[Service]
Type=simple
WorkingDirectory=/srv/www/ghost/domain.tld
User=ghost
Group=ghost
Environment="NODE_ENV=production"
Environment="GHOST_NODE_VERSION_CHECK=false"
ExecStart=/usr/bin/ghost run
Restart=always
SyslogIdentifier=ghost_domain-tld

[Install]
WantedBy=multi-user.target

This was edited per discussion to remove:

StandardOutput=syslog
StandardError=syslog

Long story

No, this is the better, safer way.

There never was any Systemd, Nginx, or Node error to report; it just had a bad gateway on Nginx from the browser, but systemctl reported the service running just fine, which means the Nginx reverse proxy was pointing to a living .service that didn’t exist. mjw, ghost start and ghost install always throw errors up to 42,000 ft telling me that I can’t fly, despite cruising at 42,000 ft, so those warnings don’t report real problems anyway.

My problem seemed to be that developer mode didn’t like concurrent sessions. So, remove -D and all Ghosts run.

Why I made my own .service files…

I’m running Arch and MariaDB with the --db=mysql option, and I have absolutely no problems once it’s running. Arch keeps everything current, so “no newer than” version checks break everything that works anyway, and then won’t create that .service file, which was why I asked. This is a security issue…

From a SysAdmin’s seat, creating .service files is either my job or the job of a package manager like pacman or apt or apt-get or even dpkg. Systemd service creation is not the job of a non-root user running ghost install CLI commands.

Unix/Linux CLI = GUI API

…otherwise it’s not a bona fide CLI tool.

Web browsers don’t ask mouse users for the sudo password, so the CLI installer shouldn’t either. This isn’t DOS of the 1990s; there’s a reason awesome apps are build on Unix, including Apple’s.

No .service file should ever be created by a command that does not require sudo when run by a non-root user.

“Please enter sudo password” in the middle of the install process = ductape bodywork → can’t hold water.

The safer workflow is that all changes to hosted websites or system settings require sudo or “run as root” up front, then have their scripts employ system users or otherwise handle permissions like “compiling as non-root”—all handled inside the CLI tool.

25% faster rollout

Ghost could be rolling out their new feature roadmap 25% faster if the CLI workflow were in order. Seeing things orchestrated this way tells me that the Ghost code team kept bumping into mirrors in a mirror maze. The problem is that the 50 year old SysAdmin curmudgeons don’t want to talk to the Node & JS masters to help perfect what the Ghost guys are doing. I see what the Ghost team is trying to do, and I like it. I just wish they knew they could do it 25% faster like I know they can.

Ghost runs happy as Larry on Arch with MariaDB, just like almost everything else that runs on Debian. All these “can’t use the new version that works, can’t use Monty’s current SQL database” warnings aren’t needed. I have it clipping along just fine. So, yes I wrote my own .service file because that’s what Self-hosting Developers do when a non-sudo command asks for a sudo password after execution.

It took two weeks, but I got Ghost working again, just like I did 6 years ago. I like what the team’s been up to.

Ghost is awesome, both in the browser and in the RAM. I hope future releases don’t require what I don’t need. I’m done with WordPress, if I’m allowed to be.

looks good, although for others following in your footsteps it is worth noting that

… overrides the default ‘journal’ setting for systemd (which uses journalctl for logging rather than the old syslog service).

For others doing a self-hosted install, note that ghost setup is there as a convenient way to create a standard install and all the setup stages are optional and can be skipped if you prefer to do it by hand (Ghost-CLI - A fully loaded tool for installation and configuration for more info). It is hard to see how the sudo dependency can be avoided in this type of utility since root access is needed to set up nginx, systemd etc.

1 Like

NickAbs nice Frank Lloyd Wright icon.

This is amazing and helpful! Yes, we want journal.

I’m glad the team thought of having a way for Node Ghost devs to get a thing up and running on their local machine fast. Kudos!

What I don’t like is a “convenient” tool that tries to outsmart me, checks for things that aren’t confirmed to matter, gets it wrong, then jumps ship. I’d rather there also be a simple checklist allowing me to clone, fill in a config sample, and use a .service example to get it started. It doesn’t have that.

For sudo

  • Wrong way: (current)
    1. $ ghost setup
    2. …a few moments later… Please enter sudo password
  • Right way: (everyone else and their mom)
    1. $ sudo ghost setup -y
    2. Watch output until finished
    • I know how to write this, though many may not.

fair enough, although I suspect that people with your system admin experience are not really who this utility is aimed at.

The ghost-cli code that does the setup is well commented, so a more detailed check list would be possible for someone willing to do the work to create it.

1 Like

3 posts were split to a new topic: Does Ghost work with MariaDB

I’d be inclined to go write the whole thing to use sudo, but I don’t know how the team will receive that. It would mess with a lot of desktop developers’ workflow.

But, these are people typing in their terminals, not using SysAdmin scripts, so it probably wouldn’t break any stacks.

I think ghost-cli already works this way…

under the covers setup is using standard Linux sudo so I’d expect sudo ghost setup run by an account needing a sudo password to prompt for a password once at the start. On a standard sudo install, all subsequent sudos needed by the installer should use the credentials cached by the system.

Similarly where the ghost-admin account has password-less sudo access - which is how my accounts are set up - there are no sudo prompts during setup.
Perhaps something about Arch sudo is different to the above…

Arch sudo is not different. That actually makes some sense and would be good, but it doesn’t seem to behave that way.

When run as root, ghost returns that only a non-root user can run ghost.

Can you please link for me:

  • where these settings & credentials are for the ghost Linux user?
  • where the instructions are for getting ghost to run with that behavior?

…I just can’t seem to find it.

Apologies I was mistaken - I just tried it with a clean install and a regular user with standard (password required) sudo permissions. It did not interrupt the script to ask for a sudo password, but this was just because the password was still cached from before I ran the installer.

As you say the ghost-cli complains if you run it as root.

I suppose this check is arguably redundant if you are just running ‘ghost setup’ in isolation - as I believe all the set up stages need root - but I also suspect it would be more trouble than it’s worth to change, given it doesn’t effect the functioning of the installer.

1 Like

Yeah. It’s a non-standard workflow, probably written just enough for devs to put into their desktop terminals, and may not be POSIX compliant, which means it is more or less pseudo-Linux. As you seem to suggest, it may not be a big enough priority for Ghost devs to get it to standard.

Sorting-out that workflow may indeed help grow their market enormously, but the team doesn’t seem to see that right now.

As for choosing Arch and MariaDB, they only grow. This from two days ago:

Arch Linux and Valve [SteamOS] Collaboration

This probably closes the discussion for now.