Set up Ubuntu server 7.10 gusty Ruby on Rails and Webmin

Posted by Joel Jensen Thu, 24 Jan 2008 15:31:07 GMT

Download and install ubuntu 32bit ( trust me ) 7.10 server

Install, when it asks select LAMP installation

Answer questions and install, it takes about 30 minutes

When finished login and run from command line:

Follow these instructions:

Taken from: ssh webmin and ip configuration Configuring Static ip address in Ubuntu server

Ubuntu installer has configured our system to get its network settings via DHCP, Now we will change that to a static IP address for this you need to edit Edit /etc/network/interfaces and enter your ip address details (in this example setup I will use the IP address 172.19.0.10):

sudo vi /etc/network/interfaces

and enter the following save the file and exit

The primary network interface

auto eth0
iface eth0 inet static
address 172.19.0.10
netmask 255.255.255.0
network 172.19.0.0
broadcast 172.19.0.255
gateway 172.19.0.1

Now you need to restart your network services using the following command

sudo /etc/init.d/networking restart

You need to setup manually DNS servers in resolv.conf file when you are not using DHCP.

sudo vi /etc/resolv.conf

You need to add look something like this

search domain.com

nameserver xxx.xxx.xxx.xxx

Install SSH Server

If you want to access your server remotely through SSH you need to install SSH server for this you need to run the following command

sudo apt-get install ssh openssh-server

You will be prompted to insert the installation CD again and this will complete SSH server in your Gutsy lamp server.This is really simple and easy server installation for new users and who wants a quick server.

Installing Webmin in Ubuntu Gutsy Gibbon

Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.

You can install webmin for your server web interface to configure apache,mysql servers.Now we will see how to install webmin in Ubuntu 7.10

Preparing your system

First you need to install the following packages

sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl

Now download the latest webmin using the following command

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.370_all.deb

Now we have webmin1.370all.deb package install this package using the following command

sudo dpkg -i webmin_1.370_all.deb

This will complete the installation.

Ubuntu in particular don’t allow logins by the root user by default. However, the user created at system installation time can use sudo to switch to root. Webmin will allow any user who has this sudo capability to login with full root privileges.

Now you need to open your web browser and enter the following

https://your-server-ip:10000/

Install Subversion tools

sudo apt-get install subversion

Installing rails

Taken from: Here

sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby
wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
tar xzvf rubygems-1.0.1.tgz
cd rubygems-1.0.1
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system
sudo gem install rails
sudo apt-get install build-essential ruby1.8-dev
sudo gem install mongrel
sudo apt-get install mysql-client mysql-admin mysql-query-browser 
sudo apt-get install libmysqlclient15-dev
sudo gem install mysql
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
sudo gem install sqlite3-ruby
echo "export RUBYOPT=rubygems" >> ~/.profile
rails path/to/your/app

Install ImageMagick

sudo apt-get install imagemagick
sudo apt-get install libmagick9-dev
sudo gem install rmagick -v 1.15.12

Add Modules to Apache

cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/headers.load
sudo ln -s ../mods-available/deflate.conf
sudo ln -s ../mods-available/deflate.load
sudo ln -s ../mods-available/proxy_ajp.load
sudo ln -s ../mods-available/proxy_balancer.load
sudo ln -s ../mods-available/proxy.conf
sudo ln -s ../mods-available/proxy_connect.load
sudo ln -s ../mods-available/proxy_ftp.load
sudo ln -s ../mods-available/proxy_http.load
sudo ln -s ../mods-available/proxy.load
sudo ln -s ../mods-available/rewrite.load

Set up apache

Add a www folder to your home directory

mkdir ~/www

Add this to your apache config file, at the end

/etc/apache2/sites-enabled/000-default

<VirtualHost * >
    ServerName YOUR-SERVER-NAME.com
    CustomLog /var/log/apache2/YOUR-SERVER-NAME.log combined
    DocumentRoot /home/YOUR-USERNAME/www/current/public
    <Directory "/home/YOUR-USERNAME/www/current/public">
            Options FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
    </Directory>
    RewriteEngine On   
    RewriteRule /html / [L,P,QSA]
    # Don't do forward proxying  
    # Enable reverse proxying
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    # RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
    # RewriteCond %{SCRIPT_FILENAME} !maintenance.html
    # RewriteRule ^.*$ /system/maintenance.html [L]
    RewriteRule ^/$ /index.html [QSA] 
    RewriteRule ^([^.]+)$ $1.html [QSA]
    # Redirect all non-static requests to cluster
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
    RewriteRule .* http://127.0.0.1:3000%{REQUEST_URI} [L,P,QSA]

    # Deflate
    AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/xml application/xhtml+xml text/javascript 
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

</VirtualHost>

Set up ssl here

Restart Apache

sudo /etc/init.d/apache2

Prepare site for rails

From your development machine, where you are working on the new rails site.

Install capistrano if you havent

gem install capistrano

Capify your site, if you haven’t cd #{rails_root} capify .

Install Subversion

Instructions here

Add your site to subversion, if you havent already

cd {RAILS_ROOT}
cd ..
svn mkdir http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME -m'adding project'
svn mkdir http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME/trunk -m'adding project'
svn mkdir http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME/branches -m'adding project'
svn mkdir http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME/tags -m'adding project'
svn add . http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME/trunk -m'adding project'

Edit the {RAILS_ROOT}/config/deploy.rb cap deploy

DONE