
우분투 13.10에서 HHVM 3.1.0(야간)으로 Apache 2.4를 설정했습니다. 어떤 이유로 서버가 hhvm 파일(.php)을 올바르게 제공하지만 .html/.css 또는 기타 정적 파일을 로드하려고 하면 표시하는 대신 다운로드를 시작합니다.
나는 stackoverflow에 이 질문을 했지만 서버와 관련된 문제이기 때문에 보류되었습니다.원본 게시물
내 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가 포함되어 있습니다.
ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/$1
어떤 충고?
답변1
ProxyPassMatch 지시어는 특정 트래픽(예: PHP 파일 요청)만 FastCGI 서버(예: HHVM)로 라우팅하기 위한 것입니다. 대신 ProxyPass 지시문을 사용하세요.
ProxyPass / fcgi://127.0.0.1:9000/var/www/whatever.com/
에 따르면선적 서류 비치, 모든 요청을 FastCGI 서버로 라우팅해야 합니다.
편집: 좋습니다. 귀하의 의견에 대한 응답으로 ProxyPassMatch는 귀하가 사용하려는 지시문입니다.
모든 것을 어떻게 설정했는지 설명하기보다는 Ubuntu 12.04에서 어떻게 설정했는지 설명하겠습니다. 아마도 여러분이 무엇을 놓치고 있는지 알아낼 수 있을 것입니다.
우선 HHVM v3.1.0-dev를 실행하고 있음에도 불구하고 이전 .hdf 구성 형식을 사용하고 있습니다. 새로운 .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
형식의 해당 구성 파일은 다음과 같습니다.
; 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
다음은 PHP 스크립트에 대한 요청을 HHVM으로 프록시하도록 구성된 내 사이트 중 하나를 기반으로 하는 VirtualHost 파일의 예입니다. 이는 mod_rewrite를 통해 깨끗한 URL이 있는 Laravel 4.2.x 사이트에서 발생합니다. 사이트가 깨끗한 URL로 구성되어 있는 경우 mod_rewrite가 작업이 완료된 후 mod_proxy로 요청을 전달할 수 있도록 줄 [PT]
끝에 가 있는지 확인하십시오 . RewriteRule
처음에는 (아마도 오류가 있을 수 있음)을 사용하고 있었는데 [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>
나는 이것이 집중해야 할 세 가지 주요 구성 파일이라고 생각합니다. ProxyPassMatch 지시문은 Apache에게 PHP 파일에 대한 요청을 HHVM으로 프록시하도록 지시해야 합니다. 다른 파일 형식에 대한 요청은 일반적으로 Apache에서 처리해야 합니다. ProxyPassMatch 지시어를 주석 처리하고 Apache를 다시 시작하면 모든 것이 제대로 작동한다면 놀랄 것입니다. 나는 귀하의 Apache가 CSS, JS 및 HTML 파일을 다운로드로 제공한다고 생각합니다.