Hosting a Typo blog with Apache 2.2, Proxy_balancer, Mongrel and MySQL on Gentoo
Because I had some small problems and hickups during my installation, I decided to write a howto guide for this installation. Make sure to also read my previous post about XMLRPC and page breaks with Typo 5.2 if you're installing Typo 5.2, these bugs should be fixed in later versions.
Read on for the entire guide!
This guide uses the following versions of these packages:
These are the latest versions available (in the ~x86 tree) while I'm writing this.
If you want to install these versions and are not using the ~x86 keyword then use the following command (this command should also work just fine if you are using the ~x86 keyword):
(remove the -p on the end if the output of the command looks OK)
I cannot guarantee this guide will work if you are using different versions than these. (I cannot even guarantee it works when you are...)
If you are upgrading from Apache 2.0 to 2.2, follow (http://www.gentoo.org/proj/en/apache/doc/upgrading.xml) this guide. Make sure you add the following keywords to APACHE2_MODULES in /etc/make.conf after running the code on that page, if they are not already in there:
You need to re-emerge Apache after adding these keywords:
You may also be missing some modules wich were previously in the default configuration of Apache, the ebuild will warn you about that. Just add them to the APACHE2_MODULES variable in make.conf and re-emerge Apache again.
Open and login to MySQL and create a database for your blog and add an account for Typo to use:
Install the Typo gem:
Create a directory for your blog (/var/www/blog for example)
Install the Typo blog engine:
Configure your Typo database in /var/www/blog/config/database.yml
Configure Mongrel to start the correct number of servers, and use the correct paths for log and pid files:
Start your Mongrel cluster (make sure your working directory is the root of the Typo directory):
Set up your Apache configuration. I used this little bit to make Apache proxy the request through to your Mongrel cluster. Make sure to proxy the same ports as you've configured for Mongrel:
I would provide a source for this, but my Googling turns up thousands of sites providing this code, I don't remember where I've got it from...
See the "empty" folder in the document root? It is recommended so set the document root for setups like this to an empty folder. I presume this is so people won't be able to download any configuration files if you've configured something wrong and the proxy isn't working... You will need to create this directory yourself.
Also, you will need to enable name based virtual hosts for this to work, I wanted to use Typo on one vhost and use regular php and perl/cgi web applications on other vhosts...
Restart your Apache server:
You should now have a working Typo blog!
If something is not working after you've followed this guide to the letter, then I've probably had you do something wrong. (very likely one of the Apache modules..) Leave a comment or send me an email if you can't get it to work.
This guide uses the following versions of these packages:
Code:
app-admin/eselect-ruby-20081227
app-admin/eselect-rails-0.14
dev-lang/ruby-1.8.6_p287-r11
dev-ruby/rubygems-1.3.1
dev-ruby/mysql-ruby-2.8
dev-ruby/activesupport-2.2.2
dev-ruby/gem_plugin-0.2.3
dev-ruby/daemons-1.0.10
dev-ruby/cgi_multipart_eof_fix-2.5.0
dev-ruby/fastthread-1.0.1
dev-ruby/rake-0.8.3
dev-ruby/actionpack-2.2.2
www-servers/mongrel-1.1.5
dev-ruby/activerecord-2.2.2
dev-ruby/activeresource-2.2.2
dev-ruby/actionmailer-2.2.2
www-servers/mongrel_cluster-1.0.5
dev-ruby/rails-2.2.2-r1
www-servers/apache-2.2.11These are the latest versions available (in the ~x86 tree) while I'm writing this.
If you want to install these versions and are not using the ~x86 keyword then use the following command (this command should also work just fine if you are using the ~x86 keyword):
Code:
ACCEPT_KEYWORDS="~x86" emerge =app-admin/eselect-ruby-20081227 =app-admin/eselect-rails-0.14 =dev-lang/ruby-1.8.6_p287-r11 =dev-ruby/rubygems-1.3.1 =dev-ruby/mysql-ruby-2.8 =dev-ruby/activesupport-2.2.2 =dev-ruby/gem_plugin-0.2.3 =dev-ruby/daemons-1.0.10 =dev-ruby/cgi_multipart_eof_fix-2.5.0 =dev-ruby/fastthread-1.0.1 =dev-ruby/rake-0.8.3 =dev-ruby/actionpack-2.2.2 =www-servers/mongrel-1.1.5 =dev-ruby/activerecord-2.2.2 =dev-ruby/activeresource-2.2.2 =dev-ruby/actionmailer-2.2.2 =www-servers/mongrel_cluster-1.0.5 =dev-ruby/rails-2.2.2-r1 =www-servers/apache-2.2.11 -p(remove the -p on the end if the output of the command looks OK)
I cannot guarantee this guide will work if you are using different versions than these. (I cannot even guarantee it works when you are...)
If you are upgrading from Apache 2.0 to 2.2, follow (http://www.gentoo.org/proj/en/apache/doc/upgrading.xml) this guide. Make sure you add the following keywords to APACHE2_MODULES in /etc/make.conf after running the code on that page, if they are not already in there:
Code:
- rewrite
- proxy_http
- proxy
- proxy_balancerYou need to re-emerge Apache after adding these keywords:
Code:
emerge =www-servers/apache-2.2.11 -pYou may also be missing some modules wich were previously in the default configuration of Apache, the ebuild will warn you about that. Just add them to the APACHE2_MODULES variable in make.conf and re-emerge Apache again.
Open and login to MySQL and create a database for your blog and add an account for Typo to use:
Code:
CREATE DATABASE myTypoBlog;
GRANT ALL ON myTypoBlog.* to `myTypoUser`@`localhost` identified by `myTypoPassword`;Install the Typo gem:
Code:
gem install typo
Create a directory for your blog (/var/www/blog for example)
Install the Typo blog engine:
Code:
typo install /var/www/blog
Configure your Typo database in /var/www/blog/config/database.yml
Configure Mongrel to start the correct number of servers, and use the correct paths for log and pid files:
Code:
mongrel_rails cluster::configure -e production -p 8000 -l log/mongrel.log -P /var/run/mongrel.pid -N 5 -n 5 -C config/mongrel_cluster.ymlStart your Mongrel cluster (make sure your working directory is the root of the Typo directory):
Code:
mongrel_rails cluster::startSet up your Apache configuration. I used this little bit to make Apache proxy the request through to your Mongrel cluster. Make sure to proxy the same ports as you've configured for Mongrel:
Code:
<Proxy balancer://mongrel_cluster>
BalancerMember http://127.0.0.1:8000
BalancerMember http://127.0.0.1:8001
BalancerMember http://127.0.0.1:8002
BalancerMember http://127.0.0.1:8003
BalancerMember http://127.0.0.1:8004
</Proxy>
<VirtualHost *:80>
ServerName blog.bqlabs.nl
DocumentRoot /var/www/blog/empty
<Directory "/var/www/blog/empty" >
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]
# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]
# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
</VirtualHost>See the "empty" folder in the document root? It is recommended so set the document root for setups like this to an empty folder. I presume this is so people won't be able to download any configuration files if you've configured something wrong and the proxy isn't working... You will need to create this directory yourself.
Also, you will need to enable name based virtual hosts for this to work, I wanted to use Typo on one vhost and use regular php and perl/cgi web applications on other vhosts...
Restart your Apache server:
Code:
/etc/init.d/apache restartYou should now have a working Typo blog!
If something is not working after you've followed this guide to the letter, then I've probably had you do something wrong. (very likely one of the Apache modules..) Leave a comment or send me an email if you can't get it to work.
Posted in Tutorials | no comments |