1 (edited by afarber 2005-07-14 11:07)

Topic: Howto: punBB + postgresql on OpenBSD 3.7

Hi,

for the archives I'd like to share a short report about successfull
installation of the web forum from http://www.punBB.org on an PC
running OpenBSD 3.7 (which runs Apache 1.3.x with many
security patches and in a chroot cool ):

1) I've downloaded and installed (using pkg_add) the following packages
   from ftp://ftp.de.openbsd.org/unix/OpenBSD/3 … ages/i386/  :

       php5-core-5.0.4
       php5-pgsql-5.0.4
       postgresql-client-7.4.3p2
       postgresql-server-7.4.3p2
       mini_sendmail-chroot-1.3.5

2) Then I followed the instructions printed by "pkg_info -D package_name"
    for each of those packages and also the instructions listed in the file
        /usr/local/share/doc/postgresql/README.OpenBSD

3) Prepended "index.php" to this line to /var/www/conf/httpd.conf :
       

DirectoryIndex index.php index.html

4) Added this line to /var/postgresql/data/postgresql.conf
       

unix_socket_directory = '/var/www/tmp'

5) Added 2 lines to /etc/rc.conf.local :

       httpd_flags=""
       postgresql=YES

6) Added this to /etc/rc.local:

       if [ X"${postgresql}" = X"YES" -a -x /usr/local/bin/pg_ctl ]; then
               su -l _postgresql -c "nohup /usr/local/bin/pg_ctl start \
                       -D /var/postgresql/data -l /var/postgresql/logfile \
                       -o '-D /var/postgresql/data'"
               echo -n ' postgresql'
       fi

7) and this to /etc/rc.shutdown :

       if [ -f /var/postgresql/data/postmaster.pid ]; then
               su -l _postgresql -c "/usr/local/bin/pg_ctl stop -m fast \
                       -D /var/postgresql/data"
               rm -f /var/postgresql/data/postmaster.pid
       fi

8) Then I unpacked http://punbb.org/download/punbb-1.2.6.tar.gz
    and copied the content of the upload/ subdir into /var/www/htdocs/punbb

    I've also download Russian.zip from that website and put it under
        /var/www/htdocs/punbb/lang

9) The files and dirs under /var/www/htdocs/punbb belong to root:daemon
    and the ones under /var/postgresql to the _postgresql user, but I had
    to create an additional dir and to change few permissions:

       mkdir /var/www/tmp  (this dir holds the postgresql unix socket)
       chmod a+rwt /var/www/tmp

       chgrp www /var/www/htdocs/punbb/{cache,img/avatars}
       chmod g+rwt /var/www/htdocs/punbb/{cache,img/avatars}

10) Added a database and user to postgresql using createdb
     and createuser

11) Put Copied /bin/sh because php calls popen for running mini_sendmail
           

cp -p /bin/sh /var/www/bin/sh

12) Put this line into /var/www/conf/php.ini
           

sendmail_path = "/bin/mini_sendmail -t -i"

13) And finally used a trick when running (in a browser)
     http://www.my.domain/punbb/install.php after a reboot:

     I have entered /tmp into the "hostname" text field -
     this made punBB to connect to the postgresql database
     through the local unix socket /var/www/tmp/.s.PGSQL.5432

Thank you for the punBB software smile

Regards
Alex

http://preferans.de/ - russian card game

Re: Howto: punBB + postgresql on OpenBSD 3.7

Good stuff. Thanks for the detailed "guide".

Regarding 13. Doesn't PHP connect via the UNIX socket if you just put localhost in the host name field?

Edit: I just read up on the documention and you're right. If the host field is in the connection string, it will use TCP/IP.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Howto: punBB + postgresql on OpenBSD 3.7

Rickard wrote:

Regarding 13. Doesn't PHP connect via the UNIX socket if you just put localhost in the host name field?

Edit: I just read up on the documention and you're right. If the host field is in the connection string, it will use TCP/IP.

Hi Rickard,

yes, I didn't want Postgresql to listen on an internet socket because of 2 reasons:

1) it is less secure (and probably that is why the default installation of Postgresql on OpenBSD doesn't listen on internet socket)
2) the local unix domain sockets are 2-3 times faster than the TCP/IP sockets (s. the "Unix Network Programmiing" book by Stevens, chapter 15.9)

By the way, the  mini_sendmail-chroot-1.3.5 instalation and the step 11) can (and should) be skipped,
when you use the SMTP-sending over localhost:25 (since OpenBSD does listen for local connections there by default).

I had to apply this bugfix to admin_options.php of 1.2.6  though, because otherwise the SMTP value was ignored:

       

 
        // Only update values that have changed
        if (array_key_exists('o_'.$key, $pun_config) && $pun_config['o_'.$key] != $input)

Regards
Alex

http://preferans.de/ - russian card game

Re: Howto: punBB + postgresql on OpenBSD 3.7

Yes, that is a known bug in 1.2.6. It is quite severe, so I'm considering releasing 1.2.7 soon.

"Programming is like sex: one mistake and you have to support it for the rest of your life."