host:~# chmod u+s program host:~# ls -l program -rwsr-xr-x 1 root root 9999 Jan 01 00:00 program*
<VirtualHost xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx:nnnn> ServerName username.domain.org DocumentRoot /users/username/html ScriptAlias /cgi-bin/ /var/www/htdocs/cgi-bin/username/ User username Group username TransferLog /var/log/apache/username.domain.org/access.log ErrorLog /var/log/apache/username.domain.org/error.log UserDir disabled </VirtualHost>
From /etc/postgresql/pg_hba.conf:
# AUTH type "peer" is a Debian improvement where it # looks at the actual userid on the other side of the socket, # which is more secure than using "ident". local all peer sameuser
Example php code:
$database=pg_connect("dbname=trilstuff user=tril");
Here's what to add to the VirtualHost section in the Apache config:
# Location can be / for entire site to have php db access, or a subfolder. # You may want a subfolder only, so the faster mod_php will interpret # the rest of the site. <Location /path-with-db-access> Action username_php_cgi /cgi-bin/php4 AddHandler username_php_cgi php </Location>
I copy the php4 interpreter to everyone's CGI directory using GNU cfengine with the following cfengine.conf:
control: actionsequence = ( shellcommands ) script_path = ( "$(HOME)/bin" ) split = ( " " ) php4_cgi_users = ( "user1 user2 user3" ) shellcommands: "$(script_path)/installcgi php4 $(php4_cgi_users)"
And here's the source to the installcgi script:
#!/bin/bash
name=$1
binary=/usr/lib/cgi-bin/${name}
user=$2
cgi_dir=/var/www/htdocs/cgi-bin
echo installing ${name} in ${user}\'s CGI directory...
install -o ${user} -g ${user} -m 755 ${binary} ${cgi_dir}/${user}/