When installing ghost using the Ubuntu docs I receive an error on "ghost install"

When running “ghost install” on my vps I receive this error.

webmaster@website:/var/www/site$ ghost install

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org



A SystemError occurred.

Message: Current directory is not empty, Ghost cannot be installed here.

Debug Information:
    OS: Ubuntu, v22.04.2 LTS
    Node Version: v12.22.9
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost install'

Try running ghost doctor to check your system for known issues.

You can always refer to https://ghost.org/docs/ghost-cli/ for troubleshooting.
webmaster@website:/var/www/site$ ghost install

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org



✔ Checking system Node.js version - found v12.22.9
✔ Checking current folder permissions
✔ Checking memory availability
✔ Checking free space
✔ Checking for latest Ghost version
✔ Setting up install directory
✖ Downloading and installing Ghost v5.43.0
An error occurred.
Message: 'fs.rmSync is not a function'


Debug Information:
    OS: Ubuntu, v22.04.2 LTS
    Node Version: v12.22.9
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost install'

Additional log info available in: /home/webmaster/.ghost/logs/ghost-cli-debug-2023-04-12T20_20_58_053Z.log

Try running ghost doctor to check your system for known issues.

You can always refer to https://ghost.org/docs/ghost-cli/ for troubleshooting.

This is the problem. Make sure you create an empty directory to install Ghost, e.g., /var/www/ghost.

1 Like

Now I get this error after reseting my vps and starting with a fresh os.

web@website:/var/www/home$ ghost install

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org



✔ Checking system Node.js version - found v16.19.1
✔ Checking current folder permissions
✔ Checking memory availability
✔ Checking free space
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v5.43.0
✔ Finishing install process
? Enter your blog URL: https://aidan-a.me
? Enter your MySQL hostname: localhost
? Enter your MySQL username: web-root
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: home_prod
✔ Configuring Ghost
✔ Setting up instance
+ sudo useradd --system --user-group ghost
+ sudo chown -R ghost:ghost /var/www/home/content
✔ Setting up "ghost" system user
ℹ Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes
+ sudo mv /tmp/aidan-a-me/aidan-a.me.conf /etc/nginx/sites-available/aidan-a.me.conf
+ sudo ln -sf /etc/nginx/sites-available/aidan-a.me.conf /etc/nginx/sites-enabled/aidan-a.me.conf
+ sudo nginx -s reload
✔ Setting up Nginx
? Do you wish to set up SSL? Yes
? Enter your email (For SSL Certificate) legotrain2008@gmail.com
+ sudo mkdir -p /etc/letsencrypt
+ sudo ./acme.sh --install --home /etc/letsencrypt
+ sudo /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --server letsencrypt --domain aidan-a.me --webroot /var/www/home/system/nginx-root --reloadcmd "nginx -s reload" --accountemail legotrain2008@gmail.com
+ sudo openssl dhparam -dsaparam -out /etc/nginx/snippets/dhparam.pem 2048
+ sudo mv /tmp/ssl-params.conf /etc/nginx/snippets/ssl-params.conf
+ sudo mv /tmp/aidan-a-me/aidan-a.me-ssl.conf /etc/nginx/sites-available/aidan-a.me-ssl.conf
+ sudo ln -sf /etc/nginx/sites-available/aidan-a.me-ssl.conf /etc/nginx/sites-enabled/aidan-a.me-ssl.conf
+ sudo nginx -s reload
✔ Setting up SSL
? Do you wish to set up Systemd? Yes
+ sudo mv /tmp/aidan-a-me/ghost_aidan-a-me.service /lib/systemd/system/ghost_aidan-a-me.service
+ sudo systemctl daemon-reload
✔ Setting up Systemd
+ sudo systemctl is-active ghost_aidan-a-me
? Do you want to start Ghost? Yes
+ sudo systemctl start ghost_aidan-a-me
+ sudo systemctl stop ghost_aidan-a-me
✖ Starting Ghost
One or more errors occurred.

1) GhostError

Message: Ghost was able to start, but errored during boot with: Access denied for user 'web-root'@'localhost' (using password: YES)
Help: Unknown database error
Suggestion: journalctl -u ghost_aidan-a-me -n 50

Debug Information:
    OS: Ubuntu, v22.04.2 LTS
    Node Version: v16.19.1
    Ghost Version: 5.43.0
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost install'

Additional log info available in: /home/web/.ghost/logs/ghost-cli-debug-2023-04-13T14_11_19_982Z.log

Try running ghost doctor to check your system for known issues.

You can always refer to https://ghost.org/docs/ghost-cli/ for troubleshooting.
web@website:/var/www/home$ cd
web@website:~$ journalctl -u ghost_aidan-a-me -n 50
Hint: You are currently not seeing messages from other users and the system.
      Users in groups 'adm', 'systemd-journal' can see all messages.
      Pass -q to turn off this notice.
-- No entries --
web@website:~$ cd /var/www/home
web@website:/var/www/home$ ghost doctor

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org


✔ Checking system Node.js version - found v16.19.1
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_aidan-a-me
+ sudo systemctl reset-failed ghost_aidan-a-me
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking free space
✔ Checking systemd unit file
✔ Checking systemd node version - found v16.19.1
web@website:/var/www/home$ 

Did you have this site running previously, i.e., was this the reason the directory wasn’t empty?

Ok so this morning I reset my vps(fresh install of Ubuntu.) When I did a fresh install of ghost I received the error from post number 4(When installing ghost using the Ubuntu docs I receive an error on "ghost install" - #4 by Aidan)

Please share the output from the above command.

Hint: You are currently not seeing messages from other users and the system.
      Users in groups 'adm', 'systemd-journal' can see all messages.
      Pass -q to turn off this notice.
-- No entries --
web@website:/var/www/home$ ```

Try using sudo with the command.

Apr 13 14:27:23 website node[16911]: Error ID:
Apr 13 14:27:23 website node[16911]:     500
Apr 13 14:27:23 website node[16911]: Error Code: 
Apr 13 14:27:23 website node[16911]:     ER_ACCESS_DENIED_ERROR
Apr 13 14:27:23 website node[16911]: ----------------------------------------
Apr 13 14:27:23 website node[16911]: Error: Access denied for user 'web-root'@'localhost' (using password: YES)
Apr 13 14:27:23 website node[16911]:     at /var/www/home/versions/5.43.0/node_modules/knex-migrator/lib/database.js:57:19
Apr 13 14:27:23 website node[16911]:     at Packet.asError (/var/www/home/versions/5.43.0/node_modules/mysql2/lib/packets/packet.js:728:17)
Apr 13 14:27:23 website node[16911]:     at ClientHandshake.execute (/var/www/home/versions/5.43.0/node_modules/mysql2/lib/commands/command.js:29:26)
Apr 13 14:27:23 website node[16911]:     at Connection.handlePacket (/var/www/home/versions/5.43.0/node_modules/mysql2/lib/connection.js:489:32)
Apr 13 14:27:23 website node[16911]:     at PacketParser.onPacket (/var/www/home/versions/5.43.0/node_modules/mysql2/lib/connection.js:94:12)
Apr 13 14:27:23 website node[16911]:     at PacketParser.executeStart (/var/www/home/versions/5.43.0/node_modules/mysql2/lib/packet_parser.js:75:16)
Apr 13 14:27:23 website node[16911]:     at Socket.<anonymous> (/var/www/home/versions/5.43.0/node_modules/mysql2/lib/connection.js:101:25)
Apr 13 14:27:23 website node[16911]:     at Socket.emit (node:events:513:28)
Apr 13 14:27:23 website node[16911]:     at addChunk (node:internal/streams/readable:315:12)
Apr 13 14:27:23 website node[16911]:     at readableAddChunk (node:internal/streams/readable:289:9)
Apr 13 14:27:23 website node[16911]:     at Socket.Readable.push (node:internal/streams/readable:228:10)
Apr 13 14:27:23 website node[16911]:     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
Apr 13 14:27:23 website node[16911]: 
Apr 13 14:27:23 website node[16911]: [2023-04-13 14:27:23] WARN Ghost is shutting down
Apr 13 14:27:23 website node[16911]: [2023-04-13 14:27:23] WARN Ghost has shut down
Apr 13 14:27:23 website node[16911]: [2023-04-13 14:27:23] WARN Your site is now offline
Apr 13 14:27:23 website node[16911]: [2023-04-13 14:27:23] WARN Ghost was running for a few seconds
Apr 13 14:27:23 website node[16911]: [2023-04-13 14:27:23] INFO Bootstrap client was closed.
Apr 13 14:27:23 website systemd[1]: Stopping Ghost systemd service for blog: aidan-a-me...
Apr 13 14:27:24 website node[16882]: /usr/lib/node_modules/ghost-cli/lib/process-manager.js:46
Apr 13 14:27:24 website node[16882]:         throw error;
Apr 13 14:27:24 website node[16882]:         ^
Apr 13 14:27:24 website node[16882]: {
Apr 13 14:27:24 website node[16882]:   message: {
Apr 13 14:27:24 website node[16882]:     statusCode: 500,
Apr 13 14:27:24 website node[16882]:     errorType: 'DatabaseError',
Apr 13 14:27:24 website node[16882]:     level: 'critical',
Apr 13 14:27:24 website node[16882]:     message: "Ghost was able to start, but errored during boot with: Access denied for user 'web-root'@'localhost' (u>
Apr 13 14:27:24 website node[16882]:     id: 500,
Apr 13 14:27:24 website node[16882]:     help: 'Unknown database error',
Apr 13 14:27:24 website node[16882]:     name: 'DatabaseError',
Apr 13 14:27:24 website node[16882]:     code: 'ER_ACCESS_DENIED_ERROR',
Apr 13 14:27:24 website node[16882]:     property: null,
Apr 13 14:27:24 website node[16882]:     redirect: null,
Apr 13 14:27:24 website node[16882]:     hideStack: false,
Apr 13 14:27:24 website node[16882]:     errno: 1045,
Apr 13 14:27:24 website node[16882]:     sqlState: '28000',
Apr 13 14:27:24 website node[16882]:     sqlMessage: "Access denied for user 'web-root'@'localhost' (using password: YES)"
Apr 13 14:27:24 website node[16882]:   }
Apr 13 14:27:24 website node[16882]: }
Apr 13 14:27:24 website systemd[1]: ghost_aidan-a-me.service: Main process exited, code=exited, status=1/FAILURE
lines 1-47```

Your MySQL user doesn’t have permission to access the Ghost database.

The following may resolve the issue, but it would be helpful if you could share the instructions you used to set up Ghost, since there may be other issues.

sudo mysql -u root -p

GRANT ALL PRIVILEGES ON home_prod.* TO 'web-root'@'localhost';
FLUSH PRIVILEGES;
QUIT;

When installing ghost im using the documentation from the docs and followed step by step.

After running to command above I get this error that seems to be the same as before.

web@website:/var/www/home$ cd
web@website:~$ sudo mysql -u root -p
[sudo] password for web: 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.32-0ubuntu0.22.04.2 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> GRANT ALL PRIVILEGES ON home_prod.* TO 'web-root'@'localhost';
ERROR 1410 (42000): You are not allowed to create a user with GRANT
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> QUIT;
Bye
web@website:~$ cd /var/www/home
web@website:/var/www/home$ ghost start

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org


+ sudo systemctl is-active ghost_aidan-a-me
+ sudo systemctl reset-failed ghost_aidan-a-me
✔ Checking system Node.js version - found v16.19.1
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_aidan-a-me
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking systemd unit file
✔ Checking systemd node version - found v16.19.1
+ sudo systemctl start ghost_aidan-a-me
+ sudo systemctl stop ghost_aidan-a-me
✖ Starting Ghost: aidan-a-me
A GhostError occurred.

Message: Ghost was able to start, but errored during boot with: Access denied for user 'web-root'@'localhost' (using password: YES)
Help: Unknown database error
Suggestion: journalctl -u ghost_aidan-a-me -n 50

Debug Information:
    OS: Ubuntu, v22.04.2 LTS
    Node Version: v16.19.1
    Ghost Version: 5.43.0
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost start'

Additional log info available in: /home/web/.ghost/logs/ghost-cli-debug-2023-04-13T16_33_03_385Z.log

Try running ghost doctor to check your system for known issues.

You can always refer to https://ghost.org/docs/ghost-cli/ for troubleshooting.
web@website:/var/www/home$ 

Okay, so you don’t have the DB user setup. You also appear to have two users: web and web-root. Which is the Ghost user?

Please share the output from:

groups web
groups web-root

when installing ghost the docs told me to add a user to my vps(web) hence web@website. Later the docs told me to setup and asked me to fill-in a db name and user. the user is web-root.

If it makes more sense, I can uninstall ghost(using “ghost uninstall” and re install ghost(using ghost install) and send a complete log file of the setup.

I understand now. Nonetheless, please share the output from groups web.

web@website:/var/www/home$ groups web
web : web sudo
web@website:/var/www/home$

The Ghost user has sudo privileges, so the issue is most likely related to your database setup.

It would seem that you haven’t set up the database user. This is what I’d do.

sudo mysql -u root -p

CREATE USER 'web-root'@'localhost' IDENTIFIED BY '<password>';
CREATE DATABASE home_prod;
GRANT ALL PRIVILEGES ON home_prod.* TO 'web-root'@'localhost';
FLUSH PRIVILEGES;
QUIT;

Substitute with the same password you used when setting up Ghost. Now try restarting Ghost: ghost start.

this seems to have fixed this issue. Thanks! Ghost will start but i can’t access the site. I get Safari can’t connect.

1 Like

Whats the output from ghost ls?

Also, share the message from Safari.

from running ghost start.

web@website:/var/www/home$ ghost start

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org


+ sudo systemctl is-active ghost_aidan-a-me
? Sudo Password [hidden]
? Sudo Password [hidden]
? Sudo Password [hidden]
+ sudo systemctl reset-failed ghost_aidan-a-me
✔ Checking system Node.js version - found v16.19.1
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_aidan-a-me
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking systemd unit file
✔ Checking systemd node version - found v16.19.1
+ sudo systemctl start ghost_aidan-a-me
+ sudo systemctl is-enabled ghost_aidan-a-me
+ sudo systemctl enable ghost_aidan-a-me --quiet
✔ Starting Ghost: aidan-a-me

------------------------------------------------------------------------------

Your admin interface is located at: 

    https://aidan-a.me/ghost/

web@website:/var/www/home$ 

When running ghost ls

web@website:/var/www/home$ ghost ls

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org


+ sudo systemctl is-active ghost_aidan-a-me
? Sudo Password [hidden]
┌────────────┬───────────────┬─────────┬──────────────────────┬────────────────────┬──────┬─────────────────┐
│ Name       │ Location      │ Version │ Status               │ URL                │ Port │ Process Manager │
├────────────┼───────────────┼─────────┼──────────────────────┼────────────────────┼──────┼─────────────────┤
│ aidan-a-me │ /var/www/home │ 5.43.0  │ running (production) │ https://aidan-a.me │ 2368 │ systemd         │
└────────────┴───────────────┴─────────┴──────────────────────┴────────────────────┴──────┴─────────────────┘
web@website:/var/www/home$ 

From safari

I see, too many redirects. You have an A-record for the domain. Moreover, the default server works on https://www.aidan-a.me/.

Please list contents of /etc/nginx/sites-enabled, and share the config file for your Ghost site (found in /etc/nginx/sites-available).