nginx下搭建CodeIgniter问题集锦

时间:2022-11-13 05:09:42

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';