首页 > 网站 > Nginx > 正文

PHP网站修改默认访问文件的nginx配置代码

2024-08-30 12:06:34
字体:大 中 小
来源:转载
供稿:网友

搭建好lnmp后,有时候并不需要直接访问index.php,配置其他的默认访问文件比如index.html这时候需要配置一下nginx才能访问到你想要设置的文件

直接上代码,如下是我的配置的一份简单的nginx到php-fpm的站点,该站点默认访问目录/ecmoban/www/index.html

  1. server { 
  2. listen 80; 
  3. location / { 
  4. root /ecmoban/www; 
  5. index index.html index.php index.htm; 
  6. } 
  7. error_page 404 /404.html; 
  8. location = /404.html { 
  9. root /usr/share/nginx/html; 
  10. } 
  11. error_page 500 502 503 504 /50x.html; 
  12. location = /50x.html { 
  13. root /usr/share/nginx/html; 
  14. } 
  15. location ~ /.php$ { 
  16. root /ecmoban/www; 
  17. fastcgi_pass 127.0.0.1:9000; 
  18. fastcgi_index index.html; 
  19. fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name; 
  20. includefastcgi_params; 
  21. } 
  22. } 

以上所述是小编给大家介绍的PHP 网站修改默认访问文件的nginx配置,希望对大家有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表