AWG Blogs

Sunday, November 15, 2009

Tips for when Setting up WordPress

Platform: Ubuntu 9.04/Apache 2

To set up WordPress as a virtual directory under a VirtualHost, add an alias to the host file in /etc/apache2/sites-available:

e.g.:
<VirtualHost 172.16.134.5:80>

Alias /blog/ "/usr/share/wordpress/"

ServerAdmin webmaster@localhost
DocumentRoot /home/wordpress/public_html
DirectoryIndex index.php

<Directory "/usr/share/wordpress/">

Options Indexes FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

</Directory>

...

</VirtualHost>
The guide I used was https://help.ubuntu.com/community/WordPress.

Note: where you run the command "sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost" you MUST change localhost to the IP or DNS name if you are setting up the site on a remote server. The reason, as I found out the hard way (I use "localhost" at first) is that the script creates a file under /etc/wordpress called config-<hostname>.php. Then when you go to run the web installation routine, the application can't find the config file, unless you set <hostname> in the above command to match exactly the domain used in the URL. This is because the config file is constructed in /etc/wordpress/wp-config.php using $_SERVER['HTTP_HOST'].

Sunday, November 1, 2009

Dell Memory Errors with BIOS USB Support

My 2550 Dell Server was displaying memory errors. It would split the amount of memory available and errors would be produced in the Windows Memory Diagnostic utility starting with the MATS+ test. It also mentioned something about an invalid NVRAM configuration in the startup messages. Dell Diagnostic utility was not helpful. I started disabling all options in the Integrated devices section of the BIOS. I found that by disabling BIOS USB support, the memory errors went away. Go figure!

Saturday, October 17, 2009

Change Directory with String Replacement

Found out through experimentation how to change directories in the bash shell using sed string replacement. I need a quick way to switch from production to staging sites which have the same path but for the user home directory.

First I tried:

echo `pwd` | echo `sed -e 's/production/staging/' ` | cd


That didn't work.

Then I tried:

cd $(echo `pwd` | echo `sed -e 's/production/staging/' ` )


That worked. Go figure...

Sunday, October 4, 2009

Add Hyperlink using jQuery

You can test this out in Firebug. Say you have a td element, <td id="foo" />,
you can add a link to this using jQuery:
jQuery("<a />").attr("href", "http://yahoo.com").appendTo("#foo").text("link to yahoo").after("<br />");

Monday, September 28, 2009

WSS 2.0 to WSS 3.0 Migration

I had a WSS 2.0 site (no custom parts) that I needed to upgrade AND migrate to another server. So I pretty much followed the advice on http://geekswithblogs.net/redwards/archive/2007/10/26/116365.aspx .

The above article is unclear about how the DB was transferred however, so had to wing it. Basically what I ended up doing was copying the .mdf and .ldf files of the WSS 2.0 content DB over to the Data folder of a SQL Express 2005 server --NOT the WSS 3.0 embedded DB (I tried that, but it gave me errors when I ran stsadm).

Note, after the DB was added and all set up in the Central Administration, I had to change the site collection administrator. The migrated site still had the OldServer\Administrator as the Primary site collection administrator. Other than that pretty seamless...

Sunday, September 20, 2009

Getting memcached to Run at Startup on Ubuntu

For some reason memcached would start and then die shortly after on reboot. This is on an Ubuntu 8.04 with updated packages for Apache2, PHP5, and memcached installed through apt-get.

The only way I could fix the problem was to remove memcached from the rc scripts:

update-rc.d -f memcached remove


Then add the following line to /etc/rc.local:

/usr/bin/memcached -d -p 11211 -u nobody -l 127.0.0.1 -m 64


I'm sure this will have to be adjusted if I ever need more memcached processes or if I need the PID file. Speaking of which, I suspect that the canned scripts that came with this memcached 3.0.1 from Ubuntu are too convoluted with regard to the PIDs, which already have problems of their own.

This bug report set me in the right direction.

Monday, August 24, 2009

Eclipse Simpletest plug-in Path errors

I struggled with this one until through experimentation I found out the problem. I have the Simpletest plug-in 0.2.5 for Eclipse.

I had

require_once dirname(__FILE__) . '\MyClass.php';
class test extends UnitTestCase {
function test_pass(){
$tc = new MyClass();
$boolean = $tc->my_method() == "hello";
$this->assertFalse($boolean);
}
}

But when running, I kept getting:

PHP Fatal error: Class 'MyClass' not found in ...test.php...[line number]

I finally found out through trial and error that to fix this fatal error I simply needed to replace the opening short tag with the full php tag <?php . That means I'm going to need to do this to all my class files. Might as well make that a best practice from now on.