Posts Tagged ‘XAMPP’

Moving WP installation

January 8, 2014

If I move my WP installation I can hard code the IP address using define in wp-config.php (codex here) but since I have 4 sites using subfolders I wanted to change one line instead of going to 4 files and change 8 lines. This solution is to use a file say ip.text at htdocs then insert below snippet in all 4 wp-config.php files to read the line containing the IP address in the text file.

$file = fopen(str_replace(substr(ABSPATH,-2),"",ABSPATH)."ip.txt", "r");
$ip = fgets($file);
define('WP_HOME','http://'.$ip."/a/");
define('WP_SITEURL','http://'.$ip."/a/");

In this example /a/ is the subfolder containing a WP installation.

There are more issues than I ever anticipated. In fact WP uses absolute url for all attachments and media that went into the posts therefore if the sites are running under a different IP all links are broken.   I have tried a few plugins which claim to resolve this, none of them can do all I want to do.

To completely replace IP addresses appear in all your posts I have to do it in mysql, fire up phpmyadmin then run below

UPDATE wp_posts SET post_content = REPLACE(post_content, 'xxx.xxx.xxx.old','xxx.xxx.xxx.new')

So that’s all I have to do to move my WP Intranet running under XAMPP portable Lite to an external drive, either thumb or HDD/SSD, run setup_xampp.bat in the XAMPP root folder do the little tricks above then I could run the installation in any Windows OS.

Advertisements

Doing it differently

December 25, 2013

I have said this many times. Most people resist change so we keep on doing things the same way. For certain things, if I could, I like to do it differently every time.

I can’t escape hiccups failure so I tried to enjoy them.

About 10~12 years ago I set up at work a browser based search facility to help myself with mountain and ocean of papers. I published my experience on an ASP Programming site.   What I’ve learned is obsolete, I hardly remember anything, never mind that I enjoyed the learning process.

Then few years back I did that again that time I used XAMPP server stack and WordPress, a popular CMS, as the platform. Everything went as planned and I learned from that experience backing up the database and scheduled backup by running DOS batch files using XP’s scheduled task.   XP support ends in a few month so again I used obsolete technologies.

Recently I’m in the mood of doing this again, the 3rd time.  To do this differently I’m working on XAMPP portable lite on an external SSD drive. However my work location uses DHCP so in case my 6~7 years old DIY computer failed on me I could still run the stack on another computer running Windows OS.   I did struggle a bit if I should be running Linux or XP for this little project, at the end I chose the easier option as I want this launched ASAP.

I’ve worked out a few safety measures such that I could migrate my work easily, backup the whole thing, making it easy to restore things etc.   I’ll post codes separately later as I’m sure these will be useful to me in the future.