The System Is Unable To Find The Requested Action "error"

Hi all,

I have an app that previously run on apache without any problem, now i want to change it to nginx. So i transfer the app to nginx server to test first.

First problem i encounter, i could not login (click on the login button it just stay there), i google and solved that issue.

but now after login im getting this error




CHttpException


The system is unable to find the requested action "error". (/usr/share/nginx/www/xxx/framework/web/CController.php:483)


#0 /usr/share/nginx/www/xxx/framework/web/CController.php(270): CController->missingAction('error')

#1 /usr/share/nginx/www/xxx/framework/web/CWebApplication.php(282): CController->run('error')

#2 /usr/share/nginx/www/xxx/framework/base/CErrorHandler.php(331): CWebApplication->runController('site/error')

#3 /usr/share/nginx/www/xxx/framework/base/CErrorHandler.php(204): CErrorHandler->render('error', Array)

#4 /usr/share/nginx/www/xxx/framework/base/CErrorHandler.php(129): CErrorHandler->handleException(Object(CHttpException))

#5 /usr/share/nginx/www/xxx/framework/base/CApplication.php(720): CErrorHandler->handle(Object(CExceptionEvent))

#6 [internal function]: CApplication->handleException(Object(CHttpException))

#7 {main}

do you have a actionError in your SiteController?

Thanks for you response

you mean in /protected/controllers ? No i don’t see actionError in that directory

could you help, sorry im not a programmer, this app was written by some programmer i hire, but i can’t not get a hold of him anymore.

How come it work in apache without it but not on nginx?

@tdx:

  1. First make sure nginx runs fine with a simple .html page; if not, check your installation.

  2. Next check if nginx can run a simple .php script page such as <? phpinfo(); ?>; if not, check your php-fpm installation because nginx – as opposed to Apache – doesn’t include PHP support out of the box. I’d also change the php-fpm user from apache to nginx at /etc/php-fpm.d/www.conf.

  3. Make sure you can display the Yii requirements page at (yii folder)/requirements and fix any missing requirements.

From your post it looks like that all of the above are working because you’re getting a Yii CHttpException (and not a PHP) error, but it never hurts to double check. It seems to me that the application is failing because of the UrlManager rules in protected/config/main.php are not appropriate for an nginx environment (especially if they depended upon Apache .htaccess rules) but to rule out nginx then check the next steps.

I use CentOS so YMMV with a different Linux flavor.

  1. My /etc/nginx/nginx.conf looks as follows:



user  nginx nginx;

worker_processes  4;


error_log  /var/log/nginx/error.log warn;

pid        /var/run/nginx.pid;




events {

    worker_connections  1024;

}




http {

    include       /etc/nginx/mime.types;

    default_type  application/octet-stream;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';


    access_log  /var/log/nginx/access.log  main;


    sendfile        on;

    #tcp_nopush     on;

    client_max_body_size 10M;

    keepalive_timeout  65;


    gzip  on;


    include /etc/nginx/conf.d/*.conf;

}



  1. nginx will look for configuration files in /etc/nginx/conf.d that have a .conf extension and load them (that’s how it can manage more than 1 app). One of my configurations is called xyz.conf (details obfuscated) and looks as follows:



server {

        listen 1.2.3.4:80;

	set $host_path "/home/xyz";

        server_name  xyz.com *.xyz.com;

        root $host_path;

	set $yii_bootstrap "index.php";

        charset utf-8;

	

	location / {

        index  index.html $yii_bootstrap;

        try_files $uri $uri/ /$yii_bootstrap?$args;

    }

	

	#avoid processing of calls to unexisting static files by yii

        location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {

        try_files $uri =404;

    }


	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    location ~ \.php {

        fastcgi_split_path_info  ^(.+\.php)(.*)$;


        #let yii catch the calls to unexising PHP files

        set $fsn /$yii_bootstrap;

        if (-f $document_root$fastcgi_script_name){

            set $fsn $fastcgi_script_name;

        }


        fastcgi_pass   127.0.0.1:9000;

        include fastcgi_params;

        fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;


        #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI

        fastcgi_param  PATH_INFO        $fastcgi_path_info;

        fastcgi_param  PATH_TRANSLATED  $document_root$fsn;

    }

}



fastcgi_params (in /etc/nginx) contains the default parameters that come with php-fpm so no changes there are needed.

If indeed the problem is in the UrlManager rules, I’m afraid you’ll need a programmer to help you. Perhaps if you post the urlManager section of protected/config/main.php you can get help here.

I hope this helps…

hi,

this is the urlmanager for the app


'urlManager'=>array(

			'urlFormat'=>'path',

                        'showScriptName' => false,

			'urlSuffix' => "",

			'rules'=>array(

                                'dashboard'=>'Site/SiteDashboard',

                                'adduser'=>'Account/AddUser',

                                'message'=>'Site/Message',

                                'showmessage'=>'Site/ShowMessage',

                                'listuser'=>'Account/ListUser',

                                'Account/GetUserByID/<strid:>'=>'Account/GetUserByID/strid/<strid>',

                                'listdevice'=>'Device/ListDevice',

                                'listcategory'=>'Category/ListCate',

                                'listvideo'=>'Video/ListVideo',

                                'listm3u8'=>'Listm3u8/ListM3U8',

                                'showurl/<strid:>'=>'Listm3u8/ShowUrl/strid/<strid>',

                                'editm3u8/<strid:>'=>'Listm3u8/EditM3U8/strid/<strid>',

                                'listfile'=>'File/List',

                                'listsub'=>'Sub/List',

                                'showurlsub/<strid:>'=>'Sub/ShowUrl/strid/<strid>',

                                'showurlepi/<strid:>'=>'Episode/ShowUrl/strid/<strid>',

                                'showurlfile/<strid:>'=>'File/ShowUrl/strid/<strid>',

                                'showurlfile1/<strid:>'=>'File/ShowUrl1/strid/<strid>',

                                'editsub/<strid:>'=>'Sub/Edit/strid/<strid>',

                                'editfile/<strid:>'=>'File/Edit/strid/<strid>',

                                'video/add'=>'Video/AddVideo',

                                'video/edit/<strid:>'=>'Video/GetVideoByID/strid/<strid>',

                                'listepisode/<strid:>'=>'Episode/ListEpisode/strid/<strid>',

                                'getlistepisode/<strid:>'=>'Episode/GetListEpisode/strid/<strid>',

                                'getnumlistepisode/<strid:>'=>'Episode/GetNumListEpisode/strid/<strid>',

                                'episode/add/<strid:>'=>'Episode/AddEpisode/strid/<strid>',

                                'episode/add/<strid:>'=>'Episode/AddEpisode/strid/<strid>',

                                'uploadepisode/<strid:>'=>'Episode/ImageUpload/strid/<strid>',

                                'getdevicebyid/<strid:>'=>'Device/GetDeviceByID/strid/<strid>',

                                'updatedeviceimage/<strid:>'=>'Device/UpdateImage/strid/<strid>',

                                

                                

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),

The rules look fine except that I’d be concerned about the routes being written in PascalCase (words created by concatenating capitalized words) if your system is Linux because unlike Windows, it makes a difference.

One possible scenario is that Yii can’t find the route as spelled so it automatically goes to the errorAction() method in SiteController (which it calls “site”, not “Site”) to display an error page. However, it doesn’t find it and thus generates the CHttpException, as shown in the error message you posted originally. Look in protected/controllers/SiteController for the actionError() method; if it’s not there (or written in PascalCase) that’s probably the cause of the error.

If the problem is indeed the PascalCase spelling, rather than renaming everything (files and folders) to camelCase (same thing but the first word is in lowercase) you can rewrite the urlManager rules to make them case insensitive (see the Class Reference):




'urlManager'=>array(

    'urlFormat'=>'path',

    'showScriptName' => false,

    'urlSuffix' => "",

    'rules'=>array(

        array('Site/SiteDashboard', 'pattern'=>'dashboard', 'caseSensitive'=>false),

        array('Account/AddUser', 'pattern'=>'adduser', 'caseSensitive'=>false),

        ...



Good luck.

Thank you i will try that and report back.

Also on ngnix do you have to enable such module like mod_rewrite on apache like this


a2enmod rewrite

because before i have issue with apache i have to enable mod rewrite and the rewrite rule in htaccess file then it work. But im clueless on nginx

nginx handles mod_rewrites internally, as the scripts I posted show (the location directives), so there’s no specific module you need to enable/disable for URL rewrites. I understand you’re not a programmer but if you’re going to be fiddling with this you might as well learn about nginx at nginx.org. Good luck.

so i start everything fresh and follow this guide and it working

http://www.yiiframework.com/doc/guide/1.1/en/quickstart.apache-nginx-config

but still have couple question hope you can point it out for me

in the nginx config file


 server_name  mysite;

    root   $host_path/MyApp;

    set $yii_bootstrap "index.php";

note ( root $host_path/MyApp; )

so when i go to http://mysite.com it work fine no error or any.

but if i go to http://mysite.com/MyApp it will throw a CHttpException error and the app is not working.

the app is locate in /usr/share/nginx/www/MyApp

i try to change $host_path/MyApp; to $host_path; though it would work but it doesn’t, the login page of my app show up but when try to login it doesn’t do anything.

if you could please explain and how do i make it work with http://mysite.com/MyApp instead of http://mysite.com.

sorry for the noob question, still to to learn and understand nginx

Thank you