-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatom.xml
More file actions
425 lines (323 loc) · 27 KB
/
atom.xml
File metadata and controls
425 lines (323 loc) · 27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Software Development Stuff]]></title>
<link href="http://blog.tommijarvinen.com/atom.xml" rel="self"/>
<link href="http://blog.tommijarvinen.com/"/>
<updated>2014-03-13T19:27:51+02:00</updated>
<id>http://blog.tommijarvinen.com/</id>
<author>
<name><![CDATA[Tommi Järvinen]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[Ruby on Rails Server With Nginx, Phusion Passenger and PostgreSQL]]></title>
<link href="http://blog.tommijarvinen.com/blog/2014/03/07/rails-server-with-nginx-passenger-and-postgresql/"/>
<updated>2014-03-07T16:36:02+02:00</updated>
<id>http://blog.tommijarvinen.com/blog/2014/03/07/rails-server-with-nginx-passenger-and-postgresql</id>
<content type="html"><![CDATA[<h2>Introduction</h2>
<p>Instructions for setting up Ubuntu 12.04.4 LTS to host a Ruby on Rails Application with nginx as the web server, Phusion Passenger as the application server and PostgreSQL as the database. This has been tested on a clean installation of Ubuntu 12.04.4, but should work on existing installation and different versions with little changes as well. This is one of my first blog posts so take that into account when giving feedback.</p>
<h2>Installation</h2>
<p>Write the following inside a script file and run it (Or run the commands one by one). It will add the Phusion Passenger repositories to apt sources, install it, install rbenv, ruby and bundler, stuff required to compile Ruby, PostgreSQL and nginx. Feel free to customize the script to your needs. If you prefer RVM to rbenv just change the corresponding lines etc.:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c">#!/usr/bin/env bash</span>
</span><span class='line'>sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
</span><span class='line'><span class="nb">echo</span> <span class="s2">"deb https://oss-binaries.phusionpassenger.com/apt/passenger precise main"</span> | sudo tee -a /etc/apt/sources.list.d/passenger.list
</span><span class='line'>sudo apt-get update
</span><span class='line'>sudo apt-get install -y apt-transport-https ca-certificates
</span><span class='line'>sudo apt-get install -y git build-essential nodejs postgresql postgresql-server-dev-9.1 libssl-dev nginx-extras passenger libcurl4-openssl-dev
</span><span class='line'>git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
</span><span class='line'><span class="nb">echo</span> <span class="s1">'export PATH="$HOME/.rbenv/bin:$PATH"'</span> >> ~/.bash_profile
</span><span class='line'><span class="nb">echo</span> <span class="s1">'eval "$(rbenv init -)"'</span> >> ~/.bash_profile
</span><span class='line'>git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
</span><span class='line'><span class="nb">source</span> ~/.bash_profile
</span><span class='line'>rbenv install -v 2.1.1 <span class="c"># replace with the ruby version that you want to use</span>
</span><span class='line'>rbenv global 2.1.1 <span class="c"># replace with the ruby version that you want to use</span>
</span><span class='line'>gem install -V bundler
</span></code></pre></td></tr></table></div></figure>
<h2>Configuration</h2>
<p>Change the following lines in /etc/nginx/nginx.conf:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># Phusion Passenger config</span>
</span><span class='line'><span class="c">##</span>
</span><span class='line'><span class="c"># Uncomment it if you installed passenger or passenger-enterprise</span>
</span><span class='line'><span class="c">##</span>
</span><span class='line'>
</span><span class='line'><span class="c"># passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;</span>
</span><span class='line'><span class="c"># passenger_ruby /usr/bin/ruby;</span>
</span><span class='line'>
</span><span class='line'><span class="c">##</span>
</span><span class='line'><span class="c"># Virtual Host Configs</span>
</span><span class='line'><span class="c">##</span>
</span></code></pre></td></tr></table></div></figure>
<p>to:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># Phusion Passenger config</span>
</span><span class='line'><span class="c">##</span>
</span><span class='line'><span class="c"># Uncomment it if you installed passenger or passenger-enterprise</span>
</span><span class='line'><span class="c">##</span>
</span><span class='line'>
</span><span class='line'>passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
</span><span class='line'>passenger_ruby /<path/to/where/you/installed/ruby>/bin/ruby;
</span><span class='line'>
</span><span class='line'><span class="c">#Add the following line if you don't want passenger to display friendly debug information when your application fails to start:</span>
</span><span class='line'>passenger_friendly_error_pages off;
</span><span class='line'>
</span><span class='line'><span class="c">##</span>
</span><span class='line'><span class="c"># Virtual Host Configs</span>
</span><span class='line'><span class="c">##</span>
</span></code></pre></td></tr></table></div></figure>
<p>(Default ruby installation directory is /home/<username>/.rbenv/versions/<ruby-version>)</p>
<p>Generate a ssh keypair and add your public key to where you deploy from (If you need to and use git with ssh). Otherwise just do whatever you need to get your application to the server. Guide to ssh key generation can be found at <a href="https://help.github.com/articles/generating-ssh-keys" title="https://help.github.com/articles/generating-ssh-keys" target="_blank"><a href="https://help.github.com/articles/generating-ssh-keys">https://help.github.com/articles/generating-ssh-keys</a></a></p>
<p>Clone your repo to a directory of your choosing (If you use git):</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>git clone <your-git-repo-address>
</span></code></pre></td></tr></table></div></figure>
<p>Add an user to postgresql with the name and password you specified in the production database config in your database.yml:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>sudo -u postgres psql
</span></code></pre></td></tr></table></div></figure>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>create user <username> with password <span class="s1">'<password>'</span>;
</span></code></pre></td></tr></table></div></figure>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>alter role <username> createdb;
</span></code></pre></td></tr></table></div></figure>
<p>To exit psql prompt, type:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="se">\q</span>
</span></code></pre></td></tr></table></div></figure>
<p>Change the local authentication line in /etc/postgresql/9.1/main/pg_hba.conf:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># TYPE DATABASE USER ADDRESS METHOD</span>
</span><span class='line'>
</span><span class='line'><span class="c"># "local" is for Unix domain socket connections only</span>
</span><span class='line'><span class="nb">local </span>all all peer
</span><span class='line'><span class="c"># IPv4 local connections:</span>
</span><span class='line'>host all all 127.0.0.1/32 md5
</span></code></pre></td></tr></table></div></figure>
<p>to:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># TYPE DATABASE USER ADDRESS METHOD</span>
</span><span class='line'>
</span><span class='line'><span class="c"># "local" is for Unix domain socket connections only</span>
</span><span class='line'><span class="nb">local </span>all all md5
</span><span class='line'><span class="c"># IPv4 local connections:</span>
</span><span class='line'>host all all 127.0.0.1/32 md5
</span></code></pre></td></tr></table></div></figure>
<p>to allow password authentication to postgresql</p>
<p>And then restart postgresql:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>sudo service postgresql restart
</span></code></pre></td></tr></table></div></figure>
<p>source ~/.bash_profile to get access to rbenv and new commands of the gems that were installed:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span><span class="nb">source</span> ~/.bash_profile
</span></code></pre></td></tr></table></div></figure>
<p>Go to your rails application root and run bundle install:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>bundle install --without development <span class="nb">test</span>
</span></code></pre></td></tr></table></div></figure>
<p>Make sure your secret token is specified in your application’s config/application.yml if you’re using the <a href="https://github.com/laserlemon/figaro" title="https://github.com/laserlemon/figaro" target="_blank">figaro</a> gem. If not, you can generate a new one with the following command in your rails apps’s root:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>rake secret
</span></code></pre></td></tr></table></div></figure>
<p>Then just add that to <your/rails/application/root>/config/application.yml:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SECRET_TOKEN: <generated-token-here>
</span></code></pre></td></tr></table></div></figure>
<p>If you are using ssl, now is the time to import your certificates or generate them. The following configurations assume they are stored in /etc/nginx/ssl/</p>
<p>Create a file to /etc/nginx/sites-enabled/ with the name of the name of your application and add the following contents Replace leading whitespaces with tabs if nginx complains about them:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>server <span class="o">{</span>
</span><span class='line'> listen 80;
</span><span class='line'> server_name <your-domain-here>;
</span><span class='line'> root <your/rails/application/root>/public;
</span><span class='line'> passenger_enabled on;
</span><span class='line'><span class="o">}</span>
</span><span class='line'>
</span><span class='line'><span class="c"># Comment this out if you are using SSL</span>
</span><span class='line'><span class="c"># server {</span>
</span><span class='line'> <span class="c"># listen 443 ssl;</span>
</span><span class='line'> <span class="c"># server_name <your-domain-here>;</span>
</span><span class='line'> <span class="c"># passenger_enabled on;</span>
</span><span class='line'> <span class="c"># root <your/rails/application/root>/public;</span>
</span><span class='line'> <span class="c"># ssl_certificate /etc/nginx/ssl/server.crt; # Replace with the path to your certificate</span>
</span><span class='line'> <span class="c"># ssl_certificate_key /etc/nginx/ssl/server.key; # Replace with the path to your key</span>
</span><span class='line'><span class="c"># }</span>
</span></code></pre></td></tr></table></div></figure>
<p>Then modify /etc/nginx/nginx.conf to only include that site configuration:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'> <span class="c">##</span>
</span><span class='line'> <span class="c"># Virtual Host Configs</span>
</span><span class='line'> <span class="c">##</span>
</span><span class='line'>
</span><span class='line'> include /etc/nginx/conf.d/*.conf;
</span><span class='line'> include /etc/nginx/sites-enabled/<the-server-conf-file-you-created>;
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>Go to your rails application root and run the following commands:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ RAILS_ENV</span><span class="o">=</span>production rake db:setup assets:precompile
</span></code></pre></td></tr></table></div></figure>
<p>Then restart nginx:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>sudo service nginx restart
</span></code></pre></td></tr></table></div></figure>
<p>Your application should now be served properly by nginx on port 80 :) If you run into problems, check the logs at /var/log/nginx to see whether they help identify the problem.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Vagrant for Ruby on Rails Development on Ubuntu 13.10]]></title>
<link href="http://blog.tommijarvinen.com/blog/2014/03/03/vagrant-for-ruby-on-rails-development-on-ubuntu-13-dot-10/"/>
<updated>2014-03-03T15:12:17+02:00</updated>
<id>http://blog.tommijarvinen.com/blog/2014/03/03/vagrant-for-ruby-on-rails-development-on-ubuntu-13-dot-10</id>
<content type="html"><![CDATA[<h2>Installing</h2>
<p>Vagrant can be installed on Ubuntu via apt-get, but the version is really old. I downloaded the .deb -file from <a href="http://www.vagrantup.com/downloads.html.">http://www.vagrantup.com/downloads.html.</a></p>
<h2>Configuring</h2>
<p>First create a folder for your project and go to that folder. The following command will initialize a new vagrant virtual machine and use Ubuntu Precise as the base:</p>
<pre><code>$ vagrant init precise32 http://files.vagrantup.com/precise32.box
</code></pre>
<p>Vagrant will also create a Vagrantfile in the working directory. Open the file for editing and the change the following line:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'> <span class="c1"># Create a forwarded port mapping which allows access to a specific port</span>
</span><span class='line'> <span class="c1"># within the machine from a port on the host machine. In the example below,</span>
</span><span class='line'> <span class="c1"># accessing "localhost:8080" will access port 80 on the guest machine.</span>
</span><span class='line'> <span class="c1"># config.vm.network :forwarded_port, guest: 80, host: 8080</span>
</span></code></pre></td></tr></table></div></figure>
<p>to</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'> <span class="c1"># Create a forwarded port mapping which allows access to a specific port</span>
</span><span class='line'> <span class="c1"># within the machine from a port on the host machine. In the example below,</span>
</span><span class='line'> <span class="c1"># accessing "localhost:8080" will access port 80 on the guest machine.</span>
</span><span class='line'> <span class="n">config</span><span class="o">.</span><span class="n">vm</span><span class="o">.</span><span class="n">network</span> <span class="ss">:forwarded_port</span><span class="p">,</span> <span class="ss">guest</span><span class="p">:</span> <span class="mi">3000</span><span class="p">,</span> <span class="ss">host</span><span class="p">:</span> <span class="mi">3000</span>
</span></code></pre></td></tr></table></div></figure>
<p>to forward the default Rails development port to the virtual machine.
Now create two script files to the same directory with Vagrantfile. We will include all software installation in those scripts. You can name the scripts as you like, the names that I use are just examples:</p>
<pre><code>$ nano installation.sh
</code></pre>
<p>I have put the following commands into the first scripts that will be run as root. Feel free to customize these commands to your liking. Node.js is included because its needed for some javascript operations:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c">#!/usr/bin/env bash</span>
</span><span class='line'><span class="nb">echo</span> -e <span class="s2">"deb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse\ndeb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse\ndeb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse\ndeb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse\n$(cat /etc/apt/sources.list)"</span> > /etc/sources.list
</span><span class='line'>apt-get update
</span><span class='line'>apt-get install -y git build-essential nodejs libsqlite3-dev
</span></code></pre></td></tr></table></div></figure>
<p>After this create another script file to be run as normal user. The script will first install rbenv for easy switching between different Ruby versions. Then it will install a version of Ruby, in my case 2.1.0. It will then set that version of Ruby to be the global default. Finally it will install Rails and Bundler:</p>
<pre><code>$ nano installation_user.sh
</code></pre>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c">#!/usr/bin/env bash</span>
</span><span class='line'>git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
</span><span class='line'><span class="nb">echo</span> <span class="s1">'export PATH="$HOME/.rbenv/bin:$PATH"'</span> >> ~/.bash_profile
</span><span class='line'><span class="nb">echo</span> <span class="s1">'eval "$(rbenv init -)"'</span> >> ~/.bash_profile
</span><span class='line'>git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
</span><span class='line'><span class="nb">source</span> ~/.bash_profile
</span><span class='line'>rbenv install -v 2.1.0 <span class="c"># replace with the ruby version that you want to use</span>
</span><span class='line'>rbenv global 2.1.0 <span class="c"># replace with the ruby version that you want to use</span>
</span><span class='line'>gem install rails
</span><span class='line'>gem install bundler
</span></code></pre></td></tr></table></div></figure>
<p>After this add the following lines to Vagrantfile to include your new shell scripts:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'> <span class="n">config</span><span class="o">.</span><span class="n">vm</span><span class="o">.</span><span class="n">provision</span> <span class="ss">:shell</span><span class="p">,</span> <span class="ss">path</span><span class="p">:</span> <span class="s2">"installation.sh"</span>
</span><span class='line'> <span class="n">config</span><span class="o">.</span><span class="n">vm</span><span class="o">.</span><span class="n">provision</span> <span class="ss">:shell</span><span class="p">,</span> <span class="ss">path</span><span class="p">:</span> <span class="s2">"installation_user.sh"</span><span class="p">,</span> <span class="ss">privileged</span><span class="p">:</span> <span class="kp">false</span>
</span></code></pre></td></tr></table></div></figure>
<p>After this the configuration for your Ruby on Rails development environment should be configured and you can start the Vagrant box with the following command:</p>
<pre><code>$ vagrant up
</code></pre>
<p>The startup will take some time the first time because it will install the whole system like you previously configured. After the process has finished you can ssh to your new virtual machine with the command:</p>
<pre><code>$ vagrant ssh
</code></pre>
<p>The directory where you most likely will want to initialize your Rails project(s) inside the virtual machine is:</p>
<pre><code>/vagrant/
</code></pre>
<p>Since it will be shared between your guest and host machine. You should now be set up to start developing your application.</p>
]]></content>
</entry>
</feed>