Webtatic.com

Just another technical blog

Installing PHP 5.2.6 on CentOS 5

Posted 17th May 2009 by Andy | 10 Comments

Update 20th June 2009 – I found a bug in PHP 5.2.6, so I have compiled 5.2.10 rpms and provided a repository from which to install them, check out the article here.
Update 19th May 2009 – I have written an article here detailing how to build RPMs and install some additional php extensions, which although part of the PHP source distribution, is not included in this installation (extensions mcrypt, mhash, tidy, mssql)

Update 13th June 2009 – I’ve made the guide easier by using yum options to install the testing RPMs rather than using yum-priorities.

Redhat-based distributions tend to supply out of date releases of software. This isn’t technically a bad thing. They extensively test their updates before releasing out to the public, and upstream security fixes from the latest versions, meaning that they can be extremely stable when compared to some other distributions such as Debian-based Ubuntu.

However, this means that you rarely get new features added, until there is a new major release. Again this isn’t all bad, as new features add new bugs, which affect stability.

PHP 5.1.6, which is part of the base CentOS repository, was released 24-Aug-2006, almost 3 years ago. Since then, PHP 5.2 has been released, gone through 9 release builds since, and is considered stable for production environments.
Continue reading Installing PHP 5.2.6 on CentOS 5 »

Posted in category: Server Admin, Software, Web Development | Tags: , ,

Generating a random PHP identifier

Posted 2nd May 2009 by Andy | 5 Comments

Update 1st June 2009 – Added a note mentioning about case-insensitive comparisons in MySQL.

I’ve been looking at generating random identifiers in PHP, and making sure they are random enough. Looking at the PHP function uniqid(), and its suggested better token, I don’t think this is an adiquate enough way:

$better_token = md5(uniqid(mt_rand(), true));

Continue reading Generating a random PHP identifier »

Posted in category: Web Development | Tags:

Laptop DNS forwarding to DHCP DNS

Posted 8th March 2009 by Andy | No Comments

I run bind9, a DNS server, on my Ubuntu laptop so that I can use more advanced local dns resolution than what /etc/hosts can provide, such as wildcard domain names.

The problem is that in order for me to be able to use that DNS server whilst being able to resolve internet domains at the same time used to require me to do two things:

  • Edit /etc/resolv.conf, and change nameserver to 127.0.0.1
  • Edit /etc/bind/named.conf.options, and add a forwarder to the nameserver IP that was previously in /etc/resolv.conf

Obviously this is too annoying to have to do every time the dhcp renews, wiping my /etc/resolv.conf changes. Also, if I am frequently changing networks, as I do on my laptop. I have to go and update the bind forwarders again.

In came the solution I wrote in Ubuntu 8.04 (Hardy), using the dhcp-script hook directory in /etc/dhcp3/dhclient-exit-hooks.d/, which scripts inside get called when dhcp renews, after the /etc/resolv.conf, I was able to write a script that did the above automatically.

Continue reading Laptop DNS forwarding to DHCP DNS »

Posted in category: Server Admin, Software | Tags: , ,

Workaround so NetworkManager runs dhclient hooks

Posted by Andy | 8 Comments

When I upgraded from Ubuntu 8.04 (Hardy) to Ubuntu 8.10 (Intrepid), a dhclient-exit-hook script I wrote no longer functioned.

dhclient-script was previously used by dhclient so that whenever the dhcp changed, it would reconfigure the interfaces, generate the /etc/resolv.conf, and run scripts who’s intention is to modify the /etc/resolv.conf file based on the dhcp settings. These scripts are located in the folders /etc/dhcp3/dhclient-enter-hooks.d/ and /etc/dhcp3/dhclient-exit-hooks.d/.

Reading up on the problem, thanks to perlhead on the Ubuntu Forums, it appears that since NetworkManager did the same function as dhclient-script, which got in the way of NetworkManager’s plugins, so dhclient-script was disabled.

Sadly NetworkManager fails to call any hooks on dhcp renew, which is what my script needed. It only calls its hooks, which are located in /etc/NetworkManager/dispatcher.d/, when the interface is brought up or down.

I’ve made a modified dhclient-script, which when set as the dhclient script, will call the enter hooks, then call NetworkManager’s dhclient script, then call the exit hooks. This effectively gives the intended effect of allowing NetworkManager to run with the old dhcp hooks available.

To use it, modify your /etc/dhcp3/dhclient.conf and add/modify the line:

script /sbin/dhclient-script-networkmanager

And save this file /sbin/dhclient-script-networkmanager

Make sure its executable:

chmod +x /sbin/dhclient-script-networkmanager

Apparmor is included in Ubuntu 9.04, which will block execution of this script, what you can do is update the apparmor dhclient profile to allow the new script location, edit “/etc/apparmor.d/sbin.dhclient3″ and replace all occurances of /sbin/dhclient-script with /sbin/dhclient-script-networkmanager, and it should now work.

Now restart NetworkManager to see if it has worked:

sudo /etc/init.d/NetworkManager restart

Wait for the network to reconnect again, if it hangs then it probably didn’t work. Check out your resolv.conf:

cat /etc/resolv.conf

Please let me know how it goes when running this script. I have only tested it on Ubuntu 8.10 and 9.04.

Posted in category: Server Admin | Tags: , ,

Which subversion branch should I follow?

Posted 7th March 2009 by Andy | No Comments

Subversion has become a popular versioning system for open-source projects. It has the capability to tag or branch the source code at a specific point in development, used to give users access to these revisions easily.

It can be used to distribute this source to the developers working on the project, the end-user and other projects which use the project. They each need to pick the correct Subversion folder to download from.

For example, you can track minor revisons to WordPress MU 2.7.* by checking out http://svn.automattic.com/wordpress-mu/branches/2.7/.

Once you’ve picked the folder, you can download it using:

svn checkout http://svn.automattic.com/wordpress-mu/branches/2.7/ /var/www/wordpress/

If it is the trunk or a branch which changes, you can update it using:

svn update /var/www/wordpress/

If you want to switch to another folder (whilst retaining any modifications you’ve made/unversioned files):

svn switch http://svn.automattic.com/wordpress-mu/branches/2.8/ /var/www/wordpress/

It is important to note not all projects follow the same guidelines, and may not even create tags or branches of the project for other people. You shouldn’t for example assume that a “branches/2.7″ branch tracks the releases in tags/2.7.* without checking.

Continue reading Which subversion branch should I follow? »

Posted in category: Code Versioning | Tags: ,

Host WordPress-MU on any domain

Posted 28th February 2009 by Andy | 21 Comments

WordPress MU (WPMU) gives you the ability to create multiple blogs on a single installation. It was written to provide the ability for a website to provide scalable user blogs. A good example of this is WordPress.com, Automattic’s hosted blog service.

What WPMU does not do is give you choice on the full domains and paths to host blogs on, so cannot directly be used to host blogs on non-blog websites, such as we wanted at Fubra Limited.

One solution is to get the Multi-Site Manager plugin. This allows you to add additional sites to your installation, but this is messy, and WPMU’s sites add an additional layer of complexity that is not needed.

An alternative I have come up with is to decouple WPMU’s sites from blogs, so you can have a single site admin controlling blogs on other domains.

Update 2009-08-31 – A new easier way of decoupling the blogs from the “sites”.

Continue reading Host WordPress-MU on any domain »