Deploying rails app using apache and passenger on ubuntu

Hey all

If you want to use apache to deploy your rails app than passenger has made your task really easy.

I assume that you have already installed apache if not do it using

sudo apt-get install apache2

Now follow these steps below and get going.

First step it to install passenger gem using

sudo gem install passenger

Once done the next step is to install the apache2 module for passenger using

sudo passenger-install-apache2-module.

I will prompt you with an option. Select #1

When you do this it will start compiling the files and will prompt for errors if any. Like when I did it for the first time I was asked to installed a couple of missing lib files required to configure along passenger. Example

apt-get install lib-curl4-openssl-dev

apt-get install apache2-prefork-dev

apt-get install libapr1-dev

apt-get install libaprutil1-dev

If every thing is installed file it will ask you to add few lines to your httpd.conf file.

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.13/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.13
PassengerRuby /usr/bin/ruby1.8

Once thats done. You will again need to add few more likes to your httpd.conf file which is actually setting up DocumentRoot for you app. will looks something like


ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to ‘public’!
DocumentRoot /somewhere/public

# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews

Make sure you replace the DocumentRoot with a valid path.

So the final conf file will look like this

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13
PassengerRuby /usr/local/bin/ruby


ServerName www.domain.com
# !!! Be sure to point DocumentRoot to ‘public’!
DocumentRoot /var/www/app/public

# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews

Once done close your file and restart apache using

/etc/init.d/apache2 restart

go you your url and check if it works. If not let me know I shall guide you but I think there should not be any issues.

Isn’t that really simple? Yes it is. Njoy Rails.

Be Sociable, Share!

Ubuntu boots into terminal with no xstart and readonly file system

Hi all

If you face this weird problem where your Ubuntu machine starts in terminal mode with no xstart option. try the following commands.

Try to first scan your system using fsck if that doesn’t work or it get stuck after few % try the next step.

type Xstart on the command prompt and press enter. still no success?

try apt-get update and if you see that your file system is read-only. Try the commands below

First of all shutdown your system using

shutdown -r now -F

once restarted try to remount your root partition using the following command

mount -o remount,rw /

If none of the above method works. Insert a Live Ubuntu CD. use GUI tool to scan your system by opening disk utility from the following path.
System > Administration > Disk Utility

Hope this solves your problem. If it doesn’t do post a comment and I shall try to help you out.

Njoi

Be Sociable, Share!

solve no such file to load — openssl error

Hi all

Was updating one server with rails 2.2.2 to rails 2.3.8. I upgraded ruby from 1.8.6 to 1.8.7 and also rubygems to 1.3.4 version from a source. When i did ruby script/server to start the server I got this error no such file to load — openssl

After a 15 mins R&D i found that this usually happens on an Ubuntu machine (which it was in my case). The solution is as follows

First install libssl using

sudo apt-get install libssl-dev

Than go to the source of ruby and go to the following path

cd ext/openssl

Run the command one after the others.

ruby extconf.rb
make
sudo make install

Now try to do ruby script/server again……and boooooooom! solved.. Even after trying this you are stuck let me know I shall help you out.

Thanks

Be Sociable, Share!

Install VNC server on Ubuntu Server

Hi all

sometimes VNC is really useful when you want to access the remote server. Though every thing can be done via command prompt but sometimes a GUI is useful (Atleast I find it useful).

Now if you want to do that here are the steps you need to follow. As you know that most or all servers dont come with Gnome installed. So thats the first step you need to do

Start with the following command

sudo apt-get update

Than install the Gnome-Core components using

sudo apt-get install gnome-core

Now install a virtual desktop using

sudo apt-get install vnc4server

Now setup a password to login using the following command. It will prompt to setup a password and verify it

vncpasswd

Than run the vnc server using

vncserver :1

Now before you proceed kill it once using

vncserver -kill :1

Now open the config file from .vnc/xstartup or ~/.vnc/xstartup

using nano .vnc/xstartup (I perfer nano you may use vim or vi)

Than uncomment the line which says

unset SESSION_MANAGER

And add sh to the line below it like this

exec sh /etc/X11/xinit/xinitrc

Exit the file and run the command as below

vncserver :1 -depth 16 -geometry 1028×1024

Than download tightVNC from http://www.tightvnc.com/download.html

connect using ip:1 (:1 is for the vnc server window)

You might see a dialog box with error and a delete option. Click delete and done 🙂

You now have GUI access to your server.

You may want to install synaptic using

apt-get install synaptic

Thats all.. Hope this article helps. If you get stuck do write to me.

Be Sociable, Share!

Install Tokyo cabinet on ubuntu + ruby

Every came across a task where in you get a task to insert 1 million + records in few hours? than the answer is NOSQL
Use Tokyo Cabinet. Here are the installation steps for the same.

First of all download the latest version of tokyocabinet via the following url

wget http://fallabs.com/tokyocabinet/tokyocabinet-1.4.47.tar.gz
tar xvf tokyocabinet-1.4.47.tar.gz
cd tokyocabinet-1.4.47
./configure
make
make install

Next step is to install the ruby library which you can download from the url below

wget http://fallabs.com/tokyocabinet/rubypkg/tokyocabinet-ruby-1.31.tar.gz

tar xvf tokyocabinet-ruby-1.31.tar.gz
cd tokyocabinet-ruby-1.31
ruby extconf.rb
make
make install

Now to verify you installation go to irb

irb(main):001:0> require ‘rubygems’
=> true

irb(main):002:0> require ‘tokyocabinet’
=> true

Done. If you get any errors while doing this please free to comment. Thanks

Be Sociable, Share!

solve libxslt is missing error when installing omniauth or nokogiri

I was trying to install omniauth and was getting error for nokogiri libxslt is missing. If you are facing the same issue you may solve it using the following command. I have tested it with ubuntu and it worked for me. Its not tested on Fedora but should work.

on Ubuntu 10

sudo apt-get install libxml2 libxml2-dev libxslt libxslt-dev

on Ubuntu 11

sudo apt-get install libxml2 libxml2-dev libxslt1-dev

On fedora

sudo yum install libxml2-devel libxslt-devel

If you still face issues do write to me.

Thanks

Be Sociable, Share!
1 2 3 4 5 22