Reputation: 7598
I know this is not an uncommon problem, but somehow I don’t seem to be able to find a direct answer. Is somebody able to answer this as straight forward as possible?
My NGINX (deliver static files) and HHVM (hhvm index.php
from console) are working just fine, but I can't access a .php through NGINX without getting a 404
Situation:
HHVM 3.5.0
Nginx 1.7.9
I have this in my /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
include hhvm.conf;
}
In HHVM.conf
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Upvotes: 3
Views: 2149
Reputation: 7413
The root
directive is defined inside location
, this is why it is not accessible inside hhvm.conf via the variable $document_root
.
It should be moved directly to the level of server
:
server {
listen 80;
server_name localhost;
root /var/www;
location / {
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
include hhvm.conf;
}
Then, no modification is needed in your hhvm.conf
, although you may do some cleanup there too.
Upvotes: 2
Reputation: 9415
Replace the below HHVM conf with yours:
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Problem
I see a space between $document_root
and $fastcgi_script_name
.
Update
Solved by changing $document_root
with /var/www
Upvotes: 2