I am using Ubuntu 14.04 + nginx + HHVM on a Unix socket.
I have a few projects, all running under the same IP in different subdirectories. I have been trying to make the configuration modular, so as projects get changed, only small changes are needed. However, not a single site is working. What I get is a plain '404 File Not Found' page without HTML markup. Nothing showed up from both nginx and HHVM's error log.
Here's my directory structure:
nginx/
main/
index.php
phpmyadmin/
index.php
laravel/
public/
index.php
And my nginx configuration:
global
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log info;
charset utf-8;
root /usr/share/nginx;
include /etc/nginx/sites-available/main.conf;
#include /etc/nginx/sites-available/phpmyadmin.conf;
#include /etc/nginx/sites-available/laravel.conf;
include hhvm.conf;
# Deny .htaccess file access
location ~ /\.ht {
deny all;
}
}
main.conf
location / {
root /usr/share/nginx/main;
index index.php;
try_files $uri $uri/ =400;
}
hhvm.conf
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Maybe the easiest way is to create a vhost for every project. So you have one domain (without a folder in the url) and it's modular too.
But if you want to stay with your structure, it's maybe possible with this config:
# For example for your main:
location /main {
root /usr/share/nginx/main;
include hhvm.conf;
index index.php;
try_files $uri $uri/ =400;
}
These blocks are needed for /main, /phpmyadmin and /laravel.
BUT, the problem with this solution could be that laravel for example is easiest to use on a domain like laravel.local
and not within a folder like pc.local/laravel
because of the url rewriting you need for it.
That would be another reason to switch to vhosts with an own domain for each of your folders. Subdomains are possible too.