Welcome Guest, Not a member yet? Register   Sign In
routes working only in local
#1
Exclamation 
(This post was last modified: 06-12-2015, 11:10 PM by StratoKyke.)

Hello,
I developed my project in local and the routes work perfectly:

PHP Code:
$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['page/(:any)'] = 'page/thread/$1';
$route['translate_uri_dashes'] = FALSE;

$route['acp'] = 'acp/user/login';
$route['acp/page/edit/(:any)'] = 'acp/page/edit/$1';
$route['acp/page/delete/(:any)'] = 'acp/page/delete/$1';
$route['acp/menu/edit/(:any)'] = 'acp/menu/edit/$1';
$route['acp/menu/edit/(:any)'] = 'acp/menu/delete/$1'

But when I try to move the project on my vps the all routes except of the default_controller it is not working.

This is the message:

Code:
404 Page Not Found

The page you requested was not found.

How can I fix?
Reply
#2

(This post was last modified: 06-10-2015, 12:51 PM by StratoKyke.)

For example in local I use domain.local/folder/index.php/acp/ and I go to login.
In the same way mydomain.com/folder/index.php/acp/ return the 404 error.

In local I use apache, in my hosting I have xginx. This is the problem?
Reply
#3

Hey StratoKyke,

If you're using nginx on your live server, you have to adapt one of the .conf files. Nginx does NOT use .htaccess files, so without changes to your nginx server, CI won't work.
That's all I know about this matter. I have almost no experience with configuring nginx, I'm sorry... 
I hope someone with nginx experience can help you.

-Roger
Reply
#4

Thanks for the reply.
I wonder if there is a configuration that you can make on codeigniter to fit nginx.
Reply
#5

(This post was last modified: 06-10-2015, 03:32 PM by CroNiX.)

Codeigniter has nothing to do with the server it's being run on. The server, whether it's Apache, NGINX, LightHTTP, IIS or something else it needs to be set up to run the PHP application, whether it's CI or WordPress or something else. The application can't alter to webserver to "make itself run". No webserver runs PHP by default, except maybe PHP's built-in webserver.

Here's a working NGINX conf for a CI site:
Code:
server {
    listen 80;

    server_name YOUR_SERVER.com ;
    root /var/www/PATH_TO_SITE_ROOT;

    error_page 404 403 /404.html;

    location / {
        index index.html index.php; ## Allow a static html file to be shown first
        try_files $uri $uri/ @handler;
        expires 30d; ## Assume all files are cachable
    }

    ## These locations would be hidden by .htaccess normally
    location ^~ /application/        { deny all; }

    location  /. { ## Disable .htaccess and other hidden files
        return 404;
    }

    location @handler {
        rewrite / /index.php;
    }

    location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*.php)/ $1 last;
    }

    location ~ .php$ { ## Execute PHP scripts
        if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss

        expires        off; ## Do not cache dynamic content
        fastcgi_param  HTTPS $fastcgi_https;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  SITE_ENVIRONMENT development;
        fastcgi_pass   unix:/tmp/php-fpm.sock;
        include        fastcgi_params; ## See /etc/nginx/fastcgi_params
    }
}

The main things you would need to change with your values are:
Code:
server_name YOUR_SERVER.com ;
root /var/www/PATH_TO_SITE_ROOT;

and to set the site environment:
Code:
fastcgi_param  SITE_ENVIRONMENT development;
Reply
#6

(This post was last modified: 06-10-2015, 04:17 PM by StratoKyke.)

(06-10-2015, 03:31 PM)CroNiX Wrote: Codeigniter has nothing to do with the server it's being run on. The server, whether it's Apache, NGINX, LightHTTP, IIS or something else it needs to be set up to run the PHP application, whether it's CI or WordPress or something else. The application can't alter to webserver to "make itself run". No webserver runs PHP by default, except maybe PHP's built-in webserver.

Here's a working NGINX conf for a CI site:

Code:
server {
   listen 80;

   server_name YOUR_SERVER.com ;
   root /var/www/PATH_TO_SITE_ROOT;

   error_page 404 403 /404.html;

   location / {
       index index.html index.php; ## Allow a static html file to be shown first
       try_files $uri $uri/ @handler;
       expires 30d; ## Assume all files are cachable
   }

   ## These locations would be hidden by .htaccess normally
   location ^~ /application/        { deny all; }

   location  /. { ## Disable .htaccess and other hidden files
       return 404;
   }

   location @handler {
       rewrite / /index.php;
   }

   location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
       rewrite ^(.*.php)/ $1 last;
   }

   location ~ .php$ { ## Execute PHP scripts
       if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss

       expires        off; ## Do not cache dynamic content
       fastcgi_param  HTTPS $fastcgi_https;
       fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
       fastcgi_param  SITE_ENVIRONMENT development;
       fastcgi_pass   unix:/tmp/php-fpm.sock;
       include        fastcgi_params; ## See /etc/nginx/fastcgi_params
   }
}

The main things you would need to change with your values are:

Code:
server_name YOUR_SERVER.com ;
root /var/www/PATH_TO_SITE_ROOT;

and to set the site environment:

Code:
fastcgi_param  SITE_ENVIRONMENT development;


This configuration when I should I put it?

I have a vps with plesk with more sites installed.

Normally it should be inserted in /etc/nginx/nginx.conf, no?

I read that in the plesk 12 for nginx.config we can create a vhost_nginx.conf in /var/www/vhosts/system/domain/conf

But when I try to insert the file with your configuration
Nothing changes. I also tried to restart the nginx.
I always give me error 404.
Reply
#7

I'm sorry, I don't know anything about how plesk operates or where it puts files.

Mine's in: /etc/nginx/conf.d/www.mysitename.com.conf
Reply
#8

When I try to set vhost_nginx.conf I receve this error:

Code:
/usr/local/psa/admin/bin/nginxmng --enable
[2015-06-11 08:51:41] ERR [util_exec] proc_close() failed
[2015-06-11 08:51:45] ERR [panel] Apache config (14340054980.97032600) generation failed: Template_Exception: nginx: [emerg] "http" directive is not allowed here in /var/www/vhosts/system/domain.com/conf/vhost_nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed

file: /opt/psa/admin/plib/Template/Writer/Webserver/Abstract.php
line: 75
code: 0
nginx: [emerg] "http" directive is not allowed here in /var/www/vhosts/system/domain.com/conf/vhost_nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed
Reply
#9

(This post was last modified: 06-11-2015, 05:18 AM by StratoKyke.)

I added http  { before server { because it gave me the same error but with the server. So read on the internet I saw that putting http { before some had resolved. But it is not for me.


If I edit the additional nginx declaration with this:

PHP Code:
## These locations would be hidden by .htaccess normally
location ^~ /application       deny all; }

location  /. { ## Disable .htaccess and other hidden files
return 404;
}

location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}

location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires        off## Do not cache dynamic content
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
fastcgi_param  SITE_ENVIRONMENT production;
fastcgi_pass   unix:/tmp/php-fpm.sock;
include 
       fastcgi_params## See /etc/nginx/fastcgi_params




I receive a 502 bad gateway on routes.


I edit the file in this way:

Code:
proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;
## These locations would be hidden by .htaccess normally
location ^~ /application/        { deny all; }

location  /. { ## Disable .htaccess and other hidden files
return 404;
}

location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}

location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires        off; ## Do not cache dynamic content
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
fastcgi_param  SITE_ENVIRONMENT production;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include        fastcgi_params; ## See /etc/nginx/fastcgi_params
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
}

and in this moment I have 404 page not found.


EDIT: I stop, I do not know what to do and groped.

I look for someone who can help you Sad

Site is not in any controller. Only the main one. I also tried to disable nginx but the result is the 404 page not found.

EDIT2: But if the nginx.conf serves essentially to replace the .htaccess. Not everything should work equally? Since I have not used in local .htaccess?
Reply
#10

Someone can help me? For this problem?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB