Merge pull request #3848 from vitalyrepin/patch-1

Merge pull request 3848
This commit is contained in:
Parker Moore 2015-07-31 10:32:42 -07:00
commit 1eba5093bd
1 changed files with 64 additions and 2 deletions

View File

@ -89,11 +89,73 @@ Setup steps are fully documented
Another way to deploy your Jekyll site is to use [Rake](https://github.com/jimweirich/rake), [HighLine](https://github.com/JEG2/highline), and Another way to deploy your Jekyll site is to use [Rake](https://github.com/jimweirich/rake), [HighLine](https://github.com/JEG2/highline), and
[Net::SSH](https://github.com/net-ssh/net-ssh). A more complex example of deploying Jekyll with Rake that deals with multiple branches can be found in [Git Ready](https://github.com/gitready/gitready/blob/cdfbc4ec5321ff8d18c3ce936e9c749dbbc4f190/Rakefile). [Net::SSH](https://github.com/net-ssh/net-ssh). A more complex example of deploying Jekyll with Rake that deals with multiple branches can be found in [Git Ready](https://github.com/gitready/gitready/blob/cdfbc4ec5321ff8d18c3ce936e9c749dbbc4f190/Rakefile).
### scp
Once youve generated the `_site` directory, you can easily scp it using a `tasks/deploy` shell script similar to [this deploy script here](https://github.com/henrik/henrik.nyh.se/blob/master/script/deploy). Youd obviously need to change the values to reflect your sites details. There is even [a matching TextMate command](http://gist.github.com/214959) that will help you run this script from within Textmate.
### rsync ### rsync
Once youve generated the `_site` directory, you can easily rsync it using a `tasks/deploy` shell script similar to [this deploy script here](https://github.com/henrik/henrik.nyh.se/blob/master/script/deploy). Youd obviously need to change the values to reflect your sites details. There is even [a matching TextMate command](http://gist.github.com/214959) that will help you run Once youve generated the `_site` directory, you can easily rsync it using a `tasks/deploy` shell script similar to [this deploy script here](https://github.com/vitalyrepin/vrepinblog/blob/master/transfer.sh). Youd obviously need to change the values to reflect your sites details.
this script from within Textmate.
#### Step 1: Install rrsync to your home folder (server-side)
We will use certificate-based authorization to simplify the publishing process. It makes sense to restrict rsync access only to the directory which it is supposed to sync.
That's why rrsync wrapper shall be installed. If it is not already installed by your hoster you can do it yourself:
- [download rrsync](http://ftp.samba.org/pub/unpacked/rsync/support/rrsync)
- Put it to the bin subdirectory of your home folder (```~/bin```)
- Make it executable (```chmod +x```)
#### Step 2: Setup certificate-based ssh access (server side)
[This process is described in a lot of places in the net](https://wiki.gentoo.org/wiki/SSH#Passwordless_Authentication). We will not cover it here. What is different from usual approach is to put the restriction to certificate-based authorization in ```~/.ssh/authorized_keys```). We will launch ```rrsync``` utility and supply it with the folder it shall have read-write access to:
```
command="$HOME/bin/rrsync <folder>",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-rsa <cert>
```
```<folder>``` is the path to your site. E.g., ```~/public_html/you.org/blog-html/```.
#### Step 3: Rsync! (client-side)
Add the script ```deploy``` to the web site source folder:
{% highlight shell %}
#!/bin/sh
rsync -avr --rsh='ssh -p2222' --delete-after --delete-excluded <folder> <user>@<site>:
{% endhighlight %}
Command line parameters are:
- ```--rsh='ssh -p2222'``` It is needed if your hoster provides ssh access using ssh port different from default one (e.g., this is what hostgator is doing)
- ```<folder>``` is the name of the local folder with generated web content. By default it is ```_site/``` for Jekyll
- ```<user>``` &mdash; ssh user name for your hosting account
- ```<site>``` &mdash; your hosting server
Example command line is:
{% highlight shell %}
rsync -avr --rsh='ssh -p2222' --delete-after --delete-excluded _site/ hostuser@vrepin.org:
{% endhighlight %}
Don't forget column ':' after server name!
#### Optional step 4: exclude transfer.sh from being copied to the output folder by Jekyll
This step is recommended if you use this how-to to deploy Jekyll-based web site. If you put ```deploy``` script to the root folder of your project, Jekyll copies it to the output folder.
This behavior can be changed in ```_config.yml```. Just add the following line there:
{% highlight yaml %}
# Do not copy these file to the output directory
exclude: ["deploy"]
{% endhighlight %}
#### We are done!
Now it's possible to publish your web site by launching ```deploy``` script. If your ssh certificate is [passphrase-protected](https://martin.kleppmann.com/2013/05/24/improving-security-of-ssh-private-keys.html), you are asked to enter the password.
## Rack-Jekyll ## Rack-Jekyll