I'm not a network admin (as you'll quickly realise) but have set up a test environment of a new customer's site on a VPS. For reasons beyond my control this is an Opencart site with a bit of Laravel 4 in it as well. It currently runs on an Apache server but I would like to get it working in this test environment using Nginx instead, before I start working in it. I have managed to set the Nginx config to work with Opencart and have got Nginx to work on Laravel only sites before, but combing both has proven beyond me.
The Opencart site works fine but when I go to a Laravel URL (laravel/public) PHP doesn't serve the pages. Instead they get treated as a download. I was wondering if anyone could have a look and give me an idea of what I'm doing wrong.
Thanks
Here's what the config looks like (i've changed the URLs to protect the innocent!).
server {
listen [::]:80;
listen 80;
server_name www.blah.blah.com;
return 301 $scheme://blah.blah.com$request_uri;
}
server {
listen [::]:80;
listen 80;
server_name blah.blah.com;
root /usr/share/nginx/blah.blah.com/html;
charset utf-8;
location / {
try_files $uri @opencart;
server_tokens off;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location ^~ /laravel {
try_files $uri $uri/ /laravel/public/index.php$query_string;
}
rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last;
rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;
rewrite ^/download/(.*) /index.php?route=error/not_found last;
rewrite /admin$ $scheme://$host$uri/ permanent;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi_params;
}
location /admin {
index index.php;
}
include h5bp/basic.conf;
}
The Opencart site works fine but when I go to a Laravel URL (laravel/public) PHP doesn't serve the pages. Instead they get treated as a download. I was wondering if anyone could have a look and give me an idea of what I'm doing wrong.
Thanks
Here's what the config looks like (i've changed the URLs to protect the innocent!).
server {
listen [::]:80;
listen 80;
server_name www.blah.blah.com;
return 301 $scheme://blah.blah.com$request_uri;
}
server {
listen [::]:80;
listen 80;
server_name blah.blah.com;
root /usr/share/nginx/blah.blah.com/html;
charset utf-8;
location / {
try_files $uri @opencart;
server_tokens off;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location ^~ /laravel {
try_files $uri $uri/ /laravel/public/index.php$query_string;
}
rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last;
rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;
rewrite ^/download/(.*) /index.php?route=error/not_found last;
rewrite /admin$ $scheme://$host$uri/ permanent;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi_params;
}
location /admin {
index index.php;
}
include h5bp/basic.conf;
}