version=pmwiki-2.2.130 ordered=1 urlencoded=1 agent=Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 author=mkf charset=UTF-8 csum= ctime=1622782574 host=188.210.102.116 name=Wordpress.Install rev=2 targets= text='''Install WordPress on OpenBSD'''%0a!!!Introduction%0aThis post shows you how to install WordPress on OpenBSD. It uses httpd(8) as web server, PHP, and MariaDB as database.%0a%0a!!!Installation of packages%0aYou can install all the required software that is not part of OpenBSD base from the packages:%0a[@%0a$ doas pkg_add -i php-mysqli php-curl php-gd php-zip pecl74-imagick mariadb-server%0a@]%0a%0aThe PHP packages will present you a list of available versions. I recommend you choose the latest one available. At the time of writing this will be 7.4 on OpenBSD 6.7-release.%0a%0a!!!Configuration of PHP%0aYou must make sure that the required PHP extensions are enabled. The easiest way to this is the following:%0a[@%0a$ cd /etc/php-7.4.sample/%0a$ for i in * ; do doas ln -sf ../php-7.4.sample/$i ../php-7.4/ ; done%0a@]%0a%0a!!!Configuration of MariaDB%0aI recommend that you create a dedicated login group for mysqld - although the package readme tells you that you only need it on busy servers. Append the following to /etc/login.conf:%0a[@%0amysqld:\%0a :openfiles-cur=1024:\%0a :openfiles-max=2048:\%0a :tc=daemon:%0a@]%0a%0a!!!Create the initial database for MariaDB:%0a[@%0a$ doas mysql_install_db%0a@]%0a%0aNow you can start mysqld(8) and secure the installation:%0a[@%0a$ doas rcctl enable mysqld%0a$ doas rcctl start mysqld%0a$ doas mysql_secure_installation%0a@]%0a%0aWith httpd(8) chrooted to /var/www you must make sure that the connection to the socket of the MariaDB server is available within the chroot. First create a folder in which the socket will be placed:%0a[@%0a$ doas install -d -m 0711 -o _mysql -g _mysql /var/www/var/run/mysql%0a@]%0a%0aSecond you must change the socket path in /etc/my.cnf. There is a section [client-server] which covers that for both with the option socket:%0a[@%0a[client-server]%0asocket = /var/www/var/run/mysql/mysql.sock%0a@]%0a%0aYou must restart mysqld(8) in order to activate the new socket:%0a[@%0a$ doas rcctl restart mysqld%0a@]%0aThe last step is to create the database for WordPress:%0a[@%0a$ mysql -u root -p%0aEnter password:%0aWelcome to the MariaDB monitor. Commands end with ; or \g.%0aYour MariaDB connection id is 3%0aServer version: 10.4.12-MariaDB OpenBSD port: mariadb-server-10.4.12v1%0a%0aCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.%0a%0aType 'help;' or '\h' for help. Type '\c' to clear the current input statement.%0a%0aMariaDB [(none)]> CREATE DATABASE wordpress;%0aQuery OK, 1 row affected (0.01 sec)%0a%0aMariaDB [(none)]> GRANT ALL PRIVILEGES on wordpress.* TO "wordpress"@"localhost"%0a -> IDENTIFIED BY "password";%0aQuery OK, 1 row affected (0.00 sec)%0a%0aMariaDB [(none)]> FLUSH PRIVILEGES;%0aQuery OK, 1 row affected (0.00 sec)%0a%0aMariaDB [(none)]> EXIT%0aBye%0a@]%0a%0a!!!Configuration of httpd(8)%0aI assume that you want to run WordPress as the only web application on your server. If this is the case, the following httpd.conf(5) is for %0ayou:%0a[@%0aserver "default" {%0a listen on egress port http%0a log style combined%0a%0a root "/wordpress"%0a directory index index.php%0a location "*.php" {%0a fastcgi socket "/run/php-fpm.sock"%0a }%0a}%0a%0atypes {%0a include "/usr/share/misc/mime.types"%0a}%0a@]%0aYou may want to change the log style from combined to forwarded if you run httpd(8) behind a proxy that sets the headers X-Forwarded-For and X-Forwarded-Port.%0a%0aIn order to make name resolving work within the chroot(2) you should copy your hosts(5) file and your resolv.conf(5) file into it:%0a[@%0a$ cd /var/www%0a$ doas mkdir etc%0a$ for f in hosts resolv.conf ; do doas cp /etc/$f etc/ ; done%0a@]%0aInstallation of WordPress%0aFirst you should fetch the latest version of WordPress:%0a[@%0a$ cd%0a$ ftp -o wordpress.tar.gz https://wordpress.org/latest.tar.gz%0a@]%0aNext you can unpack the archive into the chroot of httpd(8), set the permissions and prepare for the configuration:%0a[@%0a$ cd /var/www%0a$ doas tar xzf /home/user/wordpress.tar.gz%0a$ cd wordpress%0a$ find . -type d -exec doas chown www:daemon {} \;%0a$ find . -type f -exec doas chown www:bin {} \;%0a$ doas cp wp-config-sample.php wp-config.php%0a@]%0a%0aEdit the new file wp-config.php and add or set the following values:%0a[@%0adefine('DB_NAME', 'wordpress');%0adefine('DB_USER', 'wordpress');%0adefine('DB_PASSWORD', 'password');%0adefine('DB_HOST', 'localhost:/var/run/mysql/mysql.sock');%0a@]%0a%0aWordPress needs access to web servers for downloading of themes and plugins. If you need to use a proxy for accessing web pages you can add the following values to wp-config.php:%0a[@%0adefine('WP_PROXY_HOST', 'proxy.example.net');%0adefine('WP_PROXY_PORT', '8080');%0adefine('WP_PROXY_USERNAME', '');%0adefine('WP_PROXY_PASSWORD', '');%0adefine('WP_PROXY_BYPASS_HOSTS', 'localhost');%0aStart services and finish setup%0a@]%0a%0aNow it is time to actually start httpd(8) and php-fpm:%0a[@%0a$ doas rcctl enable php74_fpm httpd%0a$ doas rcctl start php74_fpm httpd%0a@]%0a%0aIf both daemons are started you can finish the setup of WordPress by opening the URL of your web server in a browser, e. g. http://www.example.net/:%0a time=1626893967 author:1626893967=mkf diff:1626893967:1622782574:=2c2,3%0a%3c !!!Introduction%0a---%0a> %0a> '''Introduction'''%0a5c6%0a%3c !!!Installation of packages%0a---%0a> '''Installation of packages'''%0a7c8%0a%3c [@%0a---%0a> %0a9,10d9%0a%3c @]%0a%3c %0a13c12%0a%3c !!!Configuration of PHP%0a---%0a> '''Configuration of PHP'''%0a15c14%0a%3c [@%0a---%0a> %0a17,20c16,23%0a%3c $ for i in * ; do doas ln -sf ../php-7.4.sample/$i ../php-7.4/ ; done%0a%3c @]%0a%3c %0a%3c !!!Configuration of MariaDB%0a---%0a> %0a> $ for i in * ; do%0a> %0a> > doas ln -sf ../php-7.4.sample/$i ../php-7.4/%0a> %0a> > done%0a> %0a> '''Configuration of MariaDB'''%0a22c25%0a%3c [@%0a---%0a> %0a27,30c30,32%0a%3c @]%0a%3c %0a%3c !!!Create the initial database for MariaDB:%0a%3c [@%0a---%0a> %0a> '''Create the initial database for MariaDB:'''%0a> %0a32,33d33%0a%3c @]%0a%3c %0a35c35%0a%3c [@%0a---%0a> %0a39,40d38%0a%3c @]%0a%3c %0a42c40%0a%3c [@%0a---%0a> %0a44,45d41%0a%3c @]%0a%3c %0a47c43%0a%3c [@%0a---%0a> %0a50,51d45%0a%3c @]%0a%3c %0a53c47%0a%3c [@%0a---%0a> %0a55d48%0a%3c @]%0a57c50%0a%3c [@%0a---%0a> %0a80,85c73,76%0a%3c @]%0a%3c %0a%3c !!!Configuration of httpd(8)%0a%3c I assume that you want to run WordPress as the only web application on your server. If this is the case, the following httpd.conf(5) is for %0a%3c you:%0a%3c [@%0a---%0a> %0a> '''Configuration of httpd(8)'''%0a> I assume that you want to run WordPress as the only web application on your server. If this is the case, the following httpd.conf(5) is for you:%0a> %0a100d90%0a%3c @]%0a104c94%0a%3c [@%0a---%0a> %0a108d97%0a%3c @]%0a111c100%0a%3c [@%0a---%0a> %0a114d102%0a%3c @]%0a116c104%0a%3c [@%0a---%0a> %0a123,124d110%0a%3c @]%0a%3c %0a126c112%0a%3c [@%0a---%0a> %0a131,132d116%0a%3c @]%0a%3c %0a134c118%0a%3c [@%0a---%0a> %0a141,142d124%0a%3c @]%0a%3c %0a144c126%0a%3c [@%0a---%0a> %0a147,148d128%0a%3c @]%0a%3c %0a host:1626893967=188.210.102.116 author:1622782574=usr diff:1622782574:1622782574:=1,129d0%0a%3c '''Install WordPress on OpenBSD'''%0a%3c %0a%3c '''Introduction'''%0a%3c This post shows you how to install WordPress on OpenBSD. It uses httpd(8) as web server, PHP, and MariaDB as database.%0a%3c %0a%3c '''Installation of packages'''%0a%3c You can install all the required software that is not part of OpenBSD base from the packages:%0a%3c %0a%3c $ doas pkg_add -i php-mysqli php-curl php-gd php-zip pecl74-imagick mariadb-server%0a%3c The PHP packages will present you a list of available versions. I recommend you choose the latest one available. At the time of writing this will be 7.4 on OpenBSD 6.7-release.%0a%3c %0a%3c '''Configuration of PHP'''%0a%3c You must make sure that the required PHP extensions are enabled. The easiest way to this is the following:%0a%3c %0a%3c $ cd /etc/php-7.4.sample/%0a%3c %0a%3c $ for i in * ; do%0a%3c %0a%3c > doas ln -sf ../php-7.4.sample/$i ../php-7.4/%0a%3c %0a%3c > done%0a%3c %0a%3c '''Configuration of MariaDB'''%0a%3c I recommend that you create a dedicated login group for mysqld - although the package readme tells you that you only need it on busy servers. Append the following to /etc/login.conf:%0a%3c %0a%3c mysqld:\%0a%3c :openfiles-cur=1024:\%0a%3c :openfiles-max=2048:\%0a%3c :tc=daemon:%0a%3c %0a%3c '''Create the initial database for MariaDB:'''%0a%3c %0a%3c $ doas mysql_install_db%0a%3c Now you can start mysqld(8) and secure the installation:%0a%3c %0a%3c $ doas rcctl enable mysqld%0a%3c $ doas rcctl start mysqld%0a%3c $ doas mysql_secure_installation%0a%3c With httpd(8) chrooted to /var/www you must make sure that the connection to the socket of the MariaDB server is available within the chroot. First create a folder in which the socket will be placed:%0a%3c %0a%3c $ doas install -d -m 0711 -o _mysql -g _mysql /var/www/var/run/mysql%0a%3c Second you must change the socket path in /etc/my.cnf. There is a section [client-server] which covers that for both with the option socket:%0a%3c %0a%3c [client-server]%0a%3c socket = /var/www/var/run/mysql/mysql.sock%0a%3c You must restart mysqld(8) in order to activate the new socket:%0a%3c %0a%3c $ doas rcctl restart mysqld%0a%3c The last step is to create the database for WordPress:%0a%3c %0a%3c $ mysql -u root -p%0a%3c Enter password:%0a%3c Welcome to the MariaDB monitor. Commands end with ; or \g.%0a%3c Your MariaDB connection id is 3%0a%3c Server version: 10.4.12-MariaDB OpenBSD port: mariadb-server-10.4.12v1%0a%3c %0a%3c Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.%0a%3c %0a%3c Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.%0a%3c %0a%3c MariaDB [(none)]> CREATE DATABASE wordpress;%0a%3c Query OK, 1 row affected (0.01 sec)%0a%3c %0a%3c MariaDB [(none)]> GRANT ALL PRIVILEGES on wordpress.* TO "wordpress"@"localhost"%0a%3c -> IDENTIFIED BY "password";%0a%3c Query OK, 1 row affected (0.00 sec)%0a%3c %0a%3c MariaDB [(none)]> FLUSH PRIVILEGES;%0a%3c Query OK, 1 row affected (0.00 sec)%0a%3c %0a%3c MariaDB [(none)]> EXIT%0a%3c Bye%0a%3c %0a%3c '''Configuration of httpd(8)'''%0a%3c I assume that you want to run WordPress as the only web application on your server. If this is the case, the following httpd.conf(5) is for you:%0a%3c %0a%3c server "default" {%0a%3c listen on egress port http%0a%3c log style combined%0a%3c %0a%3c root "/wordpress"%0a%3c directory index index.php%0a%3c location "*.php" {%0a%3c fastcgi socket "/run/php-fpm.sock"%0a%3c }%0a%3c }%0a%3c %0a%3c types {%0a%3c include "/usr/share/misc/mime.types"%0a%3c }%0a%3c You may want to change the log style from combined to forwarded if you run httpd(8) behind a proxy that sets the headers X-Forwarded-For and X-Forwarded-Port.%0a%3c %0a%3c In order to make name resolving work within the chroot(2) you should copy your hosts(5) file and your resolv.conf(5) file into it:%0a%3c %0a%3c $ cd /var/www%0a%3c $ doas mkdir etc%0a%3c $ for f in hosts resolv.conf ; do doas cp /etc/$f etc/ ; done%0a%3c Installation of WordPress%0a%3c First you should fetch the latest version of WordPress:%0a%3c %0a%3c $ cd%0a%3c $ ftp -o wordpress.tar.gz https://wordpress.org/latest.tar.gz%0a%3c Next you can unpack the archive into the chroot of httpd(8), set the permissions and prepare for the configuration:%0a%3c %0a%3c $ cd /var/www%0a%3c $ doas tar xzf /home/user/wordpress.tar.gz%0a%3c $ cd wordpress%0a%3c $ find . -type d -exec doas chown www:daemon {} \;%0a%3c $ find . -type f -exec doas chown www:bin {} \;%0a%3c $ doas cp wp-config-sample.php wp-config.php%0a%3c Edit the new file wp-config.php and add or set the following values:%0a%3c %0a%3c define('DB_NAME', 'wordpress');%0a%3c define('DB_USER', 'wordpress');%0a%3c define('DB_PASSWORD', 'password');%0a%3c define('DB_HOST', 'localhost:/var/run/mysql/mysql.sock');%0a%3c WordPress needs access to web servers for downloading of themes and plugins. If you need to use a proxy for accessing web pages you can add the following values to wp-config.php:%0a%3c %0a%3c define('WP_PROXY_HOST', 'proxy.example.net');%0a%3c define('WP_PROXY_PORT', '8080');%0a%3c define('WP_PROXY_USERNAME', '');%0a%3c define('WP_PROXY_PASSWORD', '');%0a%3c define('WP_PROXY_BYPASS_HOSTS', 'localhost');%0a%3c Start services and finish setup%0a%3c Now it is time to actually start httpd(8) and php-fpm:%0a%3c %0a%3c $ doas rcctl enable php74_fpm httpd%0a%3c $ doas rcctl start php74_fpm httpd%0a%3c If both daemons are started you can finish the setup of WordPress by opening the URL of your web server in a browser, e. g. http://www.example.net/:%0a host:1622782574=125.231.28.9