Using IP.Board on FreeBSD, having SQL/Apache Issues

Server: FreeBSD 7.2-RELEASE
MYSQL Version: MYSQL 5.1.36
PHP Version: 5.2.10 (apache2handler)
IP.Board Version: v3.0.2
Safe Mode: OFF

For the most part previously IP.Board, forum software, has run fine without any issues. Regular web pages and .php pages seem to load fine without any issues. However they reset the server and everything was installed with default settings, as far as I know.

I'm not really an admin who deals with the back-end of things. I usually only admin the software side of things. However I do have root access and am able to modify and set things up. Currently it looks like it is a server configuration issue with something. Possibly optimization or setups for the SQL side of things. It looks like when requesting pages it queries and things are getting stuck or hanging. I either have to repair some of the tables or restart the server.

Anyone have suggestions or ideas on optizing mySQL, apache, php that I can look in trying to make things more stable?

See this thread:

Thank you. That helped quite a bit. But now I'm getting the following error:
"ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"

There isn't a mysql.sock in /tmp. However /tmp does have the following permissions:
drwxrwxrwt 6 root wheel 512 Aug 17 20:07 .

Originally it was just a default setup. There was no my.cnf file. I found a .cnf file in /usr/local/share/mysql/my-medium.cnf and used that to configure options in mysql. I moved it to /var/db/mysql and renamed it my.cnf. Restarted, everything seemed fine. I was able to log into mysql but now I can't seem to login and I'm not sure why. I did try commenting out the socket part in my.cnf but that didn't seem to help.

EDIT:

I found a couple other default .cnf files. There was my-medium.cnf (which I originally used), my-small.cnf and my-large.cnf. I ran a diff to compare to the originals. It looks like the issue is related to these two lines:

query_cache_size = 8M
thread_cache_size = 4

That was causing the problem. When I removed them. Everything seemed to work fine... well at least I could use: mysql -u root -p

What did those commands do that caused it to not work?