开发者社区> 问答> 正文

CentOS6.532位nginx.php如何显示javascript

采用CentOS 6.5 32位的LINUX系统,nignx+php.其它php文件都正常。  

<script language="JavaScript" type="text/javascript" src="a.php"></script>
用a.php输出JS不行,直接访问a.php会自动下载PHP文件。直接下载的就是源代码。晕。  

这是我的nignx配置,请帮助。  

server {  
        listen       80;  
        server_name  xxx .com www.  xxx.com;  
    index index.html index.htm index.php;  
    root /alidata/www/xxx/;  

location ~ ^/xxx(.*)$ {  
      alias /alidata/www/xxx/$1;      
    }  
    location ~ .*\.(php|php5)?$  
    {  
        #fastcgi_pass  unix:/tmp/php-cgi.sock;  
        fastcgi_pass  127.0.0.1:9000;  
        fastcgi_index index.php;  
        include fastcgi.conf;      
    }  
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$  
    {  
        expires 30d;  
    }  
    location ~ .*\.(js|css)?$  
    {  
        expires 1h;  
    }  

}

展开
收起
sxzlkc 2015-04-23 21:36:52 8383 0
2 条回答
写回答
取消 提交回答
  • Re阿里linux下php如何显示javascript
    采用CentOS 6.5 32位的LINUX系统,nignx+php.其它php文件都正常。

    <script language="JavaScript" type="text/javascript" src="a.php"></script>
    用a.php输出JS不行,直接访问a.php会自动下载PHP文件。直接下载的就是源代码。晕。

    这是我的nignx配置,请帮助。

    server {
            listen       80;
            server_name  xxx .com www.  xxx.com;
        index index.html index.htm index.php;
        root /alidata/www/xxx/;

    location ~ ^/xxx(.*)$ {
          alias /alidata/www/xxx/$1;    
        }
        location ~ .*\.(php|php5)?$
        {
            #fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;      
        }
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires 30d;
        }
        location ~ .*\.(js|css)?$
        {
            expires 1h;
        }

    }

    -------------------------

    ReCentOS6.532位nginxphp如何显示javascript
    这是a.php 的内容

    document.write("<form name=login method=post action=\"g.php\">    <input type=hidden name=enews value=login>    <input type=hidden name=cmsfrom value=9>  <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">  <tr>    <td>  用户名:<input name=\"username\" type=\"text\"  size=\"15\" />    <td><input type=\"image\" class=\"inputSub\" src=\"kin/images/sub.jpg\" /></td>  </tr>  <tr>    <td> 密 码:<input name=\"password\" type=\"password\"  size=\"15\" /></td>    <td><a  href=\"javascript:;\" onclick=\"window.open(\'\');\">注册新用户</a></td>  </tr></table></form>");

    -------------------------

    ReCentOS6.532位nginx.php如何显示javascript
    没有人知道吗??? 高手在呢?
    2015-04-23 21:56:42
    赞同 展开评论 打赏
  • 旺旺:nectar2。
    楼主您好,

    您的意思是,访问您的站点,所有php文件都是下载的提示吗?

    如果是在Debian系统里配置nginx + php,一般是用 fastcgi_pass  unix:/tmp/php-cgi.sock 喔。您确认您的fastcgi工作在9000端口吗?

    祝您尽早解决问题。

    -------------------------

    回 3楼(sxzlkc) 的帖子
    楼主您好,

    能否提供源文件?让坛友们为您测试一下喔。
    2015-04-23 21:52:59
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里云栖开发者沙龙PHP技术专场-聊聊服务稳定性保障这些事-信海龙 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载