Set Drupal on Mac

Apache & PHP config on Mac

Three ways to check the php config

  • php -i | grep php.ini
  • php –ini
  • create php file with following line: <?php phpinfo(); and open the file in the browser

PHP opcache config

/etc/php.ini

1
2
3
4
5
6
7
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/opcache.so #!!important
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

Troubleshoot

PHP连接MySQL的时候报错SQLSTATE[HY000] [2002] No such file or directory

错误环境:Mac OS 10.10

找到mysql.sock文件的位置
$sudo find / -name mysql.sock

——结果如下———-
find: /dev/fd/3: Not a directory find: /dev/fd/4: Not a directory /private/tmp/mysql.sock

检查/var/mysql是否存在
$ll /var/mysql

如果/var/mysql不存在则创建
$sudo mkdir /var/mysql

将mysql.sock文件映射到/var/mysql路径中
$sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock