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
Hi,
You are in a little bit of a pickle.
Essentially it comes down the fact that you ventured off the beaten path of the conventions of the Installation Guide. This would be fine, but only if you have a good understanding of the underlying tools and how they are configured, because you are somewhat on your own.
Is this meant to be run as a production server? If so, I'm REALLY REALLY concerned that you are trying to run the Kete site as root. If you have access to the root account, as it sounds like you do, I would strongly advise you create a "kete" user and use the conventions of the Installation Guide instead. An alternative is to use the user that Apache does on your system, but personally I find this muddies the waters.
On to your current specific issues:
- The site-enabled/sites-available directories are a Debian Linux convention, as such, they aren't necessarily on OpenSuse, though the version of Apache we generally use is 2.2, I believe.
- It looks like the kete2_production database doesn't exist. Are you sure you created it? Are you sure you granted your mysql user the right to read it? Check your config/database.yml and use the following to see if you can connect:
mysql -u your_user_name -p kete2_production
Enter the corresponding username from the config/database.yml and when prompted the password from that file, too. If you can't connect successfully, you should probably connect to the mysql database as the mysql root user and create the databases and users you need.
Tags: mysql, Troubleshooting, Installation, Databases, root, apache2 conf
Ann Le
said apache2 conf
Hi there,
My collegue set up the server for me. It is open suse, and already have apache 2, mysql, and php on that.
The thing is I cannot find the site-availables or site-enabled folder, I assume the reason might be the difference in version of apache (we use Apache 2.2 ) .
the document root is /usr/webpages/
so I put the kete into the /usr/webpages/kete2
and the
in the vhosts.d folder name the file is kete-httpd.conf.
This folder is included in the httpd.conf file, so I think apache will run it.
Then create the symlink to point /usr/webpages/ to /usr/webpages/kete2/
But then I browse the server IP, I see the blank page.
Then I read the error log for apache 2, the last section are
The other thing is when I run the db:bootstrap, I have to run under root, because if I run under the username created before , it keep point to the /home/kete/... which is not the right place.
Sorry for a very long reading, I just want to describe the situation. Should I add something into the mysql users db ?
Thanks a lot in advance.
Regards,
Ann