Host Jekyll Site with Nginx
CHECKLIST
- Firewall port
- SELinux
- Force SSL(ssl on configure) should be off at first
Nginx site related configure:
server {
root <static_file_path>;
index index.html;
listen [::]:80;
listen 80;
listen 443 ssl;
listen [::]:443 ssl;
server_name kirisame.tips www.kirisame.tips marisa.kirisame.tips;
location / {
}
error_page 404 /404.html;
location = 404.html {
}
ssl on;
ssl_certificate <PATH_TO_CERT>;
ssl_certificate_key <PATH_TO_PRIVKEY>;
}
Install jekyll, use RVM may make build easier, e.g:
- Add
export PATH="$PATH:$HOME/.rvm/bin"
to.bashrc
$ rvm install 2.5.3
$ rvm use ruby-2.5.3
Generate HTML (from this pull request):
$ JEKYLL_ENV=production bundle exec jekyll build -d _deploy
Using JEKYLL_ENV=production if you set google analytics tracking ID so minima or other theme you’re using will render tracking script.
Change files privilege:
$ cd <PATH_TO_DEPLOY_FOLDER>
$ chmod o+x `find . -type d`
$ chmod o-x `find . -type f`
TODO
- In Fedora 25, Nginx static file folder not in
/usr/share/nginx/html
, even SELinux was disabled, Nginx still return a permission denied when access. - An automatic way to change files privilege.