mac

Mac OSX 10.8 PHP, mysql.sock not found

I found that after install MySQL and Apache/PHP – that the database connections didn’t work from PHP. They worked if I tried to connect using the MySQL client though. Must be a problem with the PHP side.

There is a sock file that PHP was trying to use, and it was in /var/mysql/mysql.sock complaining that the file was not there.

Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/filename.php, line number]

Sure enough, the file wasn’t there, and infact the folder was not there either. So I made a folder and created a symlink to the one that was there, in /tmp/mysql.sock

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Restarted Apache and MySQL just to make sure. And hey presto its working.

sudo apachectl restart
sudo /usr/local/mysql/support-files/mysql.server restart

Error 403 on a localhost site on Mac

I was having trouble with my VirtualHosts here. Some sites worked but some did not.

It was down to the sites that use some sort of framework, and by adding the following code into the VirtualHost section for the misbehaving site:

<Directory /path/to/site/folder>
    Options +Indexes +FollowSymLinks +ExecCGI
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

I’m guessing it was preventing the mod_rewrite to do the re-writing.

Error 403 on a localhost site on Mac

I was having trouble with my VirtualHosts here. Some sites worked but some did not.

It was down to the sites that use some sort of framework, and by adding the following code into the VirtualHost section for the misbehaving site:

<Directory /path/to/site/folder>
    Options +Indexes +FollowSymLinks +ExecCGI
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

I’m guessing it was preventing the mod_rewrite to do the re-writing.