WordPress can't write files on HHVM and nginx

June 8, 2015 802 views
LEMP WordPress Nginx PHP Ubuntu


Just posted this to the ‘Advanced WordPress’ Facebook group. Posting here for public archive. Will update.

Tech stack:

Ubuntu 14.04.1
nginx 0.91-ubuntu1
mysql 5.5.40-0ubuntu0.14.04.1 (Ubuntu)
hhvm 3.5.0 (rel)
WordPress 4.2.2
Any hhvm users here?

Superficial problem: auto updates to core, theme, plugins asks for FTP credentials. Same for uploading media. WordPress can’t write to server

Everything was running really well on my LEMP server until I needed to reboot my DO VPS last month. Still running well, but now simply can’t write files.

I currently (temporarily) have all mod permissions at 775 with www-data:www-data owner/group to root wp directory.

This is more a question of best practices running WP on hhvm. Is it all that different than running php-fpm?

From I can ‘sense’, it seems the hhvm process can’t write to the directories, as it either isn’t using the www-data user or part of the www-data group.

php5-fpm explicitly declares this in the /etc/php5/fpm/pool.d/www.conf file, but I can’t find a similar file or declaration for hhvm. There is a /etc/hhvm/ directory containing a php.ini and server.ini files, but currently there is no explicit user line in the files.

Upon further review in htop, it seems my ‘casey’ user owns the 6 hhvm processes. Do I just need to start hhvm as ‘www-data’? If this was the case, since ‘casey’ is a member of www-data, hhvm should be able to write to directories given the current 775 mod (but I might be mistaken about how that works). Regardless, the hhvm server process should obviously be owned by another user, but unclear what the best practice is here. If I recall, I manually booted hhvm after the server reboot, probably better to set up as a daemon.

Before I mess with the config files I want to make sure I’m relatively correct about this.

My google searches weren’t bringing up exact results on this. Am I headed in the right direction?

1 Answer

By default on Ubuntu, HHVM does run under the www-data user. This is defined in the init script that is used to start the process. Here's a snippet from /etc/init.d/hhvm:

# Default values. This values can be overwritten in '/etc/default/hhvm'

As the comment notes, you can override these defaults by placing a file at /etc/default/hhvm with new values. You shouldn't edit the init script directly. For more information on running HHVM on Ubuntu, check out:

HHVM is an open source virtual machine for executing PHP and Hack code. HHVM is developed and supported by Facebook, a fact which draws more and more attention to HHVM lately. HHVM is different from other PHP engines because of its just-in-time (JIT) compilation approach. HHVM compiles PHP code into an intermediate byte code and then directly into x64 machine instructions. This allows more optimizations and higher performance compared to the way other engines work.
Have another answer? Share your knowledge.