在服务器上部署了一个php网站,但速度慢得让人无法忍受,一开始还以为是php的原因,后来发现是与数据库交互太慢,慢得离谱,在网上找到一个解决办法:
编辑/etc/my.cnf
在[mysqld]段中加入
skip-name-resolve
重启mysql
在/etc/my.cnf 的配置文件中加入如下一句,禁用DNS反响解析,就能大大加快MySQL连接的速度。
或者:
/usr/local/mysql/bin/mysqld_safe --skip-name-resolve
--user=mysql&
加 --skip-name-resolve 这么一个参数就可以,关闭mysql的dns反查功能。(这个没试)
Fatal error: Call to undefined
function mb_substr()
报这些错误基本上都是因为没有加载php_mbstring
刚开始按照网上说的,在php.ini文件中,把php_mbstring.dll的注释去掉,但发现这样没起作用,
解决办法是:在php编译中加入的配置文件中加入--enable-mbstring=all,如:
./configure --prefix=/usr/local/php5
--with-mysql=/usr/local/mysql
--with-apxs2=/usr/local/apache2/bin/apxs --enable-mbstring=all
--enable-mbregex --with-config-file-path=/usr/local/php5/lib
再make && make install