chrisburton
5 years ago
7196
19
General

Nginx setup for subdirectory

Posted 5 years ago by chrisburton

Quick info:

I have my main site: site.com and I installed Laravel 5 in a subdirectory named 'laravel'.

I tried setting up a virtual host laravel.conf but I'm not able to get anything working. Any tutorial I try to follow, it's usually for setting up Laravel in a subdirectory but accessing it at the root domain level. I want to access Laravel via site.com/laravel and not site.com.

Laravel.conf file

server {
    listen 80;

    root /var/www/html/laravel/public;
    index index.php index.html index.htm;

    server_name site.com;

    access_log /var/log/nginx/localhost.laravel-access.log;
    error_log  /var/log/nginx/locahost.laravel-error.log error;


    location /laravel {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }


# ERROR
    error_page 404 /index.php; 


# HHVM
    include hhvm.conf; 


# DENY HTACCESS   
    location ~ /\.ht {
        deny all;
    }
}

Please sign in or create an account to participate in this conversation.