i have an old kohana app that i'm trying to put on my VPS but can't seem to get it working. i've spent hours googling and looking at cached forum answers. i have tried them all and nothing seems to work. admittedly, i have no idea how to deal with nginx. my local version of the app works fine with apache. i'm one step away from just canceling my linode account and getting shared hosting! please talk me off this ledge.
My VPS is running Ubuntu 14.04 LTS with php5-fpm and nginx 1.4.6. I am serving everything from my user directory.
My nginx sites-available file:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/gabreal/Sites/public;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name localhost;
location / {
try_files $uri $uri/ @kohana =404;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location @kohana {
rewrite ^/(.+)$ /index.php$request_uri last;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
My Kohana application is in the directory like so:
├──/home/gabreal/Sites/public/
│ ├── horizons/
│ │ ├── grader/ (aka the kohana application)
│ │ │ ├── index.php
│ │ │ ├── application/
│ │ │ ├── system/
When i visit the application by going to http://example.com/horizons/grader
the kohana bootstrap file loads and all the redirects are called. For example, my default route redirects you to a start page. if you aren't logged in, you go to 'user/login'. the url is being set correctly. going to the url above, the browser redirects to http://example.com/horizons/grader/user/login
but i get nginx 404 page.
so somehow the controller/action
pattern is just not working with this nginx setup.
please help for the love of whatever you love in this world.
UPDATE
just FYI, i installed phpmyadmin and it is working perfectly. i still can't get kohana to work though...
UPDATE 2
i did a fresh install of kohana and tried to set up a few basic controllers. only the default controller works just like in my application. so, going to the base url for my application ALWAYS works but going directly to any /controller/action/id type of resource gives me nginx 404 error on both a fresh install and my existing application.
The nginx configuration you are using is no longer considered the correct way to pass PHP execution back to FPM. The following example (UPDATED IN 2020), based on your original and slightly modified parts of the WordPress documentation, is a better way that should work for you.
upstream php {
#this should match value of "listen" directive in php-fpm pool
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/gabreal/Sites/public;
index index.html index.htm index.php;
server_name localhost;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Note that for brevity I did not include the 404 and 50x handlers and the .ht
-file protector. You can put those back in from your example in the question.