Cannot install ghost on Ubuntu 18.04 server


#1

Issue Summary

Cannot install ghost according to the documentation because of permission errors.

To Reproduce

// server and user setup

  1. Launch an Ubuntu Server 18.04 LTS (HVM), SSD Volume Type - ami-0bbe6b35405ecebdb (64-bit x86) / ami-0db180c518750ee4f (64-bit Arm) instance on AWS.
  2. SSH into the instance.
  3. sudo adduser sarthak
  4. sudo usermod -aG sudo sarthak
  5. sudo ufw allow OpenSSH
  6. sudo ufw enable

//nodejs setup
7. curl -sL https://deb.nodesource.com/setup_8.x-o nodesource_setup.sh
8. sudo bash nodesource_setup.sh
9. sudo apt-get install nodejs

//ghost cli
10. sudo npm i -g ghost-cli

//ghost directory
11. cd /var/
12. sudo mkdir www
13. cd www
14. sudo mkdir ghost
15. sudo -su sarthak
16. sudo chown $USER:$USER /var/www/ghost

//ngingx install

  1. sudo apt-get update
  2. sudo apt-get install nginx

//mysql install

  1. sudo apt-get install mysql-server
  2. sudo mysql_secure_installation

// ghost installation

  1. cd /var/www/ghost/
  2. ghost install
  3. blog url: blog.example.com, mysql hostname: localhost, mysql_username: root, ghost db name: ghost_prod

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

This is the error on the output console:

✔ Checking system Node.js version
✔ Checking logged in user
✔ Checking current folder permissions
✔ Checking operating system compatibility
✔ Checking for a MySQL installation
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v2.9.0
✔ Finishing install process
? Enter your blog URL: https://blog.example.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: root
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost_prod
✔ Configuring Ghost
✖ Setting up instance
An error occurred.
Message: 'EACCES: permission denied, mkdir '/home/ubuntu/.ghost''


Debug Information:
    OS: Ubuntu, v18.04
    Node Version: v8.14.0
    Ghost-CLI Version: 1.9.8
    Environment: production
    Command: 'ghost install'
A promise was rejected but did not have a .catch() handler:
Error: EACCES: permission denied, mkdir '/home/ubuntu/.ghost'
    at Object.fs.mkdirSync (fs.js:885:18)
    at mkdirsSync (/usr/lib/node_modules/ghost-cli/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:31:9)
    at Object.mkdirsSync (/usr/lib/node_modules/ghost-cli/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:36:14)
    at System.writeErrorLog (/usr/lib/node_modules/ghost-cli/lib/system.js:359:12)
    at UI.error (/usr/lib/node_modules/ghost-cli/lib/ui/index.js:446:40)
    at precheck.then.catch (/usr/lib/node_modules/ghost-cli/lib/command.js:188:16)
    at <anonymous>
/usr/lib/node_modules/ghost-cli/lib/bootstrap.js:28
    throw reason;
    ^

Error: EACCES: permission denied, mkdir '/home/ubuntu/.ghost'
    at Object.fs.mkdirSync (fs.js:885:18)
    at mkdirsSync (/usr/lib/node_modules/ghost-cli/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:31:9)
    at Object.mkdirsSync (/usr/lib/node_modules/ghost-cli/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:36:14)
    at System.writeErrorLog (/usr/lib/node_modules/ghost-cli/lib/system.js:359:12)
    at UI.error (/usr/lib/node_modules/ghost-cli/lib/ui/index.js:446:40)
    at precheck.then.catch (/usr/lib/node_modules/ghost-cli/lib/command.js:188:16)
    at <anonymous>

What I tried

Using the “ls -l” command on the /home directory gives me the following output:

total  8
drwxr-xr-x 2 sarthak sarthak 4096 Dec 19 07:44 sarthak
drwxr-xr-x 7 ubuntu  ubuntu  4096 Dec 19 07:40 ubuntu

I set the permission for the /home/ubuntu to ‘drwxwrxr-x’. Then I added the user sarthak to the ubuntu group.The installation was sucessful. However upon restart I could not connect to the instance through ssh because ssh does not allow any user belonging to the same group to write on the $HOME directory because then the user will be able to change the ssh config files located in $HOME/.ssh. What would be an appropriate fix and why can’t I install ghost by following the official installation instructions?

Technical details:

  • Ghost Version: 2.9.0
  • Node Version: v8.14.0
  • Browser/OS: Ubuntu, v18.04
  • Database: MySQL
  • Ghost-CLI Version: 1.9.8
  • Environment: production
  • Command: ‘ghost install’

Any help will be appreciated. Thanks.


#2

It seems that you ran the node install commands as the ubuntu user rather than the sarthak user (although with sudo that shouldn’t matter). It seems that npm cannot intall its components in /home/ubuntu/ (as the command is later run as sarthak user).

Check if you have the .npm folder in /home/sarthak/ or /home/ubuntu/. You can do a ghost uninstall and try to reinstall it.

You can actually use the ubuntu user to do the install and own the Ghost directory (I have that setup and all works well).

4 drwxr-xr-x 5 ubuntu ubuntu 4096 Dec 18 11:29 domain.com


#3

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.