繁体   English   中英

Nginx本地主机配置文件不起作用

[英]nginx localhost config file doesn't work

我在Windows上使用WPM-XM堆栈。 我正在本地环境中的两个PHP项目pcm,pcx工作。

我希望pcm项目使用pcm.conf文件。 但是我不是这样做的。 这是pcm.conf文件的内容:

server {
        # access from localhost only
        listen       127.0.0.1:80;
        server_name  localhost/pcm;

        # the following default "catch-all" configuration, allows access to the server from outside.
        # please ensure your firewall allows access to tcp/port 80. check your "skype" config.
        # listen       80;
        # server_name  _;

        log_not_found off;
        charset utf-8;

        access_log  logs/pcm.log  main;
        error_log logs/pcme.log;


        # handle files in the root path /www
        location / {
            root         /www/pcm;
            index  index.php index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   www;
        }

        location /pcxxc/ {
        deny all;
        }
        location ~ \.php$ {
            try_files      $uri =404;
            fastcgi_pass   php;
            fastcgi_index  index.php;
            #fastcgi_param  PHP_FCGI_MAX_REQUESTS 1000;
            #fastcgi_param  PHP_FCGI_CHILDREN 100;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param   REMOTE_ADDR $http_x_real_ip;
            include        fastcgi_params;
        }

        # add expire headers and speed up image access with a vary header
        location ~* ^.+.(gif|ico|jpg|jpeg|png|flv|swf|pdf|mp3|mp4|xml|txt|js|css)$ {
            expires 30d;
            add_header Vary Accept-Encoding;
        }

        # only allow these request methods
        if ($request_method !~ ^(GET|HEAD|POST)$ ){ return 405; }

        # deny access to .htaccess files (if Apache's document root concurs with nginx's one)
        # deny access to git & svn repositories
        location ~ /(\.ht|\.git|\.svn) {
            access_log off;
            log_not_found off;
            deny  all;
        }
    }
  }

我正在尝试访问url localhost / pcm / pcxxc /,以检查配置文件是否正常工作。 而不是显示访问被拒绝/您没有访问文件错误的权限。 Nginx报告404找不到错误。

保存上述配置文件的文件夹已添加到nginx主配置文件中

如何在Nginx(Windows)中正确设置多个项目的配置文件?

/pcm/pcxxc/请求与您的location /相匹配,该location /试图在目录/www/pcm/pcm/pcxxc/下提供一些索引文件,但失败。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM