Archived posts in ' "Linux desktop"

Back home

Doing multiple inheritance in PHP

09/26/2009

Officially PHP doesn’t support multiple inheritance. There are several ways around this, without having to duplicate code.

PHP 5.4 will support Traits. This concept is almost similar to mixins. For more information check the PHP manual.
Read the rest of this post »

10 Comments

How I PHP: How to take a website offline.

06/17/2009

I’ve seen a lot of methods used to take a website temporarily off-line for maintenance. Most involve a using PHP to disable the site or renaming the index file. There is however a far better method of doing this, by placing the following in the vhost file or in an .htaccess file in the document root:

Header always set Retry-After "Thu, 18 Jun 2009 08:00:00 +0200"
Redirect 503 /

This way you are sure no part of the site is used. Also by returning a 503 http response, search-engine crawlers will not reindex your site right at the moment it is down. You can use ‘ErrorDocument’ to place a different text than the apache default.

7 Comments

How to get a file extension

05/31/2008

How to get a file extension in PHP:

1
$ext = pathinfo($file_name, PATHINFO_EXTENSION);
$ext = pathinfo($file_name, PATHINFO_EXTENSION);

How to get a file extension in Perl:

1
my $ext = ($file_name =~ m/([^.]+)$/)[0];
my $ext = ($file_name =~ m/([^.]+)$/)[0];

How to get a file extension in Ruby:

1
ext = File.extname(file_name)
ext = File.extname(file_name)

How to get a file extension in Bash:

ext=${file_name##*.}
name=${file_name%.*}

How to get a file extension in Python (thanks to Jensen):

import os
ext = os.path.splitext(file_name)[1]

How to get a file extension in JavaScript:

1
var ext = /\.(\w+)$/.exec(file_name)[1]
var ext = /\.(\w+)$/.exec(file_name)[1]


Got more? Please post a comment.

28 Comments

Howto Install Xen+Lustre on Ubuntu Gutsy

04/21/2008

Send in by Ruben Daniels

Lustre is one of the most popular upcoming open source cluster file systems out there. When you want to run Xen’s from a SAN using Lustre you need to support both in the Linux kernel. Both XEN and Lustre are near mature products. This means there is support for it. But it’s quite difficult to find the right source and to combine it with the right kernel source of each. It took me a week of trial and erroring until I found a combination that worked. Since Google wasn’t much help I wrote this article so it might help you. This installation is Ubuntu Gutsy specific. You can start out with a basic Gutsy installation. Hardy is getting Lustre support, but at the time of this writing the package doesnt match the default kernel of Hardy.
Read the rest of this post »

5 Comments

Wrong PHP prediction: you don’t need to patch PHP to run multiple versions

09/7/2007

I read an article on Michael Kimsals blog about how he is waiting for a patch to run different PHP versions on the same Apache server. I think he is misinformed and I highly doubt than someone will write that patch. The solution is here already.

You simple can’t have PHP4 and PHP5 both run as Apache2 module in the same process, because they use a lot of the same internal symbols (variables, function names, etc). If you would change that, nobody would be able to write any extensions which run both on PHP4 and PHP5. However you can run multiple PHP versions as CGI modules and there is no patch required for that.
Read the rest of this post »

3 Comments

Migrating from PHP4 to PHP5: A strategy for hosts

09/1/2007

If you have a shared hosting company and are still running PHP4, you might feel the pressure rising. Articles like ‘Now showing: PHP’s true colors’ basically tell you to make the switch and take the hit, but they do not give any advice how to handle this.

The basic problem is that you can inform your customers that you’re migrating to PHP5, but if you can’t provide a testing platform for your customers, how are they going to know if migrating will break their sites.

A few months ago I’ve posted an article about running multiple Apache instances with different PHP versions. In that article I showed how to make multiple configurations running Apache on different IP addresses. By using different ports instead of different IP addresses, we can give our customers a way to check their site before it goes live.
Read the rest of this post »

3 Comments

Providing Joomla as shared hosting company

06/4/2007

As a shared hosting company, it is nowadays almost required to provide one-click installable web applications to your customers. Packages like Joomla, OS-Commerce and WordPress come to mind.
Providing the installation for this isn’t hard. You can simply copy a directory and redirect. The real problem lies in managing the installed applications. You nor the customer wants to have an outdated version and since you provided the installation you need to provide the upgrade.

The ideal situation would be if Joomla would be installed at a central location, which would be used by all customers. Only configuration files and additional support files would be in the configuration directory. Keeping in mind that you, or at least we, don’t want to set additional limits to our customers, support files include additional languages, modules, etc.
Read the rest of this post »

3 Comments

Running multiple instances of Apache

03/26/2007

Life as a shared hosting provider hasn’t become easier after PHP decided that they would allow compatibility breakage between mayor versions. Some providers managed to keep there customers satisfied while only supporting PHP 4, but lots of new projects are PHP 5 only and the problem will become even bigger when PHP 6 is released.

Usually a daemon (a service for you windows folks) is started once, with only one instance running. The same goes for Apache. However when we look closely at the apache config, we see that variables which prevent apache from being started twice, the pid file, lockfile and ip/port, can be configured. When starting apache, the config file can be specified, which allows to run multiple instances of apache (on different ip’s). Read the rest of this post »

13 Comments