Topic: Configure Kete with Apache2 and Passenger

Topic type:

Setup an Apache2 configuration file to point to your install of Kete.

Originally written by Kieran Pilkington, Kete Developer for Katipo Communications, Ltd.

Part of the Installation Guide


Add a VHost entry for your Kete instance

Because of the differences in operating system setups of apache, there are different locations for this page. Take note of the one you're using, and make the changes in the code samples when needed.

Mac Users:             [vhosts_file] = /etc/apache2/extra/httpd-vhosts.conf  (append to file)
openSUSE Users:  [vhosts_file] = /etc/apache/vhosts.d/[your_app_name].conf   (create new file)
Debian Users:        [vhosts_file] = /etc/apache/sites-available/[your_app_name]  (create new file)

Simple Kete Installation

If you arn't deploying your application using Capistrano (thus making a simple install), create/edit [vhosts_file], and add the following to it. (be sure to replace the name, path and host of your application.)

RailsAutoDetect off
<VirtualHost *:80>
ServerName your_app.com
DocumentRoot /home/kete/apps/your_app_name/public
<Directory /home/kete/apps/your_app_name/public>
Options FollowSymLinks
Options -MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# gzip html, css and js
AddOutputFilterByType DEFLATE text/html text/css application/x-javascript application/javascript
# far future expires headers
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresDefault "access plus 10 years"
</FilesMatch>
RailsBaseURI /
</VirtualHost>

Passenger assumes you want to run your server in production mode. If you want to run it in development mode instead (the default everywhere else in the simple installation), add this line as well (can be done globally in Apache main config file or within VirtualHost declaration to be specific to a particular site configuration):

RailsEnv development

Deployed Kete Installation (with Capistrano)

If you are deploying your application to your production server, create/edit [vhosts_file], and add the following to it. (be sure to replace the name, path and host of your application.)

RailsAutoDetect off
<VirtualHost *:80>
ServerName your_app.com
DocumentRoot /home/kete/apps/your_app_name/current/public
<Directory /home/kete/apps/your_app_name/current/public>
Options FollowSymLinks
Options -MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# gzip html, css and js
AddOutputFilterByType DEFLATE text/html text/css application/x-javascript application/javascript
# far future expires headers
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresDefault "access plus 10 years"
</FilesMatch>
RailsBaseURI /
</VirtualHost>

Debian Installations only (skip this if using mac or opensuse)

Now, for both simple and deployed installs, add a symlink to enable your new site:

root@host: # a2ensite [vhosts_file]

Check the site has been created correctly:

root@host: # ls /etc/apache2/sites-enabled

You should get something like the following:

lrwxrwxrwx 1 root root 36 Sep 17 12:00 000-default -> /etc/apache2/sites-available/default
lrwxrwxrwx 1 root root 41 Sep 17 12:30 your_app_name -> /etc/apache2/sites-available/your_app_name

If you get a command not found error for a2ensite, you can do the following to achieve the same result:

root@host: # cd /etc/apache2/sites-enabled
root@host: # ln -s /etc/apache2/sites-available/your_app_name

All systems (Debian, openSUSE, and Mac)

Restart Apache

And finally enabled deflate and expires modes, and restart Apache2 to load the new configuration file.

root@host: # a2enmod deflate # skip for Mac OS X
root@host: # a2enmod expires # skip for Mac OS X
root@host: # apache2ctl restart # MAC OS X users may need to change command to apachectl

Any configuration errors will become apparent now. Fix any issues that come up.

Configure Kete to use Apache's X-sendfile

Change the following line in your_app/config/initializers/send_file_options.rb

SENDFILE_METHOD = ""

to

SENDFILE_METHOD = "apache"

and save it.



Next step:
Configure your Kete site

Discuss This Topic

There are 2 comments in this discussion.

Read and join this discussion

join this discussion

Creative Commons Attribution-Share Alike 3.0 New Zealand License
Configure Kete with Apache2 and Passenger by Kieran P is licensed under a Creative Commons Attribution-Share Alike 3.0 New Zealand License