douxuanou2787 2012-12-25 00:44
浏览 82
已采纳

Apache2 mod_ruid2和Document ChRoot - 无法连接到MySQL数据库

In Apache2 virtualhost, I've got mod_ruid2 working as I want using RMode stat. I added RDocumentChRoot to chroot the process to the website folder and an unwanted side-effect is that PHP can't connect to the MySQL database. I googled for help and couldn't find anything.

Can anyone throw me some rope?

  • 写回答

2条回答 默认 最新

  • dqroktbn005028 2012-12-25 02:41
    关注

    Thanks to Mario for mentioning the "mysql socket thingy". After some searching around, I found out MySQLD uses a file called mysqld.sock as an optional way to receive connections. Running 'locate *.sock' on your system will show you .sock files. dkim-filter also uses a .sock file. According to another website I read, socket files are FIFO files created by applications and they do nothing more than act as a redirectional pipe to allow applications to communicate with each other without having to go through other socket configuration stuff.

    In the case I asked about, a chrooted php process can't access the .sock file since its outside the chroot. Fortunately, I deduced that PHP uses the .sock file because of a connection variable. In WordPress, the default configuration uses 'localhost'. A 'localhost' specification in PHP will cause PHP to look for the .sock file instead of doing a network connection. Changing 'localhost' to '127.0.0.1' fixed the problem gracefully. No hardlinks or other workarounds were needed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘