Around a half a year ago I started slowly switching my servers to Apache mod_rails. I wasn't very keen after my first test around September on one of my Slicehost servers. Without any application running apache, ruby and postgresql processes tookup around 500MB of memory - around 100MB per processes. When I experimented with my other servers I found out this happens on 64bit architecture - 32bit servers took up less than half of that memory. I am still running performance tests to compare the performance and behavior of mod_rails vs Lighttpd - I'll be writing about it soon.
For now here's the installation for Hardy Heron (I assume you have the build-essential, ruby and so on already installed):
sudo apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert apache2-prefork-dev
sudo gem install passenger
sudo passenger-install-apache2-module
Now add the 3 generated lines (almost last on the screen) to config file:
sudo vim /etc/apache2/apache2.conf
Right now it looks something like the following -
BUT THE VERSION NUMBERS WILL CHANGE SO COPY THE LINES FROM THE PREVIOUS PROCESS
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.2/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.2
PassengerRuby /usr/local/bin/ruby
In the same config file add the server name and NameVirtualHost otherwise the server will complain at restart:
ServerName XYZ
NameVirtualHost *:80
save the config file and continue - we'll need to enable modrewrite and disable default site:
sudo a2enmod rewrite
sudo a2dissite default
now just configure your application by adding your_app_name to /etc/apache2/sites-available/ with the following content:
sudo vim /etc/apache2/sites-available/your_app_name
<VirtualHost *:80>
ServerName abc.def.com
ServerAlias xyz.com
DocumentRoot /home/bohm/rails/access/current/public
</VirtualHost>
where abc.def.com and xyz.com are the URLs of your application and DocumentRoot points to the public folder of your application.
To enable the application run
sudo a2ensite your_app_name
sudo /etc/init.d/apache2 reload
To disable it run
sudo a2dissite your_app_name
sudo /etc/init.d/apache2 reload
And you're done :-)
No comments:
Post a Comment