OpenBSD 5.4, WordPress et Nginx

Voici comment installer WordPress sur OpenBSD.

Pour installer un package, on renseigne la variable PKG_PATH :

$ sudo export PKG_PATH=

On installe php-fpm qui ajoutera les dépendances (notamment php-5.3.27) :

$ sudo pkg_add php-fpm
Ambiguous: choose dependency for php-fpm-5.3.27:
a       0: php-5.3.27
1: php-5.3.27
Your choice: 1
php-fpm-5.3.27:libiconv-1.14p0: ok
php-fpm-5.3.27:libxml-2.9.0p0: ok
php-fpm-5.3.27:gettext-0.18.2p3: ok
php-fpm-5.3.27:femail-0.98: ok
php-fpm-5.3.27:femail-chroot-0.98p2: ok
php-fpm-5.3.27:php-5.3.27: ok
php-fpm-5.3.27: ok
The following new rcscripts were installed: /etc/rc.d/php_fpm
See rc.d(8) for details.
Look in /usr/local/share/doc/pkg-readmes for extra documentation.
--- +php-5.3.27 -------------------
To enable the php-5.3 module please create a symbolic link from
/var/www/conf/modules.sample/php-5.3.conf to
/var/www/conf/modules/php.conf. As root:

ln -sf /var/www/conf/modules.sample/php-5.3.conf /var/www/conf/modules/php.conf

The recommended php configuration has been installed to:

Comme indiqué, on crée le lien pour activer le module :

$ sudo ln -sf /var/www/conf/modules.sample/php-5.3.conf /var/www/conf/modules/php.conf

Modification du fichier /etc/php-fpm.conf : on indique listen = /var/www/tmp/php.sock à la place de listen =

Paramètres à rajouter dans /etc/nginx/nginx.conf :

# pass the PHP scripts to FastCGI server listening on
location ~ .php$ {
root /var/www/htdocs;
fastcgi_pass unix:/tmp/php.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

Dans /etc/rc.conf.local (pour un lancement des services au démarrage) :


Démarrage des services :

$ sudo /etc/rc.d/nginx start
$ sudo /etc/rc.d/php_fpm start

On peut tester l’installation et le fonctionnement de php en lançant une requête vers après avoir fait ceci :

$ sudo echo '' > /var/www/htdocs/info.php
$ sudo chown www.www /var/www/htdocs/info.php

Installation d’un serveur MySQL :

$ sudo pkg_add mysql-server
mysql-server-5.1.70v0:mysql-client-5.1.70v0: ok
mysql-server-5.1.70v0:p5-Net-Daemon-0.48: ok
mysql-server-5.1.70v0:p5-PlRPC-0.2018p1: ok
mysql-server-5.1.70v0:p5-FreezeThaw-0.5001: ok
mysql-server-5.1.70v0:p5-MLDBM-2.05: ok
mysql-server-5.1.70v0:p5-Params-Util-1.07: ok
mysql-server-5.1.70v0:p5-Clone-0.34: ok
mysql-server-5.1.70v0:p5-SQL-Statement-1.33: ok
mysql-server-5.1.70v0:p5-DBI-1.622: ok
mysql-server-5.1.70v0:p5-DBD-mysql-4.023p0: ok
mysql-server-5.1.70v0: ok
The following new rcscripts were installed: /etc/rc.d/mysqld
See rc.d(8) for details.
Look in /usr/local/share/doc/pkg-readmes for extra documentation.

Post installation :

$ sudo /usr/local/bin/mysql_install_db
Installing MySQL system tables...
140307 16:17:55 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
Filling help tables...
140307 16:17:55 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.

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 password 'new-password'

Alternatively you can run:

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!

On fait ce que le monsieur demande, on lance le serveur :

$ sudo /usr/local/bin/mysqld_safe &

.. et on finalise l’installation en sécurisant les accès :

$ sudo /usr/local/bin/mysql_secure_installation


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Est-ce que MySQL tourne?

$ sudo fstat | grep "*:" | grep mysql
_mysql   mysqld     18833   11* internet stream tcp 0xfffffe8074df0050 *:3306

On modifie /etc/rc.conf.local :

pkg_scripts="php-fpm mysqld"

On crée la base et l’utilisateur pour WordPress :

$ sudo mysql -u root -h localhost -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 11
Server version: 5.1.70-log OpenBSD port: mysql-server-5.1.70v0

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> CREATE DATABASE wordpressdb;
Query OK, 1 row affected (0.01 sec)

mysql> GRANT ALL ON wordpressdb.* to wpuser@localhost IDENTIFIED BY '*** mon scret ***';
Query OK, 0 rows affected (0.00 sec)

| Database           |
| information_schema |
| mysql              |
| wordpressdb        |
3 rows in set (0.00 sec)

mysql> q

On installe WordPress :

$ sudo pkg_add wordpress
wordpress-3.5.2:php-mysql-5.3.27: ok
wordpress-3.5.2: ok
Look in /usr/local/share/doc/pkg-readmes for extra documentation.
--- +php-mysql-5.3.27 -------------------
You can enable this module by creating a symbolic link from
/etc/php-5.3.sample/mysql.ini to
/etc/php-5.3/mysql.ini. As root:

ln -sf /etc/php-5.3.sample/mysql.ini /etc/php-5.3/mysql.ini

$ ln -sf /etc/php-5.3.sample/mysql.ini /etc/php-5.3/mysql.ini

On copie l’arborescence du blog WordPress là où on le souhaite :

$ sudo cp -rp /var/www/wordpress /var/www/htdocs/blog
$ sudo chown -R www:www /var/www/htdocs/blog/
$ sudo chmod -R g+w /var/www/htdocs/blog/

On rend accessible en lecture le fichier de configuration de php au groupe www :

$ sudo chown root:www /etc/php-5.3.ini
$ sudo chmod 640 /etc/php-5.3.ini

Comme Nginx est en environnement Chrooté, il faut tout de même permettre l’accès à la socket mysql :

$ sudo mkdir -p /var/www/var/run/mysql/
$ sudo ln -f /var/run/mysql/mysql.sock /var/www/var/run/mysql/mysql.sock

Ce lien doit être régénéré à chaque redémarrage de MySQL… On peut par exemple créé ce lien dans /etc/rc.local.

…puis à un fichier resolv.conf que l’on recrée pour permettre la résolution de noms (avec par exemple le DNS de google) :

$ sudo mkdir -p /var/www/etc/
$ sudo echo "nameserver" > /var/www/etc/resolv.conf
$ sudo chown root:www /var/www/etc/resolv.conf
$ sudo chmod 640 /var/www/etc/resolv.conf

On peut vérifier que les résolutions DNS se font bien depuis l’application :

$ sudo tcpdump -Xni em0 port 53
tcpdump: listening on em0, link-type EN10MB
tcpdump: WARNING: compensating for unaligned libpcap packets
11:01:48.075462 X.Y.Z.W.15350 > 64232+ A? (35)
  0000: 4500 003f 757a 0000 4011 83c0 d453 9d10  E..?uz..@....S..
  0010: 0808 0808 3bf6 0035 002b 973b fae8 0100  ....;..5.+.;....
  0020: 0001 0000 0000 0000 0361 7069 0977 6f72  .........api.wor
  0030: 6470 7265 7373 036f 7267 0000 0100 01

11:01:48.086135 > X.Y.Z.W.15350: 64232 3/0/0 CNAME, A, (81)
  0000: 4500 006d d974 0000 3111 2e98 0808 0808  E..m.t..1.......
  0010: d453 9d10 0035 3bf6 0059 835d fae8 8180  .S...5;..Y.]....
  0020: 0001 0003 0000 0000 0361 7069 0977 6f72  .........api.wor
  0030: 6470 7265 7373 036f 7267 0000 0100 01c0
  0040: 0c00 0500 0100 0026 7a00 02c0 10c0 1000  .......&z.......
  0050: 0100 0100 0000 4e00 0442 9b28 fac0 1000  ......N..B.(....
  0060: 0100 0100 0000 

Enfin, on peut finir l’installation de WordPress via l’interface web : … et il faut mettre à jour WordPress (toujour depuis l’interface web) pour avoir la toute dernière version!

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *