Nginx配置在RHEL 6.3版本中不起作用

时间:2016-03-10 04:51:37

标签: nginx configuration phalcon

我正在使用Red Hat Enterprise服务器来托管我的基于phalcon的应用程序。但部署后,应用程序无法运行并显示“请在您的Web服务器上启用重写模块以继续”。我在default.conf文件中使用以下配置。

如果有任何机构有任何想法,请帮助我解决问题。

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;
    }
}

2 个答案:

答案 0 :(得分:0)

您可以尝试在nginx配置中添加以下代码并再次检查。

try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=$1;
    }   

答案 1 :(得分:0)

这对你有用。 (超时很高,你应该根据你的应用规格进行更改)

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;
    }
}