简体   繁体   English

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

[英]nginx localhost config file doesn't work

I am using WPM-XM stack on Windows. 我在Windows上使用WPM-XM堆栈。 I am working of two php projects pcm, pcx in a localhost environment. 我正在本地环境中的两个PHP项目pcm,pcx工作。

I want pcm project to use pcm.conf file. 我希望pcm项目使用pcm.conf文件。 But I'm not abele to do so. 但是我不是这样做的。 Here's the pcm.conf file's content: 这是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;
        }
    }
  }

I'm trying to access the url localhost/pcm/pcxxc/ to check whether the config file is working or not. 我正在尝试访问url localhost / pcm / pcxxc /,以检查配置文件是否正常工作。 Instead of displaying access denied/you don't have permission to access the file error. 而不是显示访问被拒绝/您没有访问文件错误的权限。 Nginx reports 404 not found error. Nginx报告404找不到错误。

The folder where the above config file is saved has been added in main nginx config file 保存上述配置文件的文件夹已添加到nginx主配置文件中

How to setup configuration files for multiple projects in Nginx (Windows) correctly? 如何在Nginx(Windows)中正确设置多个项目的配置文件?

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

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

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