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
|
# File 'lib/pointer/nginx_passenger.rb', line 3
def install_passenger()
unless file_exists('/opt/nginx')
what 'Install nginx/passenger'
rvm!('gem install passenger')
@ssh.exec!('sudo mkdir /opt')
@ssh.exec!('sudo mkdir /opt/nginx')
@ssh.exec!('sudo chown rails:rails /opt/nginx')
rvm!('passenger-install-nginx-module --auto --auto-download --prefix=/opt/nginx')
what "Installing nginx init.d"
@ssh.exec!('sudo wget https://raw.github.com/slava-vishnyakov/useful-stuff/master/init.d-nginx.conf -O /etc/init.d/nginx')
what "Changing nginx.conf permissions"
@ssh.exec!('sudo chmod o+x /etc/init.d/nginx')
what "update-rc.d"
@ssh.exec!('sudo update-rc.d nginx defaults')
what "Installing nginx.conf"
@ssh.exec!('mv /opt/nginx/conf/nginx.conf /opt/nginx/conf/nginx.conf-orig')
@ssh.exec!('wget https://raw.github.com/slava-vishnyakov/useful-stuff/master/nginx.conf -O /opt/nginx/conf/nginx.conf')
what "Replacing passenger_ruby and passenger_root with actual Passenger data"
orig_file = get_file_contents '/opt/nginx/conf/nginx.conf-orig'
new_file = get_file_contents '/opt/nginx/conf/nginx.conf'
new_file.sub! /passenger_ruby (.*?);/, orig_file.match(/passenger_ruby (.*?);/)[0]
new_file.sub! /passenger_root (.*?);/, orig_file.match(/passenger_root (.*?);/)[0]
put_file_contents '/opt/nginx/conf/nginx.conf', new_file
what "Creating /opt/nginx/conf/rails-sites"
@ssh.exec!('mkdir /opt/nginx/conf/rails-sites')
what "Starting nginx"
@ssh.exec!('sudo service nginx start')
end
end
|