Catalyst
From DreamHost
| This article or section may require a cleanup. We are hoping to create articles that meet certain standards. Please discuss this issue on the talk page. Editing help is available. |
Contents |
Catalyst Web Framework
Catalyst is an MVC web development framework. More details can be found on Wikipedia or at the official website.
Installing on DreamHost
| The instructions provided in this article or section are considered advanced. You are expected to be knowledgeable in the UNIX shell. |
| The instructions provided in this article or section require shell access unless otherwise stated. You can use the PuTTY client on Windows, or SSH on UNIX and UNIX-like systems such as Linux or Mac OS X. |
Disclaimer
This installation was performed on the caprisun server on 2007-06-04. Other servers may yield different results.
Configure your site in the panel
You're going to need some space to work, and a shell account. You may wish to create a subdomain and account specifically for learning to use Catalyst on DreamHost.
- Log into the control panel
- Domains > Manage Domains > Add New Domain
- Domain To Host: catalyst.yourdomain.com
- FastCGI Support: YES
- FTP User: Create New User
- How do you like the www?:' Select Remove WWW
- Create your domain
- Users > Manage Users > username
- User Account Type: Shell Account
- Set your password: MakeItAG0odP4ssw0RD!\ ITSyourSHELL!
Configure a custom CPAN user environment
You're going to be creating your own CPAN library for your user account. You need to alter your shell environment to accommodate the custom lib directories. Each Perl application you write that uses these libraries will need 'use lib' declarations.
Log into your shell account and add the following lines to both of these files. Then log out of your shell, and log back in to ensure the changes have taken effect.
- ~/.bash_profile
- ~/.bashrc
# define custom perl libraries
perlversion=`perl -v | grep 'built for' | awk '{print $4}' | sed -e 's/v//;'`
export PATH=$HOME/local/bin:$HOME/local/script:$PATH
export PERL5LIB=$HOME/local/lib/perl5
export PERL5LIB=$PERL5LIB:$HOME/local/share/perl/$perlversion
export PERL5LIB=$PERL5LIB:$HOME/local/lib/perl/$perlversion
export PERL5LIB=$PERL5LIB:$HOME/local/lib
Configure CPAN to use user library
- From the shell, run cpan, answer no and type bye.
- edit the following lines in ~/.cpan/CPAN/MyConfig.pm
- Be sure to replace USERNAME with your username
...
'make_install_arg' => q[SITEPREFIX=/home/USERNAME/local],
'makepl_arg' => q[INSTALLDIRS=site install_base=/home/USERNAME/local],
...
'urllist' => [q{http://cpan.pair.com/}],
Install and build lots
- Log into your shell: Make sure you are in bash
- bash
- perl -MCPAN -e 'install Module::Build'
- wget http://www.shadowcatsystems.co.uk/static/cat-install
- perl cat-install ( you may need to run this a few times before it can get all the dependencies installed
- perl -MCPAN -e 'install Catalyst::Devel'
- cp ~/.cpan/build/Catalyst-Runtime-5.7007/script/catalyst.pl ~/local/bin ( Do this now, because after installing the upcoming list, cpan is probably going to purge it's build cache. Version number may be different for your build )
- run cpan and pass it this install list. Then pass it the same list just to be sure. Maybe even a third time if you're a skittish person. Four times is just silly.
install Template::Timer install PadWalker install Cache::FastMmap install Devel::Caller install Devel::LexAlias install Catalyst::Plugin::ConfigLoader install Catalyst::Plugin::Static::Simple install Catalyst::Plugin::StackTrace install Catalyst::Model::CDBI install DBIx::Class::ResultSource install Class::DBI::SQLite install Catalyst::Model::DBIC::Schema install Catalyst::Helper::Model::DBIC::Schema install Catalyst::Helper::View::TT install Catalyst::Helper::View::TTSite install Catalyst::Plugin::Authentication install Catalyst::Plugin::Authentication::Store::DBIC install Catalyst::Plugin::Authentication::Credential::Password install Catalyst::Plugin::Session install Catalyst::Plugin::Session::Store::FastMmap install Catalyst::Plugin::Session::State::Cookie install Catalyst::Plugin::Authorization::Roles install Catalyst::Action::RenderView install Catalyst::Controller::BindLex install Catalyst::Plugin::I18N
- If everything looks good, say bye to cpan and get back to your shell
N.B. DreamHost's process killer will kill CPAN if it is taking up too much memory. I experienced this while installing a few modules such as DBIx::Class, when doing a make test. For these, try adding notest before the install command to skip the test. Alternatively, you can try 'nice'ing cpan to a lower priority. Try 'nice -n 19 cpan' and continue installing the modules.
Sanity Check
At this point you should have a functioning installation of Catalyst. To be sure, try typing this at the shell:
perl -MCatalyst -e 'print "There is no *I* in team, but there is an *I* in pie"x100'
If your server is a fan of Shaun of the Dead then everything's all good. If not, something is screwed up. Or maybe you screwed up. Or both.
# If you have to start over, you can say THIS from the shell and start over cd rm -R -f .cpan local
If you still can't get things working, there are lots of places to seek help
Create an application
Do this
cd ~/catalyst.mysite.com ( or whatever your domain name is ) catalyst.pl Test chmod a+rx Test/script/test_cgi.pl Test/script/test_fastcgi.pl
IMPORTANT!! This needs to be at the top of your app executable. For the purposes of your test app, place it at the top of the following files AFTER the shebang line
- Test/script/test_cgi.pl
- Test/script/test_fastcgi.pl
#!/usr/bin/perl -w use lib qw[ /home/myusername/local/lib/perl5 /home/myusername/local/share/perl/5.8.4 /home/myusername/local/lib/perl/5.8.4 /home/myusername/local/share/perl/5.8.4 /home/myusername/local/lib/perl/5.8.4 /home/myusername/local/lib ];
Now you can visit your site URL http://catalyst.yourfancypants.com/Test/script/crm_cgi.pl and see the neat catalyst welcome page.
Running the application under FastCGI
These instructions are adapted from the Fastcgi set up entry. First, set up Catalyst as described above. For this example, Catalyst is setup in /home/myusername/domainname.com/myapp.
VERY IMPORTANT: DreamHost's has a very aggressive process killer that tends to kill the FastCGI server if it's idle for a while. However, if the server is named 'dispatch.fcgi', it does not seem to kill it. So be sure to rename the server script dispatch.fcgi!
To do this, find myapp_fastcgi.pl in the /home/myusername/domainname.com/myapp/script directory and rename it to dispatch.fcgi. Then, create a .htaccess in the /home/myusername/domainname.com directory. Add the following directives in the .htaccess file:
Options +ExecCGI AddHandler fastcgi-script .fcgi
RewriteEngine On RewriteRule ^(myapp/script/dispatch\.fcgi/.*)$ - [L] RewriteRule ^(.*)$ myapp/script/dispatch.fcgi/$1 [PT,L]
Make sure to make the FastCGI server executable:
chmod +x dispatch.fcgi
Now, make your changes to your Catalyst application. To have those changes take effect, use the command:
touch ~/domainname.com/myapp/script/dispatch.fcgi


