php网站打开只显示部分php源代码

花如月 2011-04-18 03:00:21
我的是用nginx+php建站的,
nginx安装路径:/usr/local/webserver/nginx/
网站根目录:/data0/htdos/www/WebSite
网站代码目录:
drwxrwxrwx 15 root root 4096 Apr 14 20:21 admin
drwxrwxrwx 2 root root 4096 Apr 14 20:18 include
drwxrwxrwx 9 root root 4096 Apr 14 20:16 public
网站首页地址是:http://192.168.15.250/admin/Action/index.php
网站从根目录开始加过x权限的, 且phpinfo()测试页放在网站根目录下是可以显示的,但是打开网站首页地址却只显示部分php源码,真不知道是怎么回事了,劳烦各路大侠献计献策????

...全文
1669 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
花如月 2011-04-20
  • 打赏
  • 举报
回复
这个问题终于解掉了,跟短标签有关系,但是不是你们说的编码问题,只要确定配置好nginx和php就ok了,我的错误确实是php程序的问题,让人气愤的是,到最后才发现他们写了绝对路径的调用,所以才会导致错误,下面,我贴出我的nginx的配置文件内容:
user www www;
worker_processes 8;

error_log /usr/local/webserver/nginx/logs/error.log;
pid /usr/local/webserver/nginx/logs/nginx.pid;

worker_rlimit_nofile 65535;

events {
use epoll;
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format download '$remote_addr – $remote_user [$time_local]'
'"$request" $status $bytes_sent'
'"$http_referer" "$http_user_agent"'
'"$http_range" "$sent_http_content_range"';
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 30;
fastcgi_send_timeout 30;
fastcgi_read_timeout 30;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
access_log logs/access.log main;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;

server {
listen 80;
server_name demeter.smm.cn;
root /data0/htdos/www/WebSite/;
access_log logs/host.access.log;

location / {
index index.html index.htm index.php;
}

error_page 500 502 503 504 /50x.html;
location ~ .*\.php?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /usr/local/webserver/nginx/conf/fastcgi_params;
}

location ~ /\.ht {
deny all;
}
}

ihefe 2011-04-19
  • 打赏
  • 举报
回复
短标签,和编码问题。 用编辑器或者其他工具转换1下文件编码

编码错误导致你注释错位等。。
lazyboy_wu 2011-04-19
  • 打赏
  • 举报
回复
1、文件编码问题例如gbk文件编码包含有utf8的内容
2、注释中有 /// ?> 或者 /* ?> */ ,和1的乱码内容构成解析错误!
花如月 2011-04-19
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 lea200304 的回复:]

明显是程序本身问题!
[/Quote]

为什么这么说呢?
忧伤的蜗牛 2011-04-19
  • 打赏
  • 举报
回复
明显是程序本身问题!
花如月 2011-04-19
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 woliujinyuan 的回复:]

php.ini的short_open_tag = On了么?
[/Quote]
之前没有开,你说了之后我开了一下,然后重启,发现还是那个样子
花如月 2011-04-19
  • 打赏
  • 举报
回复
如果解析不了,难道不应该是乱码吗?怎么会显示部分源码呢?
花如月 2011-04-19
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 ihefe 的回复:]

短标签,和编码问题。 用编辑器或者其他工具转换1下文件编码

编码错误导致你注释错位等。。
[/Quote]

如果全部改用gbk编码就没问题了吗?
woliujinyuan 2011-04-18
  • 打赏
  • 举报
回复
php.ini的short_open_tag = On了么?
花如月 2011-04-18
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 woliujinyuan 的回复:]

很明显程序有问题了。把程序贴出来吧
[/Quote]

下面是程序:
<?
/*================================
×÷Õߣºlc
½¨Á¢ÈÕÆÚ£º2011/1/7
Ö÷Òª¹¦ÄÜ: ÏÔʾÊ×Ò³,¶¨ÒåÈ«¾Ö·¾¶
================================
*/
//http://smmsrv1:20000/YSCMS/default.htm
require_once "../include/global.php";
nullAction(); //µ÷ÓÃδµÇ¼·½·¨
$xtpl = new XTemplate("../templates/index.tpl");


@session_start();
$type=$_SESSION['user_type'];


$xtpl->assign("linkAdmin",$link_admin);
$xtpl->assign("linkimages",$link_images);
@$xtpl->assign("siteName",$sitename);
$xtpl->assign("siteImage",$site_image);
$xtpl->assign("adsImage",$ads_image);
$xtpl->assign("subTitle","网站");

//²âÊÔÄÚÈÝ

if($type==1 || $type==2){
//$xtpl->parse("main.left.qxnone");
$xtpl->parse("main.index");
}else{
$xtpl->parse("main.index");
}
require "../include/footer.php";
$xtpl->parse('main');
$xtpl->out('main'); //modified by qq 2010/12/31
?>
woliujinyuan 2011-04-18
  • 打赏
  • 举报
回复
很明显程序有问题了。把程序贴出来吧
花如月 2011-04-18
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 jordan102 的回复:]

楼主要干嘛。。网页能运行不就行了。你那个是单一入口吧。。其实很多源码在其他文件,只是被包含进来了!
[/Quote]

这个我知道的,我打开的是http://192.168.15.250/admin/Action/index.php页面,说的就是这个页面里的源码了,其他页面的都没有包含
花如月 2011-04-18
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 woliujinyuan 的回复:]

只显示部分php源码是什么意思?
[/Quote]
就是我上一条里面讲的 打开这个页面 http://192.168.15.250/admin/Action/index.php 应该显示的是首页才是,结果在网页里面只显示了php的源码,但是又不是那个页面全部的源码:没办法截图,我就复制给你好了,就是下面的:
assign("linkAdmin",$link_admin); $xtpl->assign("linkimages",$link_images); @$xtpl->assign("siteName",$sitename); $xtpl->assign("siteImage",$site_image); $xtpl->assign("adsImage",$ads_image); $xtpl->assign("subTitle","网站"); //测试内容 if($type==1 || $type==2){ //$xtpl->parse("main.left.qxnone"); $xtpl->parse("main.index"); }else{ $xtpl->parse("main.index"); } require "../include/footer.php"; $xtpl->parse('main'); $xtpl->out('main'); //modified by buoren 2010/12/31 ?>

只有这些,所以我很郁闷,之前他们搭建的http+php首页都是可以显示的,我不知道我搭建的是哪里出了问题
一起混吧 2011-04-18
  • 打赏
  • 举报
回复
楼主要干嘛。。网页能运行不就行了。你那个是单一入口吧。。其实很多源码在其他文件,只是被包含进来了!
woliujinyuan 2011-04-18
  • 打赏
  • 举报
回复
只显示部分php源码是什么意思?

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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