2016-10-29 6 views
0

Я пытаюсь использовать Nginx в MAMP, но по некоторым причинам я не могу просмотреть любой .php файл, он всегда возвращает 404.Nginx (MAMP) возвращает 404 на index.php

У меня нет проблема с файлами .html.

Кто-нибудь знает, что вызывает это и как я могу это решить?

Мой nginx.conf:

#user       admin staff; 
worker_processes    2; 

pid  c:/MAMP/bin/nginx/pid/nginx.pid; 

events { 
    worker_connections  1024; 
} 

http { 
    include     mime.types; 
    default_type    text/html; 
    gzip      on; 
    gzip_types    text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon; 

    sendfile     on; 

    server { 
     listen    80 default_server; 

     # MAMP DOCUMENT_ROOT !! Don't remove this line !! 
     root     "C:/MAMP/htdocs/"; 

     access_log c:/MAMP/logs/nginx_access.log; 

     error_log c:/MAMP/logs/nginx_error.log; 

     location/{ 
      root C:\Git; 
      index index.php index.html; 
      autoindex on; 
     } 

     location ~* /MAMP(.*)$ { 
      root    C:/MAMP/bin; 
      index   index.php; 

      location ~ \.php$ { 
       try_files  $uri =404; 
       fastcgi_pass  127.0.0.1:9100; 
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
       include   fastcgi_params; 
      } 
     } 

     location ~* /phpMyAdmin(.*)$ { 
      root    C:/MAMP/bin; 
      index   index.php; 

      location ~ \.php$ { 
       try_files  $uri =404; 
       fastcgi_pass  127.0.0.1:9100; 
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
       include   fastcgi_params; 
      } 
     } 

     location ~* /phpLiteAdmin(.*)$ { 
      root    C:/MAMP/bin; 
      index   phpliteadmin.php index.php; 

      location ~ \.php$ { 
       try_files  $uri =404; 
       fastcgi_pass  127.0.0.1:9100; 
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
       include   fastcgi_params; 
      } 
     } 

     location ~* /SQLiteManager(.*)$ { 
      root    C:/MAMP/bin; 
      index   index.php; 

      location ~ \.php$ { 
       try_files  $uri =404; 
       fastcgi_pass  127.0.0.1:9100; 
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
       include   fastcgi_params; 
      } 
     } 

     #location /icons { 
     # alias /Applications/MAMP/Library/icons; 
     # autoindex on; 
     #} 

     #location /favicon.ico { 
     # alias /Applications/MAMP/bin/favicon.ico; 
     # # log_not_found off; 
     # # access_log off; 
     #} 

     location ~ \.php$ { 
      try_files  $uri =404; 
      fastcgi_pass  127.0.0.1:9100; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include   fastcgi_params; 
     } 

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

     # location ~* \.(gif|jpg|png|pdf)$ { 
     # expires   30d; 
     # } 

     # location = /robots.txt { 
     # allow all; 
     # log_not_found off; 
     # access_log off; 
     # } 

     # location ~* \.(txt|log)$ { 
     # allow 127.0.0.1; 
     # deny all; 
     # } 

     # location ~ \..*/.*\.php$ { 
     # return 403; 
     # } 

     #location /nginx_status { 
     # stub_status  on; 
     # access_log  off; 
     # allow   127.0.0.1; 
     # deny    all; 
     #} 
    } 
} 
+1

Что говорит журналы Nginx? – Deep

+0

@Deep Спасибо за вопрос, я обнаружил, что это проблема с MAMP Document_root. Я изменил это в MAMP, но не понял, что мне пришлось изменить его в nginx.config – Lennart

ответ

0

Deep рекомендуется проверить журналы Nginx, так что я сделал, я нашел следующую строку:

[error] 14468#14504: *12 directory index of "C:/MAMP/htdocs/" is forbidden, client: 127.0.0.1, server: , request: "GET/HTTP/1.1", host: "localhost" 

Я вспомнил, я изменил document_root в самой MAMP, но никогда не делал этого в моем nginx.conf

После изменения Document_Root в nginx.conf файлы .php работали :)

Линия, я изменил к реальному document_root:

# MAMP DOCUMENT_ROOT !! Don't remove this line !! 
root     "C:/MAMP/htdocs/";