Nginx下搭建CodeIgniter问题集锦

nginx环境下CodeIgniter会出现一些问题!

1、数据库驱动连接失败! 出现如下问题:

A PHP Error was encountered

Severity: Warning

Message: mysqli::real_connect(): (HY000/2002): No such file or directory

Filename: mysqli/mysqli_driver.php

解决方法: 这个问题是php.ini配置的问题。 默认以下配置为空,将以下三个选项设置成你mysql.sock对应的目录就可以解决了。(以下配置为mac下)mysql.default_socket = /tmp/mysql.sock pdo_mysql.default_socket= /tmp/mysql.sock mysqli.default_socket =/tmp/mysql.sock

2、出现Only variable references should be returned by reference报错

A PHP Error was encountered
Severity: Notice
Message: Only variable references should be returned by reference
Filename: core/Common.php
Line Number: 257

解决方法: 原代码: return $_config[0] =& $config;

    修改后: `$_config[0] =& $config; return $_config[0];` 
    

3、session报错

A PHP Error was encountered
Severity: Warning
Message: mkdir(): Invalid path
Filename: drivers/Session_files_driver.php
Line Number: 117

解决方法: 以ci 3.0为例: 将config配置文件中 将sess_save_path改为如下
$config['sess_save_path'] = FCPATH.'public/sess_save_path'; //CI sission 也是以文件形式存储上一行修改时定义存储路径

4、伪静态配置信息


server
{
  listen       80 ;
  server_name  www.xxx.com;
  index index.html index.htm index.php;
  root  "a:/xx";

  location / {
     rewrite ^/(?!index\.php|robots\.txt|upload|resource)(.*)$ /index.php/$1 last;
  }

  #nginx模拟pathinfo,否则CI框架的控制器无法访问
  location ~ \.php(.*)$ {
    fa  stcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_param        SCRIPT_FILENAME        $document_root$fastcgi_script_name;
    fastcgi_param        PATH_INFO                $fastcgi_path_info;
    fastcgi_param        PATH_TRANSLATED        $document_root$fastcgi_path_info;
    include        fastcgi_params;
  }
}

非特殊说明,本博所有文章均为博主原创。

备注:相关侵权、举报、投诉及建议等,请联系站长

添加新评论

昵称
邮箱
网站