我在ubuntu 13.10上设置了HHVM 3.1.0(夜间)的Apache 2.4。出于某种原因,服务器正确地提供了hhvm文件(.php),但是当我尝试加载.html / .css或者其他任何静态文件时启动下载而不是显示
我在stackoverflow问这个问题,但它被搁置,因为它是服务器相关: 原始post
我的HHVM server.ini如下所示:
hhvm.server.port = 9000 hhvm.server.type = fastcgi hhvm.server.default_document = index.php hhvm.server.source_root = /var/www hhvm.enable_static_content_from_disk = true
并且apache2.conf包含以下代理通配符:
ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/$1
有什么build议?
ProxyPassMatch指令仅用于将特定stream量(即对php文件的请求)路由到FastCGI服务器(即HHVM)。 改用ProxyPass指令:
ProxyPass / fcgi://127.0.0.1:9000/var/www/whatever.com/
根据文档 ,这应该将所有请求路由到FastCGI服务器。
编辑:好的,作为对您的评论的回应,ProxyPassMatch是您要使用的指令。
而不是在你如何设置所有的东西之间来回回顾,我只是解释一下如何在Ubuntu 12.04上设置它,也许你可以找出你错过的东西。
首先,我使用旧的.hdfconfiguration格式,即使我正在运行HHVM v3.1.0-dev,因为我似乎无法获取以新的.ini格式工作的访问日志。 我试过hhvm.log.access.file = /var/log/hhvm/access.log但没有奏效。 这是排除故障的重要日志,因此我现在要坚持使用.hdf。
这是我的新贵脚本:
description "HipHop VM server" start on filesystem or runlevel [2345] stop on runlevel [!2345] respawn respawn limit 10 5 umask 002 pre-start script mkdir -p -m0755 /var/run/hhvm chown apachetwo:threews /var/run/hhvm end script # Location of executable env SERVER=/usr/local/sbin/hhvm exec $SERVER --mode daemon -c /etc/hhvm/test.hdf --user apachetwo
每当我想停止和启动HHVM,我使用sudo stop hhvm和sudo start hhvm 。
这是我的/etc/hhvm/server.hdf文件:
PidFile = /var/run/hhvm/pid Server { Type = fastcgi Port = 9000 SourceRoot = /var/www/html/ DefaultDocument = index.php } Log { Level = Verbose AlwaysLogUnhandledExceptions = true RuntimeErrorReportingLevel = 8191 UseLogFile = true UseSyslog = false File = /var/log/hhvm/error.log Access { * { File = /var/log/hhvm/access.log Format = %h %l %u % t \”%r\” %>s %b } } } Repo { Central { Path = /var/log/hhvm/.hhvm.hhbc } } MySQL { TypedResults = false }
理论上,新的.ini格式的等效configuration文件看起来像这样:
; php options pid = /var/run/hhvm/pid ; hhvm specific hhvm.server.type = fastcgi hhvm.server.port = 9000 hhvm.server.source_root = /var/www/html hhvm.server.default_document = index.php hhvm.log.level = Verbose hhvm.log.always_log_unhandled_exceptions = true hhvm.log.runtime_error_reporting_level = 8191 hhvm.log.use_log_file = true hhvm.log.use_syslog = false hhvm.log.file = /var/log/hhvm/error.log hhvm.log.access.file = /var/log/hhvm/access.log hhvm.log.access.format = %h %l %u % t \”%r\” %>s %b hhvm.repo.central.path = /var/log/hhvm/.hhvm.hhbc hhvm.mysql.typed_results = false
而且,下面是一个基于我的站点之一的虚拟主机文件示例,这个站点被configuration为将对PHP脚本的请求委托给HHVM。 这恰好是通过mod_rewrite为Laravel 4.2.x站点提供干净的URL。 如果您的站点也configuration了干净的URL,请确保在RewriteRule行末尾有[PT] ,这样mod_rewrite会在完成之后将请求传递给mod_proxy。 最初,我正在使用[L] (可能是错误的),不知道为什么mod_proxy没有将请求传递给HHVM。
<VirtualHost *:80> ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/site.com/htdocs/public/$1 DirectorySlash On DirectoryIndex index.php ServerAdmin [email protected] ServerName www.site.com DocumentRoot /var/www/site.com/htdocs/public/ AllowEncodedSlashes On # Don't display the ServerAdmin email address on server generated pages ServerSignature Off RewriteEngine On RewriteCond %{REQUEST_FILENAME} !^(index\.php|/images|/includes|/cache|/mpd|/packages|/queues|/samples|/robots\.txt|/sitemap\.xml) RewriteRule ^(.*)$ /index.php$1 [PT] <Directory /var/www/site.com/htdocs> Require all granted Options +FollowSymLinks AllowOverride None </Directory> <Directory /var/www/site.com/htdocs/public> Require all granted Options +FollowSymLinks AllowOverride None </Directory> ErrorLog /var/log/apache2/www.site.com.error.log LogLevel alert rewrite:trace6 proxy:trace6 CustomLog /var/log/apache2/www.site.com.access.log combined </VirtualHost>
我认为这些是你需要关注的主要三个configuration文件。 ProxyPassMatch指令应指示Apache将PHP文件的请求代理到HHVM。 其他文件types的请求应该像Apache一样正常运行。 如果你可以注释掉ProxyPassMatch指令,重新启动Apache,一切正常,那么我会感到惊讶。 我猜你的Apache是责备提供CSS,JS和HTML文件作为下载。