当前位置:Gxlcms > php框架 > ThinkPHP 在阿里云上的nginx.config配置实例详解

ThinkPHP 在阿里云上的nginx.config配置实例详解

时间:2021-07-01 10:21:17 帮助过:36人阅读

具体代码如下所示:

  1. # For more information on configuration, see:
  2. # * Official English Documentation: http://nginx.org/en/docs/
  3. # * Official Russian Documentation: http://nginx.org/ru/docs/
  4. user nginx;
  5. worker_processes auto;
  6. error_log /var/log/nginx/error.log;
  7. pid /run/nginx.pid;
  8. events {
  9. worker_connections 1024;
  10. }
  11. http {
  12. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  13. '$status $body_bytes_sent "$http_referer" '
  14. '"$http_user_agent" "$http_x_forwarded_for"';
  15. access_log /var/log/nginx/access.log main;
  16. sendfile on;
  17. tcp_nopush on;
  18. tcp_nodelay on;
  19. keepalive_timeout 65;
  20. types_hash_max_size 2048;
  21. include /etc/nginx/mime.types;
  22. default_type application/octet-stream;
  23. # Load modular configuration files from the /etc/nginx/conf.d directory.
  24. # See http://nginx.org/en/docs/ngx_core_module.html#include
  25. # for more information.
  26. include /etc/nginx/conf.d/*.conf;
  27. server {
  28. listen 80 default_server;
  29. listen [::]:80 default_server;
  30. server_name _;
  31. root /usr/share/nginx/html;
  32. # Load configuration files for the default server block.
  33. include /etc/nginx/default.d/*.conf;
  34. location / {
  35. #try_files $uri $uri/ /index.php;
  36. root /usr/share/nginx/html;
  37. index index.php index.html index.htm;
  38. if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; }
  39. }
  40. # redirect server error pages to the static page /40x.html
  41. #
  42. error_page 404 /404.html;
  43. location = /40x.html {
  44. }
  45. # redirect server error pages to the static page /50x.html
  46. #
  47. error_page 500 502 503 504 /50x.html;
  48. location = /50x.html {
  49. }
  50. location ~ \.php$ {
  51. root /usr/share/nginx/html;
  52. fastcgi_pass 127.0.0.1:9000;
  53. fastcgi_index index.php;
  54. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  55. include fastcgi_params;
  56. }
  57. location ~ /\.ht {
  58. deny all;
  59. }
  60. }
  61. }

总结

以上所述是小编给大家介绍的ThinkPHP 在阿里云上的nginx.config配置实例详解,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

人气教程排行