mysql command doesn’t work in OS X snow leopard
So you install mySql on your mac, and it’s working great, but then you go into terminal to run a mysqldump or something, and it doesn’t work!
you get a message something like:
-bash: mysqldump: command not found
so how do you fix this? well, copy and paste the following into your terminal window and press enter:
echo export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" >> ~/.profile
source ~/.profile
whoa, whoa, you say. what is this doing? It makes it so that when you type any command into the terminal, it does a check of these folders before giving you the “command not found” error.
If you want to undo it, you can always edit your .profile, or just delete it.
WordPress on Snow Leopard: Unable to Connect to Database
If an “unable to connect to database” comes up while installing WordPress on a Snow Leopard machine, try adding :3306 to the end of the DB_HOST in wp-config.php
Assuming everything else works, this should solve your problem!
VirtualHostX and mod_rewrite
To enable mod_rewrite manually, see: OS X server tips but if you are using VirtualHostX it changes your default config file. Add the following code to the Directives box:
Options FollowSymLinks
AllowOverride All AuthConfig
Order deny,allow
Deny from all
if you’re using the new version of VirtualHostX, make sure that you select Directory from the dropdown, then use:
Options FollowSymLinks
AllowOverride All AuthConfig
How to do multiple virtual hosts on OS X
- Download and install VirtualHostX (don’t forget to back up your existing config!!)
- Download and install Gas Mask (manages multiple hosts files, dumb name though)
- If you want to do this with WordPress and you have a database locally and another one on a dev server somewhere, you can do the following code:
if(eregi(“^mywebsitename.com$”, $_SERVER[HTTP_HOST]))
{
define(‘DB_NAME’, ‘dbremotename’);
/** MySQL database username */
define(‘DB_USER’, ‘dbremoteuser’);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘dbremotepassword’);
/** MySQL hostname */
define(‘DB_HOST’, ‘dbremotehost’);
define(‘WP_SITEURL’, ‘http://mywebsitename.com’);
define(‘WP_HOME’, ‘http://mywebsitename.com’);
}
else{
define(‘DB_NAME’, ‘dbremotename’);
/** MySQL database username */
define(‘DB_USER’, ‘dblocaluser’);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘dblocalpassword’);
/** MySQL hostname */
define(‘DB_HOST’, ‘dblocalhost’);
define(‘WP_SITEURL’, ‘http://mywebsitename.com’);
define(‘WP_HOME’, ‘http://mywebsitename.com’);
}
HTML Special Characters
Any good web designer knows certain characters have to be encoded in HTML.
Here’s a list of pretty much every character and it’s encoding: http://webdesign.about.com/library/bl_htmlcodes.htm
Bonus: Need to use some encoded characters in your PHP script? Use html_entity_decode() to turn them into regular text.
OS X Server Tips
To enable PHP:
- nano /etc/apache2/httpd.conf
- uncomment LoadModule php5_module…
To enable mod_rewrite
- In the primary site configuration, change AllowOverride to AllowOverride All AuthConfig
- Restart apache with sudo apachectl restart
Recursive FTP
Fun thing I found today: how to copy a whole pile of files/folders over from one place to another using ftp. Especially useful on two remote computers in terminal when security isn’t a concern!
wget -r ftp://username: password@domainname
