Install Ruby, Apache, and some required utility packages
sudo aptitude install ruby apache2-mpm-prefork build-essential ruby-dev libopenssl-ruby \
apache2-prefork-dev libapr1-dev libaprutil1-dev git-core irb
sudo aptitude install ruby apache2-mpm-prefork build-essential ruby-dev libopenssl-ruby \
apache2-prefork-dev libapr1-dev libaprutil1-dev git-core irb
- Get the latest Gem package manager (the file ending in .tgz) from the gem distribution.
- Unzip and install (version 1.3.6 for example)
tar -zxf rubygems-1.3.6.tgzcd rubygems-1.3.6sudo ruby ./setup.rbcd /usr/binsudo ln -s gem1.8 gem
By default gems installs all the documentation with the gems. That is a waste
of time and space on servers. Fix like so:
vi ~/.gemrc
And add this line:
gem: --no-ri --no-rdoc
sudo gem install rails
sudo gem install passengersudo passenger-install-apache2-module- And follow the excellent Passenger instructions.
Create a file in /etc/apache2/sites-available/ and add the following
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /path/to/railsapp/public
<Directory />
Options -MultiViews
AllowOverride All
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
If your site needs ssl create another file in sites-available and add the following
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin [email protected]
DocumentRoot /path/to/railsapp/public
<Directory />
Options -MultiViews
AllowOverride All
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/ssl_access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
#If you have it
SSLCertificateChainFile /etc/apache2/ssl/gd_bundle.crt
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>
</IfModule>
If your site uses ssl you’ll want a simple self signed certificate for your
staging server so you can test it.
openssl genrsa -des3 -out server.key.orig 2048 openssl req -new -key server.key.orig -out server.csr openssl rsa -in server.key.org -out server.key openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Use log rotate or your logs will eventually consume all your disk space.
Logrotate is probably already installed so just create a file in /etc/logrotate.d/
with content like this:
/path/to/railsapp/log/*.log {
daily
missingok
rotate 5
compress
delaycompress
notifempty
copytruncate
}
This adapter is updated regularly. Follow these excellent Ubuntu Install Instructions