lNPM 环境搭建问题

bljswpu 2015-10-20 09:46:32

已启动nginx个php-cgi
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2355/nginx
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2212/php-cgi

phpinfo.php脚本
<?php
phpinfo();
?>


nginx配置
location / {
root html;
index index.php index.html index.htm;
}

location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name;
include fastcgi_params;
}

打开localhost/ 能正常
打开localhost/phpinfo.php的时候 出来的是提示下载整个php文件 而不是php执行的结果

刚刚入手php 高高手解答 看了网上好多资料 还是没搞定
...全文
107 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
码无边 2015-10-21
  • 打赏
  • 举报
回复
fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name; /html 写绝对路径试试
黄袍披身 2015-10-21
  • 打赏
  • 举报
回复
显然还是没有能够正确的解析PHP脚本,环境有问题.我不知道你的是什么系统 如果是ubuntu 建议你使用系统自带的 nginx 和 php 不要折腾了会简单很多.
ayzen1988 2015-10-21
  • 打赏
  • 举报
回复
fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name; /html是绝对路径,估计是路径错了 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
bljswpu 2015-10-21
  • 打赏
  • 举报
回复
引用 3 楼 zy205817 的回复:
fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name; /html 写绝对路径试试
改成绝对路径还是一样的效果
bljswpu 2015-10-21
  • 打赏
  • 举报
回复
引用 1 楼 zhangbin1988 的回复:
fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name; /html是绝对路径,估计是路径错了 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; include fastcgi_params; } 还是一样的效果 我怀疑不是路径有问题 是nginx和php没关联起来

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧