OpenBSD - Episode 4 - Apache, MySQL, PHP

Ok, so it took longer than I expected…

But in the end, the process was exceedingly easy.

I’d like to thank toeknee over at h00d.org for his awesome post, “OAMP on OpenBSD 4.2 (OpenBSD, Apache, MySQL 5.0 & PHP5)” which basically walked me through the process.

Before finding toeknee’s article, I was trying to manually install Apache.

After a few hours of banging on the keyboard, I realized… like an idiot… that OpenBSD comes with a chrooted Apache install…

Ok… RTFM, Bill.

Next all i had to do was get MySQL and PHP working.

Toeknee’s page was perfect.

There are a few changes between 4.2 and 4.3 with regards to activating MySQL for PHP, but after doing PKG_ADD, the instructions were quite clear.

I had no problem getting Apache to start at boot, but I couldn’t get MySQL to start at boot. There was no real error message. When the server would boot, you could see MySQL being started, but then immediately it would shut down.

No worries. I just started it by hand, and linked the socket over to the chroot:

/usr/local/bin/mysqld_safe -user=_mysql -log
ln -f /var/run/mysql/mysql.sock \ /var/www/var/run/mysql/mysql.sock

Installing and configuring an instance of WordPress was a breeze.

Sweet… I’m sure I’ll play around with this box some more. Perhaps putting known-vulnerable apps on it to test web-penetration testing tools.

I like OpenBSD. It’s been a fun project. Now, if I can just get my boss to consider anything that isn’t M$FT…

Bill

One Response to “OpenBSD - Episode 4 - Apache, MySQL, PHP”

  1. fcgoo Says:

    hello, i installed openbsd4.4+mysql(pkg_add),but there are some error appeared in log accidently. then i write a test perl script:
    === script start ===
    use DBI;
    $dsn = “DBI:mysql:database=test;host=127.0.0.1;port=3306″;
    for ($i = 0; $i connect($dsn, ‘root’, ”);
    if (!$dbh) { exit 1; }
    print $i, ‘ ‘, $dbh, “\n”;
    }
    === script end ===
    to run it ,and show following error:

    231 DBI::db=HASH(0×877f9084)
    232 DBI::db=HASH(0×877f9bb8)
    233 DBI::db=HASH(0×877f9b34)
    234 DBI::db=HASH(0×877f9dc8)
    235 DBI::db=HASH(0×863f915c)
    DBI connect(’database=test;host=127.0.0.1;port=3306′,’root’,…) failed: Can’t connect to MySQL server on ‘127.0.0.1′ (65) at 2.pl line 4

    if you connect mysql through socket , the error is disappear any time. however, if you connect mysql through ip(127.0.0.1), the error appear again, how to workaround it ?

    forum discussed such problem :
    http://www.openbsdonly.org/viewtopic.php?f=17&t=640

    sorry for my poor english

Leave a Reply