无法在nginx php-fpm上运行.html文件

前端之家收集整理的这篇文章主要介绍了无法在nginx php-fpm上运行.html文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我无法在运行NginxPHP-fpm的Ubuntu 12.04服务器上运行.html文件.

执行.html扩展文件时,我得到的是拒绝访问. .PHP文件运行得很好.

这是我的配置代码.

Nginx.conf

  1. user www-data;
  2. worker_processes 4; # Make this equal to no of processors you have "cat /proc/cpuinfo |grep processor" @mayur
  3. pid /var/run/Nginx.pid;
  4. events {
  5. worker_connections 2048; # Essential to keep it high for heavy sites @mayur
  6. # multi_accept on;
  7. }
  8. http {
  9. ##
  10. # Basic Settings
  11. ##
  12. sendfile on;
  13. tcp_nopush on;
  14. tcp_nodelay on;
  15. keepalive_timeout 65;
  16. types_hash_max_size 2048;
  17. server_tokens on; #Make this off Live Server for Security Reasons: @mayur
  18. # server_names_hash_bucket_size 64;
  19. # server_name_in_redirect off;
  20. include /etc/Nginx/mime.types;
  21. default_type application/octet-stream;
  22. ##
  23. # Logging Settings
  24. ##
  25. access_log /var/log/Nginx/access.log;
  26. error_log /var/log/Nginx/error.log;
  27. log_format main '$remote_addr - $remote_user [$time_local] $request '
  28. '"$status" $body_bytes_sent "$http_referer" '
  29. '"$http_user_agent" "$http_x_forwarded_for"';
  30. ##
  31. # Gzip Settings
  32. ##
  33. gzip on;
  34. gzip_disable "msie6";
  35. # gzip_vary on;
  36. # gzip_proxied any;
  37. # gzip_comp_level 6;
  38. # gzip_buffers 16 8k;
  39. # gzip_http_version 1.1;
  40. # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+RSS text/javascript;
  41. ##
  42. # Nginx-naxsi config
  43. ##
  44. # Uncomment it if you installed Nginx-naxsi
  45. ##
  46. #include /etc/Nginx/naxsi_core.rules;
  47. ##
  48. # Nginx-passenger config
  49. ##
  50. # Uncomment it if you installed Nginx-passenger
  51. ##
  52. #passenger_root /usr;
  53. #passenger_ruby /usr/bin/ruby;
  54. ##
  55. # Virtual Host Configs
  56. ##
  57. include /etc/Nginx/conf.d/*.conf;
  58. include /etc/Nginx/sites-enabled/*;
  59. }

网站可用/默认

  1. server {
  2. listen 80; ## listen for ipv4; this line is default and implied
  3. access_log /var/log/Nginx/access.log;
  4. error_log /var/log/Nginx/error.log;
  5. root /data/paytm/htdocs;
  6. index index.PHP index.html;
  7. server_name localhost;
  8. ssi on;
  9. location ~* ^.+\.(jpg|js|jpeg|png|ico|gif|js|css|swf)${
  10. expires 24h;
  11. }
  12. location ~ ^/.*\.html${
  13. fastcgi_pass unix:/tmp/PHP5-fpm.sock;
  14. fastcgi_index index.html;
  15. fastcgi_param SCRIPT_FILENAME /data/paytm/htdocs/$fastcgi_script_name;
  16. include fastcgi_params;
  17. }
  18. location ~ ^/.*\.PHP${
  19. fastcgi_pass unix:/tmp/PHP5-fpm.sock;
  20. fastcgi_index index.html;
  21. fastcgi_param SCRIPT_FILENAME /data/paytm/htdocs/$fastcgi_script_name;
  22. include fastcgi_params;
  23. }
  24. # For APIs and other stuff where we write our own Header Variables
  25. underscores_in_headers on;
  26. ignore_invalid_headers off;
  27. }
最佳答案
请参阅:https://bugs.php.net/bug.php?id=60763您需要添加到[www]部分内的/etc/PHP5/fpm/pool.d/www.conf

  1. security.limit_extensions = .PHP .html

猜你在找的Nginx相关文章