PHP/HHVM: Difference between revisions

From Bibliotheca Anonoma
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
First, install HHVM:
The PHP engine runs the MediaWiki source code. However, rather than using the conventional PHP engine, this configuration will use Facebook’s HHVM for significantly higher performance. Follow these instructions to set up the HHVM package:


https://www.digitalocean.com/community/tutorials/how-to-install-hhvm-with-nginx-on-ubuntu-14-04
* '''Debian/Ubuntu''': https://docs.hhvm.com/hhvm/installation/linux
* '''RHEL/CentOS''': https://github.com/facebook/hhvm/wiki/Prebuilt-Packages-on-Centos-7.x


https://www.howtoforge.com/tutorial/how-to-install-wordpress-with-hhvm-and-nginx-on-centos-7/
{{Note|Make sure you've installed [[Nginx/MediaWiki|Nginx]] from the official nginx repos, rather than your distribution's outdated versions. On both Debian and CentOS, this will result in the creation of an nginx user and group, which will be necessary as shown below.}}


For better performance, set up HHVM as a UNIX socket to reduce additional load from TCP layers.
{{Note|According to the build instructions, HHVM only compiles and runs on 64-bit CPUs only.}}


https://docs.hhvm.com/hhvm/advanced-usage/fastCGI#using-fastcgi
First, edit the HHVM configuration file, and in line 7, replace the server port line with the following to activate the UNIX socket:
 
{{hc|/etc/hhvm/server.ini|<nowiki>
;hhvm.server.port = 9000
hhvm.server.user = nginx
hhvm.server.file_socket = /var/run/hhvm/hhvm.sock
</nowiki>}}


== Systemd Service ==
== Systemd Service ==


Make sure you've installed Nginx from the official nginx repos, rather than your distribution's outdated versions. On both Debian and CentOS, this will result in the creation of an nginx user and group, which is then made accessible in the systemd service below:
Then, create a customized Systemd configuration file for HHVM, which will provide Nginx with the ability to read and write to the UNIX socket:


{{hc|/etc/systemd/system/hhvm.service|<nowiki>
{{hc|/etc/systemd/system/hhvm.service|<nowiki>
Line 26: Line 33:
WantedBy=multi-user.target
WantedBy=multi-user.target
</nowiki>}}
</nowiki>}}
Now, reload the systemd services. You only need to do this whenever you edit the systemd service files.
sudo systemctl daemon-reload
Finally, start HHVM.
sudo systemctl start hhvm
If it works out, enable the hhvm service.
sudo systemctl enable hhvm
== Sources ==
* [https://docs.hhvm.com/hhvm/advanced-usage/fastCGI#using-fastcgi FastCGI UNIX Socket]

Latest revision as of 21:32, 10 April 2017

The PHP engine runs the MediaWiki source code. However, rather than using the conventional PHP engine, this configuration will use Facebook’s HHVM for significantly higher performance. Follow these instructions to set up the HHVM package:

Note: Make sure you've installed Nginx from the official nginx repos, rather than your distribution's outdated versions. On both Debian and CentOS, this will result in the creation of an nginx user and group, which will be necessary as shown below.
Note: According to the build instructions, HHVM only compiles and runs on 64-bit CPUs only.

First, edit the HHVM configuration file, and in line 7, replace the server port line with the following to activate the UNIX socket:

/etc/hhvm/server.ini
;hhvm.server.port = 9000
hhvm.server.user = nginx
hhvm.server.file_socket = /var/run/hhvm/hhvm.sock

Systemd Service[edit]

Then, create a customized Systemd configuration file for HHVM, which will provide Nginx with the ability to read and write to the UNIX socket:

/etc/systemd/system/hhvm.service
[Unit]
Description=HHVM HipHop Virtual Machine (FCGI)
After=network.target nginx.service mariadb.service
 
[Service]
User=nginx
Group=nginx
ExecStart=/usr/local/bin/hhvm --config /etc/hhvm/server.ini --user nginx --mode daemon -vServer.Type=fastcgi -vServer.FileSocket=/var/run/hhvm/hhvm.sock
 
[Install]
WantedBy=multi-user.target

Now, reload the systemd services. You only need to do this whenever you edit the systemd service files.

sudo systemctl daemon-reload

Finally, start HHVM.

sudo systemctl start hhvm

If it works out, enable the hhvm service.

sudo systemctl enable hhvm

Sources[edit]