Transferring WordPress to new server

Just wanted to make a note here as there are plenty of tutorial on transferring wordpress to another server.

Dont’ forget to do a find and replace on the .sql file that you backed up.

Also, after the transfer, my site would just hang.  After trying to track down the error, I renamed my wp-config.php file to wp-config.php.bak.  Reloaded the site, and let wordpress create me a new one.  I did not run the install as all my information was already there.  A quick refresh and everything was working!

Advertisements

Common Linux Commands I use

unzip archive:

> unzip filename.zip

or

>tar cfv test.tar test/

to get hidden files as well

Move contents of directory A to directory B

> mv -i ./A/* ./B

Copy contents of directory A to directory B

> cp -r ./A/* ./B

Remove directory

>rmdir ./A

or

>rm -rf ./A to remove all subdirectories and file

Untar file

tar -xvf ./file.tar

if zipped also use -zxvf

Taken from: http://www.geekvenue.net/chucktips/jason/chuck/994016279/index_html

If you would like to preserve the permissions of the files you backup, use the p option with the tar command. This will save the uid, gid as well as the specific permission attributes of the files (read, write, execute etc.)

tar pzcvf tarball.tgz .

You should also use the p option with the tar extraction command:

tar pxvf tarball.tgz .

PHP include vs require_once

After 10 years of PHP programming, it has finally settled with me the difference between require_once() and include().

Now, there are other differences as recorded in the manual, but I never really cared about it, until today.

I have 4 files: index.php, config.php, functions.php, and plugins/config.php.  All of which are nested inside the other respectively using an include.

In the last config.php file, I am declaring a function…say, function what(){ }

While using include, I get the error, cannot redeclare function what as previously declared.  The interesting thing was that the two places it said that it was begin redeclared in were the same file!

Strange.  I happened to realized that during the order in which PHP includes files, was that it was redeclaring the function as it bubbled up the chain of includes.

changing to require_once() fixed the problem!