Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nginx): customisable paths & program name #932

Merged
merged 1 commit into from
May 30, 2019

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented May 26, 2019

no issue

  • Respect environment variables that customise where nginx lives and what it is called
  • Use env vars, not config, because this will be system-wide
  • Allows CLI to work with "flavours" of nginx, like OpenResty

The two env vars are:

NGINX_PROGRAM_NAME
NGINX_CONFIG_PATH

I did wonder as part of this if dpkg -l | grep xxx is the best way to find out if something is installed, and whether using which, or a version check, might be more interoperable 🤔 (thinking about the case of symlinking openresty as nginx)

no issue

- Respect environment variables that customise where nginx lives and what it is called
- Use env vars, not config, because this will be system-wide
- Allows CLI to work with "flavours" of nginx, like OpenResty
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b4393ff on ErisDS:openresty into 3bf34ad on TryGhost:master.

@ErisDS
Copy link
Member Author

ErisDS commented May 27, 2019

Currently verifying this patch, seems to be working 👍

@ErisDS
Copy link
Member Author

ErisDS commented May 27, 2019

Soooo this is definitely working as desired, however if you use OpenResty instead of nginx, there are a couple of gotchas, where openresty doesn't quite have the same setup as nginx out-of-the box.

Main thing is that instead of /etc/nginx/ our config path will be /usr/local/openresty/nginx/conf. I tried a couple of different things to change this, but fighting it makes life harder & symlinks don't quite seem to work nicely either, so you'll want to set the following env vars:

export NGINX_PROGRAM_NAME=openresty
export NGINX_CONFIG_PATH=/usr/local/openresty/nginx/conf

(I put them in /etc/profile.d/ghostcli-openresty.sh, so they are global)

Once you've done that you'll want to create the following folders:

sites-available, sites-enabled, snippets, conf.d inside of /usr/local/openresty/nginx/conf owned by root and with perms 755. The rest of the standard nginx files are there, but these folders are missing.

Then you'll want to update /usr/local/openresty/nginx/conf/nginx.confto have include /usr/local/openresty/nginx/conf/sites-enabled/*; instead of a server block...

If you want a default file for sites-enabled to test openresty is still working, this works:

server {
    listen       80;
    server_name  localhost;

    location / {
        root   html;
        index  index.html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

You also need a /var/www/ folder owned by root with perms 775.

Finally, once you're done with setting up, the last thing to do before running ghost install is always test that sudo openresty -s reload works cleanly, cos if there are issues, it borks the setup really late in the process!

@acburdine acburdine self-assigned this May 28, 2019
@acburdine acburdine added this to the 1.10.1 milestone May 28, 2019
Copy link
Member

@acburdine acburdine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worked 👍

@acburdine acburdine merged commit 94389d5 into TryGhost:master May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants