真是有点儿无语
时间:2011-05-10
来源:互联网
             废话少说,还是“无法加载模块Index”的问题
环境:Ubuntu Server 11.04
nginx(0.8.54)配置:
server {
listen 80;
server_name test.xxx.com;
access_log /var/log/nginx/test.access.log;
error_log /var/log/nginx/test.error.log;
   
root /home/xxx/www/test;
index index.html index.php;
   
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
   
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
Conf/config.php:
<?php
return array(
'APP_DEBUG' => true,
'DB_TYPE'=> 'mysql',
'DB_HOST'=> 'localhost',
'DB_NAME'=> 'test',
'DB_USER'=> 'root',
'DB_PWD'=> '123456',
'DB_PORT'=> '3306',
'DB_PREFIX'=> 'test_',
'APP_GROUP_LIST' => 'Home,Admin',
'DEFAULT_GROUP' => 'Home',
'URL_MODEL' => 1,
'URL_ROUTER_ON' => true,
'URL_CASE_INSENSITIVE' => false,
);
?>
已经在/Lib/Action/Home/Index下创建IndexAction.class.php文件,并将/etc/php5/cgi/php.ini中的cgi.fix_pathinfo=0修改为cgi.fix_pathinfo=1
可是为什么打开http://localhost还是显示“无法加载模块Index”,而且打开http://localhost/index.php/Home/Index/index直接就是404 Not Found?
而如果在/Lib/Action下创建一个空的IndexAction.class.php文件(没有index方法),却可以直接访问到/Tpl/default/Home/Index/下的index.html文件,但是访问其他URL仍然是404 Not Found。
不知道是我配置的问题,还是ThinkPHP的问题?求解释
            环境:Ubuntu Server 11.04
nginx(0.8.54)配置:
server {
listen 80;
server_name test.xxx.com;
access_log /var/log/nginx/test.access.log;
error_log /var/log/nginx/test.error.log;
root /home/xxx/www/test;
index index.html index.php;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
Conf/config.php:
<?php
return array(
'APP_DEBUG' => true,
'DB_TYPE'=> 'mysql',
'DB_HOST'=> 'localhost',
'DB_NAME'=> 'test',
'DB_USER'=> 'root',
'DB_PWD'=> '123456',
'DB_PORT'=> '3306',
'DB_PREFIX'=> 'test_',
'APP_GROUP_LIST' => 'Home,Admin',
'DEFAULT_GROUP' => 'Home',
'URL_MODEL' => 1,
'URL_ROUTER_ON' => true,
'URL_CASE_INSENSITIVE' => false,
);
?>
已经在/Lib/Action/Home/Index下创建IndexAction.class.php文件,并将/etc/php5/cgi/php.ini中的cgi.fix_pathinfo=0修改为cgi.fix_pathinfo=1
可是为什么打开http://localhost还是显示“无法加载模块Index”,而且打开http://localhost/index.php/Home/Index/index直接就是404 Not Found?
而如果在/Lib/Action下创建一个空的IndexAction.class.php文件(没有index方法),却可以直接访问到/Tpl/default/Home/Index/下的index.html文件,但是访问其他URL仍然是404 Not Found。
不知道是我配置的问题,还是ThinkPHP的问题?求解释
作者: uuwtf 发布时间: 2011-05-10
             把你的地址 http://localhost/index.php/Home/Index/index 换成 http://localhost/Home/Index/index 试一试, 这样的话 应该和http://localhost是一样效果, 显示无法加载Index模块, 因为你IndexAction.class.php 是空的, 写一点简单的代码吧。
  
    复制代码
这是你 nginx配置的问题。  nginx是不支持pathinfo的。
   
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
改为
   
location ~ .*\.(php|php5) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
试一试。 这样能开启pathinfo, 但是很不安全。 你到网上搜索一下"nginx 畸形解析" 就知道了。
估计你也不明白
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
这段 指令的意思, 你有这段指令不用配置pathinfo的。
            - <?php
 
- class IndexAction extends Action{
 
- function index(){
 
- echo "index";
 
- }
 
- }
 
- ?>
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
改为
location ~ .*\.(php|php5) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
试一试。 这样能开启pathinfo, 但是很不安全。 你到网上搜索一下"nginx 畸形解析" 就知道了。
估计你也不明白
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
这段 指令的意思, 你有这段指令不用配置pathinfo的。
作者: luofei614 发布时间: 2011-05-10
 相关阅读 更多  
      
    热门阅读
-   office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具 office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具阅读:74 
-   如何安装mysql8.0 如何安装mysql8.0阅读:31 
-   Word快速设置标题样式步骤详解 Word快速设置标题样式步骤详解阅读:28 
-   20+道必知必会的Vue面试题(附答案解析) 20+道必知必会的Vue面试题(附答案解析)阅读:37 
-   HTML如何制作表单 HTML如何制作表单阅读:22 
-   百词斩可以改天数吗?当然可以,4个步骤轻松修改天数! 百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!阅读:31 
-   ET文件格式和XLS格式文件之间如何转化? ET文件格式和XLS格式文件之间如何转化?阅读:24 
-   react和vue的区别及优缺点是什么 react和vue的区别及优缺点是什么阅读:121 
-   支付宝人脸识别如何关闭? 支付宝人脸识别如何关闭?阅读:21 
-   腾讯微云怎么修改照片或视频备份路径? 腾讯微云怎么修改照片或视频备份路径?阅读:28 















