reverse_engineer

Personal website of Aurélien Vermylen

Setting up apache with php-fpm over a unix socket

Another technical post regarding the setup of an Apache server with php-fpm, but mess ensuing trying to set up the unix socket for the fastcgi…

OwnCloud

OwnCloud is a php application that can be handy to provide a kind of Google Drive or OneDrive to your company while ensuring that the data is physically owned by yourself. It’s distributed as a directory that you can just serve from a webserver with php support and a mysql database, and looks quite easy to work with from there onwards.

You don’t have the online tools like Google Docs (or the OneDrive online editing tools), but you can set up a Desktop client for Windows, OSX or basically any Linux, which synchronises over WebDAV, so it is quite powerful.

Setup

My usual drive for doing things right made it impossible for me to set up just the mod_php version. No, no, we need a php-fpm over a unix socket (even though we will be under 10 people using it…)

There, I got stuck quite a long time because of one mistake: the ProxyPassMatch directive that sends the request to php-fpm. The syntax is basically:

ProxyPassMatch "<yourRegexpForMatching>" "unix:/run/php/php<version>-fpm.sock|fcgi://localhost/path/to/my/www/folder"

When setting it up, I changed the directory root path of my apache server at some point, because I had installed owncloud in a subdirectory, which it seems not to be designed for…

So I changed /path/to/my/www/folder to /path/to/my/www/folder/owncloud, and that was the mistake: I failed to change that too in the ProxyPassMatch directive…

What is counterintuitive, is that the separator | seems to be indicating: use the unix socket or if that fails use the fcgi:// protocol, so that the info in that second part is useless if the unix socket works.

This is not the case, the fcgi:// link is needed to set the correct chroot in the php-fpm process, so you need to change that in the ProxyPassMatch too.