I want to run codeigniter under NGINX but it just doesnt work. I want to be able to send a parameters to controllers methods. But so far I can not even access controller using the address example.com/index.php/welcome.php. It says No input file specified. However when I type example.com/index.php/ it redirects to welcome controller. I would say I have tried all nginx config files on the internet.
this is my ngnix config
server {
## Your website name goes here.
server_name compute.amazonaws.com;
## Your only path reference.
root /var/www/;
listen 80;
## This should be in your http block and if it is, it's not needed here.
index index.html index.htm index.php;
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
# location / {
# This is cool because no php is touched for static content
#try_files $uri $uri/ /index.php?q=$uri&$args;
# try_files $uri $uri/ /index.php;
#
location / {
try_files $uri $uri/ /index.php?$args;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}
location ~ \.php$ {
#try_files $uri =404;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_split_path_info ^(.+\.php)(.*)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
this is my welcome controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->helper('url');
$this->load->view('welcome_message');
}
function a($a)
{
echo "AHOJ ";
echo $a;
}
}
I want to be able to call function a from welcome controller and get response. Basicaly I want to build a REST server and this is my routes.php
$route['default_controller'] = "welcome";
$route['404_override'] = '';
$route['test_welcome'] = 'welcome';
$route['api/v1/(:any)'] = "api_v1/$1";
$route['item/(:any)'] = "item/show_item/$1";
$route['scaffolding_trigger'] = "";
The important line is $route['api/v1/(:any)'] = "api_v1/$1"; I want this to work.
This is my codeigniter config.php
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Please help me somehow. Thank you very much