当前位置: 首页 > news >正文

搭建LNMP中遇到PHP只能下载无法打开的处理

  搭建LNMP中nginx能正常访问,但PHP文件只能下载无法打开的问题处理方法

首先,我们先了解下安装nginx后的目录:

|--nginx

|-conf.d  

   |-default.conf
           

|-fastcgi_params.default 

|-nginx.conf          

|-uwsgi_params.default

|-default.d                

|-koi-utf                

|-nginx.conf.default  

|-win-utf

|-fastcgi.conf         

|-koi-win                

|-scgi_params

|-fastcgi.conf.default 

|-mime.types             

|-scgi_params.default

|-fastcgi_params       

|-mime.types.default     

|-uwsgi_params

很多帖子都说这种问题要修改nignx/conf.d/default.conf里面的配置,且修改如下:

server {

  listen       80;
  root   /usr/share/nginx/html;
  server_name  localhost;
  #charset koi8-r;
  #access_log  /var/log/nginx/log/host.access.log  main;
  location / {
      index  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   /usr/share/nginx/html;
  }
  # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  #
  #location ~ \.php$ {
  #    proxy_pass   http://127.0.0.1;
  #}
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index   index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
  }
  # deny access to .htaccess files, if Apache's document root
  # concurs with nginx's one
  #
  #location ~ /\.ht {
  #    deny  all;
  #}

}

 

 

但还是不行,结果我就改为在nginx/nginx.conf下面修改、添加上面的代码
location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
 
 
    root   /usr/share/nginx/html;//你的php文件路径
 
 
    fastcgi_index index.php; 

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}
结果就能运行了。总结起来就是conf文件的作用域不同。

转载于:https://www.cnblogs.com/zhangcxin/p/5433127.html

相关文章:

  • 为什么要用深度学习来做个性化推荐 CTR 预估
  • Win2008R2修改远程桌面端口
  • DateUtils时间的封装
  • 数学口袋精灵bug的发现及单元测试
  • 用fail2ban阻止ssh暴力破解root密码
  • Centos 下面升级系统内核(转)
  • 两个二进制数求和
  • magento 货币换算
  • iOS -- tableView顶部留白
  • C链表的简单案例
  • Java与面向对象设计
  • TCP与UDP的区别
  • Mysql Order By 字符串排序,mysql 字符串order by
  • Java7,AutoClosable
  • Java循环练习:婚礼上的谎言
  • JavaScript创建对象的四种方式
  • JavaScript函数式编程(一)
  • JavaScript设计模式系列一:工厂模式
  • k个最大的数及变种小结
  • magento2项目上线注意事项
  • NLPIR语义挖掘平台推动行业大数据应用服务
  • quasar-framework cnodejs社区
  • 给Prometheus造假数据的方法
  • 构造函数(constructor)与原型链(prototype)关系
  • 汉诺塔算法
  • 前嗅ForeSpider中数据浏览界面介绍
  • 使用Envoy 作Sidecar Proxy的微服务模式-4.Prometheus的指标收集
  • 微服务核心架构梳理
  • (17)Hive ——MR任务的map与reduce个数由什么决定?
  • (8)STL算法之替换
  • (C++17) optional的使用
  • (办公)springboot配置aop处理请求.
  • (十)c52学习之旅-定时器实验
  • (四)搭建容器云管理平台笔记—安装ETCD(不使用证书)
  • (四)鸿鹄云架构一服务注册中心
  • (已更新)关于Visual Studio 2019安装时VS installer无法下载文件,进度条为0,显示网络有问题的解决办法
  • (转)视频码率,帧率和分辨率的联系与区别
  • .Net 垃圾回收机制原理(二)
  • .net和jar包windows服务部署
  • .NET教程 - 字符串 编码 正则表达式(String Encoding Regular Express)
  • .net开发时的诡异问题,button的onclick事件无效
  • .net通用权限框架B/S (三)--MODEL层(2)
  • @31省区市高考时间表来了,祝考试成功
  • []Telit UC864E 拨号上网
  • [17]JAVAEE-HTTP协议
  • [20180312]进程管理其中的SQL Server进程占用内存远远大于SQL server内部统计出来的内存...
  • [acwing周赛复盘] 第 69 场周赛20220917
  • [C#]winform制作圆形进度条好用的圆环圆形进度条控件和使用方法
  • [C++]AVL树怎么转
  • [DAU-FI Net开源 | Dual Attention UNet+特征融合+Sobel和Canny等算子解决语义分割痛点]
  • [HackMyVM]靶场 Wild
  • [Java]快速入门二叉树,手撕相关面试题
  • [JavaScript]_[初级]_[关于forof或者for...of循环语句的用法]
  • [Linux打怪升级之路]-信号的保存和递达
  • [office] excel中weekday函数的使用方法 #学习方法#微信#媒体