Categories
Uncategorized

HHVM + WordPress Permalinks Issue Resolved

Once HHVM (Hip Hop Virtual Machine) is installed and running, you might have an issue that shows only the Homepage of your WordPress site and the other links lead to a 404 not found. This issue can be quickly resolved.

Open the HHVM proxy configuration file using your favourite editor with root privileges.

sudo nano /etc/apache2/mods-available/hhvm_proxy_fcgi.conf

Add the following line to hhvm config file after editing the path to your WordPress installation. The following line of code assumes that the WordPress installation is in your root web directory.

ProxyPassMatch ^(?!\/wp\-admin\/)([^\.]+)$ fcgi://127.0.0.1:9000/var/www/html/index.php

Your HHVM proxy configuration file should look somewhat similar to this

ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
ProxyPassMatch ^(?!\/wp\-admin\/)([^\.]+)$ fcgi://127.0.0.1:9000/var/www/html/index.php

Now restart the HHVM

sudo service hhvm restart

This should take care of your permalinks issue.

The above HHVM proxy configuration file makes sure that all the php request are routed through HHVM. But if you want to route only specific php requests for a particular website or directory from your server to HHVM, then just add the config lines in your Virtual Hosts section of your apache configuration file. For example,

<VirtualHost *:80>
    ServerName yoursite.com

    DirectoryIndex index.php
    DocumentRoot /var/www/html/yoursite

    ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/yoursite/$1
    ProxyPassMatch ^(?!\/wp\-admin\/)([^\.]+)$ fcgi://127.0.0.1:9000/var/www/html/yoursite/index.php

  </VirtualHost>  

  <VirtualHost *:443>
    ServerName yoursite.com

    DirectoryIndex index.php
    DocumentRoot /var/www/html/yoursite

    SSLEngine On
    SSLCertificateFile   /etc/ssl/certs/yoursite.crt
    SSLCertificateKeyFile    /etc/ssl/private/yoursite.key
    SSLCACertificateFile  /etc/ssl/certs/yoursite.ca.crt

    ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/yoursite/$1
    ProxyPassMatch ^(?!\/wp\-admin\/)([^\.]+)$ fcgi://127.0.0.1:9000/var/www/html/yoursite/index.php

</VirtualHost>