After upgrading to OS X Lion today, MySQL seemed to stop working. In fact, mysql was still running, however there were 2 problems:
- php not connecting to mysql server
- mysql no longer in path (terminal commands “mysql -u root -p” doesn’t work)
I found the solution for (1) at: http://birdchan.com/home/2011/07/20/osx-lion-mysql-sock-path/
Here is what it says:
- shut down your Web Sharing
- cp /etc/php.ini.default /etc/php.ini (for some reasons my old php.ini got renamed to php.ini.default…)
- modify /etc/php.ini, change /var/mysql/mysql.sock to /tmp/mysql.sock
- enable Web Sharing
Or it looks like the file that you want to reinstate is “php.ini-5.2-previous” (had all of my old settings). If you follow the 4 steps above, you will also need to set the timezone in line 998 on you newly created php.ini: “date.timezone = Europe/London”.
To add the mysql into your path just create a file called mysql in /etc/paths.d :
sudo touch /etc/paths.d/mysql
Then add “/usr/local/mysql/bin” to the file using a text editor e.g.
sudo vi /etc/paths.d/mysql
Then I had to reboot.
Dan Spencer Computing, OS X
Whilst reading a very good article from the techies at Yahoo, I found out that it would be a good idea to compress certain files on my Apache2 server to reduce the amount of data passed to the browser over the internet.
I found a pretty good article from How2forge at http://www.howtoforge.com/apache2_mod_deflate
I also modified the log output to include a timestamp to distinguish easily between different requests:
DeflateFilterNote Input input_info
DeflateFilterNote Output output_info
DeflateFilterNote Ratio ratio_info
LogFormat '"%t %r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
CustomLog /private/var/log/apache2/deflate_log deflate
The %t in the LogFormat line adds the timestamp.
Note the path to the CustomLog as I am on a Mac.
Dan Spencer Computing
The other day I wanted to find out how many lines of code I had written for a particular project. A quick web search through up a useful bit of code in the terminal.
Navigate to the directory that you wish to search and then:
find . -name "*.php" -exec wc -l '{}' \; | awk '{ sum += $1 } END { print sum }'
It will search all files in the directory and sub-directories beneath it.
Dan Spencer Computing