lazy saunter

(personal learnings in computation)

Monday, March 30, 2009

catalyst, 5: deployment using htaccess

one problem with the last approach- everytime you update the source of your app, you have to restart apache for the updates to take effect. what if you are having the app hosted by a company that runs many sites from the same apache server? restarting apache would take down all those sites temporarily and so would not be an option.

to avoid this, the following can be done.

==========
steps 1-3 pertain to apache configuration. of course, apache would need to be restarted for these to take effect.

(1) fastcgi must be enabled with the autoupdate option on. this means it will rebuild the app when it sees that the "myapp_fastcgi.pl" file has been modified (this can be done with the "touch" comand). my apache conf contains this:

FastCgiConfig -autoUpdate


(2) mod_rewrite must be installed and enabled. this will handle the URL mapping.

(3) htaccess must be able to override the default apache settings. the relevant portion of the apache conf file should contain:
AllowOverride All

==========
steps 4-6 pertain to allowing apache to be able to access the database file (SQLite in my case).

(4) move it to /tmp (this is actually a bad place for it since it will get deleted at every reboot).

(5) delete Schema.pm, Schema/, and Model/

(6) regenerate the model specifying the absolute path to the DB file (/tmp)

==========
steps 7-8 pertain to setting up the URL to point to the right place

(7) create the htaccess file in the web directory:
AddHandler fastcgi-script .fcgi .pl
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/?script/residencies_fastcgi.pl
RewriteRule ^(.*)$ script/residencies_fastcgi.pl/$1 [PT,L]

(8) create the symbolic link from the web directory to your source:
ln -s Residencies/script script/

==========
steps 9-10 pertain to updating your app after the source has changed.

(9) if there is a leftover /tmp/residencies/, delete it

(10) from the command line: "touch residencies_fastcgi.pl". i imagine a new copy of the file could be ftp'ed over also for this to work.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home