【问题标题】:Why my nginx config doesn't work?为什么我的 nginx 配置不起作用?
【发布时间】:2018-07-19 18:32:47
【问题描述】:

我正在尝试设置 nginx 以开始使用 phalcon,这是配置:

server {
    listen      80;
    server_name localhost.dev;
    set $root_path '/usr/share/nginx/html/phalcon/public';
    root        $root_path;
    index       index.php index.html index.htm;
    charset     utf-8;
    rewrite_log on;

    location / {
        try_files $uri $uri/ /index.php?_url=$uri&$args;
    }

    location ~ \.php$ {
        try_files     $uri =404;

        fastcgi_pass   unix:/var/run/php/php5.6-fpm.sock;
        fastcgi_index /index.php;

        include fastcgi_params;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path/public;
    }

    location ~ /\.ht {
        deny all;
    }
}

我尝试了所有可能的方法,但仍然无法正常工作。 有什么线索吗?

【问题讨论】:

标签: nginx phalcon


【解决方案1】:

看这里

location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
    root $root_path;
}

【讨论】:

  • 一些文本到 sn-p(解释为什么要更改 root 值)会很好
  • 因为你的静态资源在 ./public 路径
猜你喜欢
  • 2018-02-21
  • 1970-01-01
  • 1970-01-01
  • 2019-04-21
  • 2021-07-01
  • 2015-05-29
  • 1970-01-01
  • 1970-01-01
  • 2018-01-14
相关资源
最近更新 更多