Linux ThinkPHP No such file or directory FILE: /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/meimeieee/article/details/71440174

由于公司服务器从Windows服务器换成Linux服务器,在迁移项目的时候,其中一个是thinkphp 3.2.2 写的项目,之前在Windows服务下面运行好好的怎么就一直报如下错误:

No such file or directory
错误位置
FILE: /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php  LINE: 55
TRACE
#0 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php(55): E('No such file or...')
#1 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db.class.php(166): Think\Db\Driver\Mysql->connect()
#2 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php(92): Think\Db->initConnect(false)
#3 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php(211): Think\Db\Driver\Mysql->query('SHOW COLUMNS FR...')
#4 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Model.class.php(130): Think\Db\Driver\Mysql->getFields('st_sys_configs')
#5 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Model.class.php(118): Think\Model->flush()
#6 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Model.class.php(1298): Think\Model->_checkTableInfo()
#7 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Model.class.php(95): Think\Model->db(0, '', true)
#8 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Common/functions.php(521): Think\Model->__construct('System')
#9 /phpstudy/www/shop.icloudinn.com/Apps/Home/Action/BaseAction.class.php(16): D('Home/System')
#10 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Common/functions.php(613): Home\Action\BaseAction->__construct()
#11 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/App.class.php(80): controller('Index', '')
#12 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/App.class.php(193): Think\App::exec()
#13 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Think.class.php(120): Think\App::run()
#14 /phpstudy/www/shop.icloudinn.com/ThinkPHP/ThinkPHP.php(96): Think\Think::start()
#15 /phpstudy/www/shop.icloudinn.com/index.php(28): require('/phpstudy/www/s...')
#16 {main}

百度了半天没有找到一个可靠的答案,各种乱七八糟的的方案 ,全是坑。我怀疑,是不是Linux对大小写敏感的问题,各种折腾,查看thinkphp官网文档,各种折腾没成功。放弃了治疗,暂时放我私人Windows服务上面。后面闲下来了,想起了这个坑,这个坑一定要解决才行,又开始问度娘了,哪怕有丁点,也不放过。于是找到了

https://zhidao.baidu.com/question/1304382241665341579.html

这篇文章就有人说了:

出现过类似的情况 要么就是socket目录没有写的权限 通常linux默认是/tmp/mysql.sock
还有一种情况是/tmp目录已满 需要清理磁盘空间

于是去看了这个目录下mysql.sock ,发现根本没这个文件,于是我自己新建了一个这个文件,为了防止权限干扰,并给了777权限,后来发现不给足权限也可以。再次刷新网站,这次的错误提示变了,一下心情好了很多。


但是还是报如下错:

Permission denied
错误位置
FILE: /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php  LINE: 55
TRACE
#0 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php(55): E('Permission deni...')
#1 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db.class.php(166): Think\Db\Driver\Mysql->connect()
#2 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php(92): Think\Db->initConnect(false)
#3 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php(211): Think\Db\Driver\Mysql->query('SHOW COLUMNS FR...')
#4 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Model.class.php(130): Think\Db\Driver\Mysql->getFields('st_sys_configs')
#5 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Model.class.php(118): Think\Model->flush()
#6 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Model.class.php(1298): Think\Model->_checkTableInfo()
#7 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Model.class.php(95): Think\Model->db(0, '', true)
#8 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Common/functions.php(521): Think\Model->__construct('System')
#9 /phpstudy/www/shop.icloudinn.com/Apps/Home/Action/BaseAction.class.php(16): D('Home/System')
#10 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Common/functions.php(613): Home\Action\BaseAction->__construct()
#11 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/App.class.php(80): controller('Index', '')
#12 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/App.class.php(193): Think\App::exec()
#13 /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Think.class.php(120): Think\App::run()
#14 /phpstudy/www/shop.icloudinn.com/ThinkPHP/ThinkPHP.php(96): Think\Think::start()
#15 /phpstudy/www/shop.icloudinn.com/index.php(28): require('/phpstudy/www/s...')
#16 {main}

于是继续百度:下面这篇文章,也是七嘴八舌,没有明确答案,不过给了我启示。

http://www.thinkphp.cn/topic/45661.html

有人就说了:如果用的是虚拟主机的话,'DB_HOST' => '',这一项应该填数据库的主机地址,而不是本机地址的localhost或者127.0.0.1。

不管他说得正确与否,至少让我怀疑我的配置文件,于是查看我配置文件'DB_HOST' => 'localhost‘,我想是不是Linux不支持localhost,我改成127.0.0.1上传服务器,刷新网页,久违的界面出来了,心情大好,世界也和平了,感觉从黑暗走向了光明。

不过,后来我想我是不是走了绕路了,我就把/tmp/mysql.sock 删了,刷新网页正常,心里有一头草泥马蹦过..... 但我还是怀疑没有走绕路,于是我把原来的配置文件上传了,刷新网页,又出现了第一个报错:

No such file or directory
错误位置
FILE: /phpstudy/www/shop.icloudinn.com/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php  LINE: 55

接着上传修改后的配置文件,刷新网页,正常,再次刷新,正常,再次刷新,正常.....

这下心里有万头草泥马奔过,什么鬼,这么简单,让我绕了大半圈,能不能靠谱点。

无语,无语,也许我是第一个吃螃蟹的人。


综上:只需要改配置文件DB_HOST' => 'localhost‘为DB_HOST' => '127.0.0.1‘,因为你的Linux不支持localhost



阅读更多

扫码向博主提问

狂野小青年

博客专家

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • PHP
  • Android
  • Linux
  • web前端
  • 产品
去开通我的Chat快问
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页