问题
I'm aware that HHVM can run regular PHP code. What I would like to know is if I can migrate in a way where I serve all files written with hack
with the HHVM
and all the files written with PHP via the regular PHP
interpreter.
I assume this should be possible by using two different file extensions (say .hh
and .php
) and then somehow map them two the different interpreters/VM with some nginx setting, no?
回答1:
Even though you asked for nginx, here is an example (untested) Apache CGI configuration:
(sorry I don't know nginx)
<IfModule mod_fcgid.c>
IdleTimeout 3600
ProcessLifeTime 7200
MaxProcessCount 64
DefaultMaxClassProcessCount 8
IPCConnectTimeout 300
IPCCommTimeout 7200
BusyTimeout 300
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
ScriptAlias /php-5.5.10-bin/ /opt/php/5.5.10/bin/
ScriptAlias /php-5.4.17-bin/ /opt/php/5.4.26/bin/
ScriptAlias /php-5.3.27-bin/ /opt/php/5.3.28/bin/
ScriptAlias /php-5.2.17-bin/ /opt/php/5.2.17/bin/
<Directory "/opt/php">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
<FilesMatch ".+\.hh$">
SetHandler application/x-httpd-hhvm
</FilesMatch>
ScriptAlias /hhvm-2.4.2-bin/ /opt/hhvm/2.4.2/bin/
<Directory "/opt/hhvm">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</IfModule>
And the Virtual host:
<VirtualHost *:80>
ServerAdmin hosting@example.com
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/deployments/www.example.com/public
<Directory /var/deployments/www.example.com>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Action application/x-httpd-php /php-5.5.10-bin/php-cgi
Action application/x-httpd-hhvm /hhvm-2.4.2-bin/hhvm-cgi
</Directory>
ErrorLog /var/deployments/$serverName/log/www.example.com.error.log
LogLevel warn
CustomLog /var/deployments/$serverName/log/www.example.com.access.log combined
</VirtualHost>
来源:https://stackoverflow.com/questions/22648383/can-i-use-hhvm-side-by-side-with-the-regular-php-interpreter