0

I am using Red Hat Enterprise server for hosting my phalcon based application. But after deployment the application is not working and showing "Please enable rewrite module on your web server to continue". I am using the below configuration in my default.conf file.

If any body has any idea plz help me to resolve the issue.

server {
    listen      80;
    server_name example.com www.example.com;

    access_log /srv/www/example.com/log/access.log;
    error_log /srv/www/example.com/log/error.log;

    root /srv/www/example.com/public/;
    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ @php_mvc;
    }

    location @php_mvc {
        rewrite ^(.+)$ /index.php$1 last;
    }

    location ~ ^(.+\.php)(/.*)?$ {
        fastcgi_split_path_info ^(.+\.php)(/.*)?$;

        set $script_filename $document_root$fastcgi_script_name;

        if (!-e $script_filename) {
            return 404;
        }

        fastcgi_pass fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;

        fastcgi_param   APPLICATION_ENV development;
        fastcgi_param   SCRIPT_FILENAME $script_filename;
        fastcgi_param   SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param   PATH_INFO $fastcgi_path_info;
    }
}
MANOJ
  • 177
  • 5
  • 14

2 Answers2

0

Can you please try to add following code in your nginx configuration and check it again.

try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=$1;
    }   
24x7servermanagement
  • 2,520
  • 1
  • 13
  • 11
  • Boss can u share a full configuration script for RHEL 6.3,The above code is not working. Thanks in advance. – MANOJ Mar 10 '16 at 06:08
0

This will work for you. (timeouts are high, you should change it for your app specs)

server {
    listen   80 default_server;
    server_name  _;
    client_max_body_size 128M;
    location / {
        root /var/www/public;
        index  index.php index.html index.htm;
        try_files $uri $uri/ @rewrite;
        fastcgi_connect_timeout 3000;
        fastcgi_send_timeout 3000;
        fastcgi_read_timeout 3000;
        client_max_body_size 128M;
        proxy_read_timeout 3000;
    }
    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=$uri&$args;
    }
    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    location ~ \.php$ {
        root /var/www/public;
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 256 16k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
        include        fastcgi_params;
    }
    location ~ "\.(js|ico|gif|jpg|png|jpeg|xls|csv)$" {
        root /var/www/public;
    }
    location ~*  \.(jpg|jpeg|png|gif|ico)$ {
        expires 365d;
        log_not_found off;
        access_log off;
    }
}