In order to run a mysqldump from one host to another over SSH you can run:
mysqldump dbname | ssh [email protected] "mysql -D dbname"
This will pipe the output of mysqldump directly to the ssh connection which is running MySQL at the other end and receiving the mysqldump from standard input.
Author: Paul Maunders
A wget replacement for OS X Leopard
If, like me, you are missing wget since you upgraded to Leopard, then should set up an alias for wget to curl -O which does exactly the same thing:
echo 'alias wget="curl -O"' >> ~/.bash_profile
Getting Apache, PHP and MySQL to work on Leopard
Enabling PHP
If you have upgraded from Tiger, you may need to complete this step to get Leopard’s version of Apache to work with UserDir (otherwise ignore this bit):
- Copy your old userdir configurations from /etc/httpd/users/ to /etc/apache2/users/
PHP is normally disabled by the default Apache configuration, so you will need to load up a text editor and then:
- Uncomment LoadModule php5_module libexec/apache2/libphp5.so in /etc/apache2/httpd.conf
Once you’ve saved this, you’ll need to restart apache. The easiest way to do this is to go to System Preferences > Sharing and to turn Web sharing off then on again.
Installing MySQL
To install MySQL, just follow these steps:
- Download the MySQL OS X disk image from a MySQL mirror
- Mount the image, and install the main package, the startup item package, and then the preferences pane
- Add the mysql bin folder to your path:
sudo echo 'export PATH=$PATH:/usr/local/mysql/bin' >> ~/.bash_profile
- If no /private/etc/php.ini exists, make a copy of php.ini.default
- Update php.ini to point at the new MySQL socket mysql.default_socket = /private/tmp/mysql.sock – do this for both mysql and mysqli.
mysql.default_socket = /private/tmp/mysql.sock mysqli.default_socket = /private/tmp/mysql.sock
Other tips if you having problems with .htaccess
Ensure the following directives are enabled (e.g. look in /etc/apache2/users/username.conf) :
Options FollowSymLinks
AllowOverride All
Generating a Certificate Signing Request
When applying for a secure certificate you will need to generate a certificate signing request (CSR). If you are renewing an existing certificate you might want to keep your existing private key, if it’s a new certificate then you will probably need to create a new private key.
If you have previously registered a secure cert and nothing has changed since then, you can even re-use the existing CSR. The most important part of a CSR is the embedded public key, which must correspond to your private key, hence why it only really needs to change if you have changed private key.
What is in a Certificate Signing Request?
A CSR can contain the following information:
- Domain name (or person’s name)
- Address details
- E-mail address
- Public Key
When you send the CSR to a CA (certificate authority), they will use the information embedded within it to create you a full certificate, which has been signed by them. Some CAs will let you change the address information before generating the certificate.
You can decode a CSR with the following command:
openssl req -in old/secure.domain.com.csr -text -noout Certificate Request: Data: Version: 0 (0x0) Subject: C=GB, ST=Hampshire, L=Aldershot, O=Fubra Ltd, CN=secure.domain.com Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (1024 bit) Modulus (1024 bit): 00:c7:2b:e8:ad:c7:2a:da:f7:0f:e5:7d:23:f5:91: 49:a5:1d:ee:df:03:33:af:b5:ad:0b:dd:3e:af:e0: 95:67:b8:39:fb:2b:0e:c4:2b:37:d7:aa:f7:79:f8: 07:23:41:87:e8:72:88:8e:4b:c5:e6:cc:51:7b:9a: 9f:87:db:52:f8:4d:73:b2:79:9a:b9:18:17:fb:f8: 22:05:6b:af:25:81:e3:89:e0:ec:be:d1:19:93:bf: 06:31:20:01:e3:3d:80:7f:1e:c3:9c:89:4f:33:f1: bd:9a:f6:58:d5:74:51:9a:43:3e:14:f8:ee:8e:8d: 7b:43:da:44:33:13:bd:0d:7f Exponent: 65537 (0x10001) Attributes: a0:00 Signature Algorithm: md5WithRSAEncryption 50:c7:69:cf:04:53:8b:de:64:dc:ba:e3:ac:3b:93:d1:94:2f: 48:3b:15:27:c7:e5:1a:65:bc:a4:bd:cb:6a:fe:12:a3:b0:14: 13:23:ff:3b:15:68:eb:48:c1:63:64:e0:de:8d:ce:34:93:8f: 41:ef:97:e5:6f:aa:1d:01:db:2e:51:d6:68:8a:d3:f8:f4:70: 87:17:a2:d1:c8:2d:79:61:22:b6:02:bd:31:50:67:e6:7e:fb: 23:49:e3:58:61:2e:6b:4b:77:1e:76:3f:d8:2f:8e:44:6e:9e: e7:e5:54:f7:a7:90:a7:3c:1e:34:4a:31:22:72:77:fe:bc:7e: 53:ce
Generating a new CSR and a new private key
To create a brand new private key and certificate signing request just run:
openssl req -new -nodes -keyout newprivate.key -out server.csr
Generating a new CSR with an existing private key
If you need to generate a certificate signing request from an existing private key, you can do so with the following command:
openssl req -new -key existingprivate.key -out server.csr
Using an existing CSR with an existing private key
You don’t need to run any new commands, just send your existing CSR to the certificate issuer.
Apple Homepage – 4th Generation iPod Nano
When sudo echo ‘test’ > /root/test gives permission denied
If you get a permission denied error when trying to redirect the output of a sudo command then the reason for this is normally because the superuser permissions only apply to the first part of the statement, e.g. the echo command. They do not carry through to the bash redirection.
paul@backups:~$ sudo echo 'test' >> /root/test -bash: /root/test: Permission denied
One way to get round this is to use the tee command, as follows:
echo 'test' | sudo tee -a /root/test
Note that the -a switch means append to the file if it already exists.
Installing Zend Framework on Ubuntu (Hardy)
As of the 8.04 Hardy release of Ubuntu, Zend Framework has been added to the repositories, so you can install it by simply running:
sudo apt-get install zend-framework
The package installs 17M of files into /usr/share/php/libzend-framework-php/.
Once that has finished, you then need to ensure that the framework is in your PHP include path. The best way to do this is to add the include to your PHP scripts directly, or better still via a global include file. The line you would need to add is:
set_include_path(get_include_path().PATH_SEPARATOR.'/usr/share/php/libzend-framework-php');
An example project would then look like:
set_include_path(get_include_path().PATH_SEPARATOR.'/usr/share/php/libzend-framework-php'); require_once 'Zend/Mail.php'; $mail = new Zend_Mail(); $mail->setBodyText('My Nice Test Text'); $mail->setBodyHtml('My Nice Test Text'); $mail->setFrom('[email protected]', 'Mr Example'); $mail->addTo('[email protected]', 'Mr Test'); $mail->setSubject('TestSubject'); $mail->send();
As Andy pointed out in a comment, Zend Framework is evolving quite rapidly, so if the Ubuntu repository version fails to meet your needs, then you could easily install and switch to a newer version for certain projects if you modify the include path this way.
Hosting multiple blogs on a single WordPress installation
As you can probably tell from this blog, WordPress is my favourite blogging tool. I’ve been using it for a couple of years now, and during that time I’ve been really impressed by it. So when I was recently asked if a single copy of WordPress could be used to power several blogs, I was optimistic that it would be up to the job.
And it didn’t disappoint me…
There are a number of ways you can host multiple blogs with WordPress:
- WordPress MU (multi-user) – This is system that powers all blogs at wordpress.com, Le Monde, Harvard Univeristy etc…
- Batch management of blogs with WP-Create and WP-Upgrade – These scripts let you install multiple blogs in parallel, however each one would get it’s own installation.
- Modifying wp-config.php to choose a different database per hostname. This uses the standard wordpress scripts.
Since I wanted to use a standard wordpress installation, and I didn’t want to install it multiple times, I chose the 3rd option. WordPress stores most of it’s configuration in it’s database, so all you need to do is modify wp-config.php to point at a different database depending on the hostname of the site being accessed:
// Ignore the www. part of a hostname $host = eregi_replace('^www\.', '', $_SERVER['HTTP_HOST']); switch ($host) { case 'site1.co.uk'; $db = 'site1'; break; case 'site2.co.uk'; $db = 'site2'; break; default: header("HTTP/1.0 404 Not Found"); exit(); break; } // ** MySQL settings ** // define('DB_NAME', $db); // The name of the database define('DB_USER', 'user'); define('DB_PASSWORD', 'password'); define('DB_HOST', 'hostname');
Simply add the existing database settings code with the code above, and then create a new empty database for each blog you want to host. You will need to run the install scripts for each blog, e.g. http://www.site1.co.uk/blog/wp-admin/install.php
References:
- Enterprise 2.0 anyone? – How to: multiple blogs, one WordPress installation
- WordPress Codex – Installing Multiple Blogs
iPhone firmware update fails
If you repeatedly get an error while upgrading your iPhone’s firmware that says something like:
the iphone could not be restored an unkown error occured 1604
Try restarting iTunes and plugging the iPhone into a different USB port. Failing that you might need to try restoring the phone on another machine before syncing your settings from the original machine.
Always look for a voucher code when shopping online
Although we’re not technically in a recession yet, we are certainly in midst of a downturn in the economy and with prices rising and wages stagnating (or even falling in real terms) I think most people are definitely feeling the pinch on their wallets.
However, everyone still needs to make some purchases, and there is one easy way you can save a few percent when shopping online; use a voucher / discount code. It surprised me that some of my friends weren’t aware of this, as I’ve been using vouchers for years to get a discount on anything from pizza to holidays.
Dominos regularly give out vouchers for 20% off online orders, and last year I managed to get 15% off a group holiday to Center Parcs. There were 18 of us, so that amounted to about £200 in savings! Hence why it’s definitely spending a few minutes searching for codes online.
A friend of mine has just launched a new site, which aims to have the largest and most up-to-date selection of voucher codes. They are investing a lot of time into checking all their codes and ensuring that they remain valid, and they publish the expiry date so you know when it must be used by.
It’s a good idea to start looking for codes in advance, as this year I missed out on getting a Center Parcs discount… there were no vouchers available when we booked.