Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Feb 1, 2008

My Apache Setup

I've been using Apache2 with mod_fcgid for quite a while because it's good enough. I use it primarily because it's really simple to administer and I'm hosting internal business applications with very little load on them. Here's my setup...

Installation is really straight forward

$> sudo apt-get install apache2 libapache2-mod-fcgid
$> a2enmod fcgid


default config
# serve everything from /var/www/ and use /var/www/default as the document root

ServerAdmin webmaster@hostname

# setup logs
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
LogLevel warn\

# limit the amount of info about server
ServerSignature Off

# default permissions to all files
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>p;

# setup document root and permissions
DocumentRoot /var/www/default
<Directory /var/www/default>
Options +FollowSymLinks +MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

# define environment for fcgid processes
DefaultInitEnv PATH "/opt/ruby/bin"
DefaultInitEnv RAILS_ENV "production"


per application config
# run the app from /var/www/appname and serve it aliased as http://hostname/appname

Alias /appname "/var/www/appname/current/public"
<Directory /var/www/appname/current/public/>

Options -Indexes +MultiViews +FollowSymLinks +ExecCGI
AllowOverride None
Order deny,allow
Allow from all

RewriteEngine On

# provide support for cap deploy:web:disable
RewriteCond /var/www/appname/current/public/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /appname/system/maintenance.html [L]

# standard rails rewrite with support for alias directory
RewriteBase /appname
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

# define error documents
ErrorDocument 500 500.html
</Directory>

Jan 26, 2008

Setting Up A Shared Bazaar Repository

Currently I'm using a Decentralized Shared Mainline Repository. Here's my recipe...

You will of course need a server that's accessible to everyone.

Create a group for project.

$> groupadd projectname

Create an login for each of the users who will have commit access to the shared mainline.
$> adduser --ingroup projectname username

Create a directory for the repostitory inside the web servers document root
$> mkdir /var/bzr/projectname

Set the project folders group to the project groups name
$> chown :projectname /var/bzr/projectname

Set the project folders permissions
$> chmod ug+rwx,g+s,o+rx,o-w projectname

Now you can push updates
$> bzr push bzr+ssh://hostname/var/bzr/projectname


If you need to provide anonymous access to the repository one way would be to serve it with Apache.
Alias /bzr "/var/bzr"
<Directory "/var/bzr">
Options +Indexes +MultiViews +FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>

This would allow you to do something like this
$> bzr branch http://hostname/bzr/projectname