$Id$ There's a lot of misinformation out there regarding steps necessary to get mysql (and optionally php or Perl) running properly inside of a chroot Apache install (the default option in OpenBSD). Fortunately, it's not as difficult as most people seem to think. Here's the steps I've used to install and configure mysql to run inside a chrooted Apache (to support MediaWiki (also in ports, requires php, also in ports)) on OpenBSD (3.9 as of this writing; should be pretty much the same for later versions): 0) install MediaWiki (or whatever LAMP-style application you're using; if it's in ports, it will automagically install the current php and MySQL packages as well). The following assume OpenBSD-3.9 on i386; substitute your current version and architecture: $ export PKG_PATH=ftp://ftp.usa.openbsd.org/pub/OpenBSD/3.9/packages/i386/ $ ftp -a ftp.usa.openbsd.org ftp> cd /pub/OpenBSD/3.9/packages ftp> ls i386 pkglist output to local-file: pkglist? [y] ftp> bye $ grep -i mediawiki pkglist -r--r--r-- 1 anonftp wheel 1948308 Sep 4 2005 mediawiki-1.4.4.tgz -r--r--r-- 1 anonftp wheel 2312650 Apr 8 09:38 mediawiki-1.5.8.tgz $ sudo pkg_add -v mediawiki-1.5.8 ... stuff ... 1) IF YOU DIDN'T ALREADY DO STEP 0 (ABOVE): $ grep mysql-server pkglist -r--r--r-- 1 anonftp wheel 4778789 Sep 4 2005 mysql-server-4.0.24p1.tgz $ sudo pkg_add -v mysql-server-4.0.24p1 OR, if you enjoy compiling large applications from source: $ cd /usr/ports/databases/mysql && env SUBPACKAGE="-server" sudo make install 2) create necessary directories and symlinks # mkdir -p /var/www/var/run/mysql/ /var/www/var/mysql # chown _mysql:_mysql /var/www/var/run/mysql /var/www/var/mysql # ln -s /var/www/var/run/mysql /var/run # ln -s /var/www/var/mysql /var 3) add appropriate stuff to /etc/rc.local to start chroot mysqld on boot: # cat >>/etc/rc.local if [ X"${mysqld_flags}" != X"NO" -a -x /usr/local/bin/mysqld_safe ]; then echo -n ' mysqld' /usr/local/bin/mysqld_safe --datadir=/var/www/var/mysql \ --pid-file=/var/www/var/run/mysql/mysql.pid >/dev/null 2>&1 & fi ^D 4) create your /etc/my.cnf - socket and datadir locations are critical: # cat >>/etc/my.cnf [client] # sockets go in chroot - the following are symlinks to the real sockets socket = /var/www/var/run/mysql/mysql.sock [mysqld] socket = /var/www/var/run/mysql/mysql.sock # working dir also goes in chroot datadir = /var/www/var/mysql # don't listen on a TCP/IP port at all - if you're going to be running a # networked mysql, you will want to comment this next line: skip-networking ^D 5) at this point, chroot mysqld should be starting properly on boot and be ready for database configuration (there are plenty of resources out there on this topic; google and mysql.com are your friends here). I recommend testing the startup sequence outlined in /etc/rc.local to be sure that mysqld will in fact start up as expected (reboot your machine if you're really paranoid, but in general this is not necessary). You will of course also want to have Apache starting on boot: # echo httpd_flags= >>/etc/rc.conf.local 6) OPTIONAL: if you installed PHP (similar instructions for other ports/packages), _follow_the_post-install_directions: $ ls /var/db/pkg|grep php php5-core-5.0.4p0/ php5-gd-5.0.4/ php5-mysql-5.0.4/ php5-pear-5.0.4/ $ pkg_info -M php5-core-5.0.4p0 Information for php5-core-5.0.4p0 Install notice: To finish the install, enable the php5 module with: /usr/local/sbin/phpxs -s To enable parsing of PHP scripts, add the following to /var/www/conf/httpd.conf: AddType application/x-httpd-php .php Copy the config file below into /var/www/conf/php.ini /usr/local/share/examples/php5/php.ini-recommended Don't forget that the default OpenBSD httpd is chrooted into /var/www by default, so you may need to create support directories such as /var/www/tmp for PHP to work correctly. $ pkg_info -M php5-mysql-5.0.4 Information for php5-mysql-5.0.4 Install notice: Enable this module in php.ini using the following command: /usr/local/sbin/phpxs -a mysql ---- If you're more comfortable with a GUI interface, you might also want to install phpmyadmin (in ports, of course). If you need Perl inside your chroot environment, I suggest reading my document on installing Kwiki in chroot and the relevant OpenBSD FAQ .