Installing Wordpress on OpenBSD 4.4
bsduser1# echo $PKG_PATHftp://ftp.rt.fm/pub/OpenBSD/snapshots/packages/i386bsduser1# pkg_add mysql-server
mysql-client-5.0.67: complete p5-DBD-mysql-4.005p0:p5-Net-Daemon-0.43: complete p5-DBD-mysql-4.005p0:p5-PlRPC-0.2018p0: complete p5-DBD-mysql-4.005p0:p5-DBI-1.604p0: complete p5-DBD-mysql-4.005p0: complete mysql-server-5.0.67: complete --- mysql-server-5.0.67 ------------------- You can find detailed instructions on how to install a database in /usr/local/share/doc/mysql/README.OpenBSD.bsduser1# less /usr/local/share/doc/mysql/README.OpenBSD
Using MySQL in an OpenBSD environment
If you are installing MySQL for the first time, you have to create
a default database first. In order to create the database, please run
/usr/local/bin/mysql_install_db
You will need to tune the values in the my.cnf file (examples
available in /usr/local/share/mysql).
By default, the _mysql user, and so the mysqld processes run in
the login(1) class of "daemon". On a busy server, it may be advisable
to put the _mysql user and processes in their own login(1) class
with tuned resources, such as more open file descriptors etc.
For example, add this to the login.conf(5) file:
mysql:\
:openfiles-cur=1024:\
:openfiles-max=2048:\
:tc=daemon:
Rebuild the login.conf.db file if necessary:
# cap_mkdb /etc/login.conf
And start the server like this:
if [ -x /usr/local/bin/mysqld_safe ] ; then
su -c mysql root -c '/usr/local/bin/mysqld_safe >/dev/null 2>&1 &'
echo -n ' mysql'
fi
mysqld_safe(1) is the recommended way to start a MySQL server,
it creates the directory for the socket and adds some safety
features such as restarting the server when an error occurs
and logging runtime information to an error log file. Options
may be passed in the [mysqld_safe] section of my.cnf.
Note that the classes in login.conf(5) are used by login(1);
they do not apply to normal process startup, hence the use of su(1).
For larger servers and dedicated database servers, these numbers
and memory limits (e.g. datasize and stacksize) may also need to be
increased. Please report any changes and experiences to the package
maintainers so that we can update this file for future versions.
bsduser1# /usr/local/bin/mysql_install_db
Installing MySQL system tables... OK Filling help tables... OK PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/local/bin/mysqladmin -u root password 'new-password' /usr/local/bin/mysqladmin -u root -h bsduser1.usesbsd.com password 'new-password' Alternatively you can run: /usr/local/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. Please report any problems with the /usr/local/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.combsduser1# /usr/local/bin/mysqld_safe &
[1] 7663 Starting mysqld daemon with databases from /var/mysqlbsduser1# /usr/local/bin/mysqladmin -u root password 'YOURPASS'
bsduser1# hostname
bsduser1.usesbsd.combsduser1# /usr/local/bin/mysqladmin -u root -p -h bsduser1.usesbsd.com password 'YOURPASS'
bsduser1# fstat | grep "*:" | grep mysql
_mysql mysqld 2686 15* internet stream tcp 0xd6922964 *:3306bsduser1# ps aux | grep mysql
root 7663 0.0 0.1 444 464 p4 IN 8:11AM 0:00.02 /bin/sh /usr/local/bin/mysqld_safe _mysql 2686 0.0 3.6 40432 18464 p4 SN 8:11AM 0:01.95 /usr/local/libexec/mysqld --basedir=/usr/local --datadir=/var/mysql --user=_mysql --pid-fil root 19308 0.0 0.1 312 640 p4 RN+ 8:23AM 0:00.01 grep mysqlbsduser1# vi /etc/rc.local
add this:
if [ -x /usr/local/bin/mysqld_safe ]; then
    /usr/local/bin/mysqld_safe >/dev/null 2>&1
    for i in 1 2 3 4 5 6; do
       if [ -S /var/run/mysql/mysql.sock ]; then
       break
       else sleep 1; echo -n "."
       fi
    done
    mkdir -p /var/www/var/run/mysql
    sleep 2
    ln -f /var/run/mysql/mysql.sock /var/www/var/run/mysql/mysql.sock
    echo -n ' mysql'
fi
bsduser1# mkdir -p /var/www/var/run/mysql
bsduser1# ln -f /var/run/mysql/mysql.sock /var/www/var/run/mysql/mysql.sock
Since MySQL will only be accessed locally, we (a) do not open port 3306 for it in pf.conf, and (b):
bsduser1# vi /etc/my.cnf
uncomment this (was on line 44 of my default /etc/my.cnf):
skip-networkingbsduser1# mysql -u root -h localhost -p Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.0.67-log OpenBSD port: mysql-server-5.0.67 Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> CREATE DATABASE wordpressDB;
Query OK, 1 row affected (0.14 sec)mysql> GRANT ALL ON wordpressDB.* TO username@localhost IDENTIFIED BY 'userpass';
Query OK, 0 rows affected (0.17 sec)mysql> SHOW DATABASES;
+--------------------+ | Database | +--------------------+ | information_schema | | familyblogDB | | mysql | | test | +--------------------+ 4 rows in set (0.11 sec)mysql> \q
Byebsduser1# pkg_add php5-mysql
php5-core-5.2.6p0: complete
php5-mysql-5.2.6: complete
--- php5-core-5.2.6p0 -------------------
To enable the php5 module please create a symbolic
link from /var/www/conf/modules.sample/php5.conf
to /var/www/conf/modules/php5.conf.
ln -s /var/www/conf/modules.sample/php5.conf \
/var/www/conf/modules
The recommended php configuration has been installed
to /var/www/conf/php.ini.
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.
--- php5-mysql-5.2.6 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/mysql.ini to
/var/www/conf/php5/mysql.ini.
ln -fs /var/www/conf/php5.sample/mysql.ini \
/var/www/conf/php5/mysql.ini
bsduser1# pkg_add -i wordpress
wordpress-2.5.1: complete --- wordpress-2.5.1 ------------------- The WordPress has been installed into /var/www/wordpress You should point this to the DocumentRoot of your web-server: # ln -s ../wordpress /var/www/htdocs/wordpress (make sure you use a relative symlink since Apache is chrooted) and proceed to complete the installation by reading: /var/www/wordpress/readme.html You can ensure you have a working install by accessing: http://bsduser1# cp /usr/local/share/examples/php5/php.ini-recommended /var/www/conf/php.ini/wordpress/
bsduser1# ln -s /var/www/conf/modules.sample/php5.conf /var/www/conf/modules
bsduser1# ln -fs /var/www/conf/php5.sample/mysql.ini /var/www/conf/php5/mysql.ini
bsduser1# chown root:www /var/www/conf/php.ini
bsduser1# chmod 640 /var/www/conf/php.ini
bsduser1# mkdir /var/www/tmp
bsduser1# echo "Include /var/www/conf/phpinclude.conf" >> /var/www/conf/httpd.conf
bsduser1# echo "LoadModule php5_module /usr/lib/apache/modules/libphp5.so
AddType application/x-httpd-php .php .php4 .php3 .htm .html
AddType application/x-httpd-php-source .phps" >> /var/www/conf/phpinclude.conf
bsduser1# vi /var/www/conf/httpd.conf
edit this (was on line 454 of my default /var/www/conf/httpd.conf):
DirectoryIndex index.html index.phpbsduser1# echo "<?php phpinfo() ?>" > /var/www/htdocs/phptest.html
bsduser1# useradd -b /var/www/htdocs/web -m -L default username
bsduser1# mkdir /var/www/htdocs/web/username/public_html
bsduser1# mkdir /var/www/htdocs/web/username/logs
bsduser1# touch /var/www/htdocs/web/username/logs/username.log
bsduser1# cp -rp /var/www/wordpress/* /var/www/htdocs/web/username/public_html/
bsduser1# chown -R username /var/www/htdocs/web/username
bsduser1# vi /var/www/htdocs/web/username/wp-config.php
visit http://api.wordpress.org/secret-key/1.0/ to get a secret key
// ** MySQL settings ** //
define('DB_NAME', 'wordpressDB'); // The name of the database
define('DB_USER', 'username'); // Your MySQL username
define('DB_PASSWORD', 'userpass'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
define('SECRET_KEY', 'vkEx,*\' =|=5p;l@Hy~]xJ!px$y3WXP+3@V:2a*mO*CSN9CR7JAO_B?hM*S6g?@9');
Now go login and enjoy!
Below this is extraneous notes for myself:
Since I just copied my /home and /var/lib/mysql I didn't do the proper "export" through wordpress, thus I must find a way to use my old databases and information with the new installation. Copy the database from /backup/var/lib/mysql/databaseDB to /var/mysql/databaseDB. From there, do mkdir dumps && `mysqldump -u root -p databaseDB > /var/mysql/dumps/databaseDB.dump`