我知道HHVM可以运行常规的PHP代码。我想知道的是,我是否能够以hack
使用HHVM
编写的所有文件以及通过常规PHP
解释器使用PHP编写的所有文件进行迁移。
我认为这应该可以通过使用两个不同的文件扩展名(比如.hh
和.php
),然后以某种方式将两个不同的解释器/ VM映射到一些nginx设置,不是吗?
答案 0 :(得分:3)
即使您要求使用nginx,这里有一个示例(未经测试的)Apache CGI配置:
(抱歉,我不知道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>
虚拟主机:
<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>