Recently in L.A.M.P. Category

Every time I upgrade my Ubuntu desktop, a new kernels comes in. Then I have a new kernel and old one will never be used.

Time by time. I have 6 or more kernels in the booting list and I don't want to see. How can I remove them.

I got the way to do this cleaning job.
1) Check my current kernel I use by command as below:

uname -r

The response tells the current version number

2.6.24-19-generic

2) Open the Synaptic package manager from the System->Administration menu.

GNOME 2.22

| | Comments (0) | TrackBacks (0)

I use Ubuntu 8.04. It is shipped with GNOME Desktop.

Gnome 2.22 now.
You may want to read its release notes.

Go to Gnome official site to find out more.

I wrote PHP Optimization to improve performance. Now I have another ten PHP optimization tips for you.
1. Single-quoted strings.
Use single quote when possible. It is faster than double quote. If it is string only, just pick single quotes.
2. The way output data.
Could you point which is the fastest way to output from below?
print "Hi my name is $a. I am $b";
echo "Hi my name is $a. I am $b";
echo "Hi my name is ".$a.". I am ".$b;
echo "Hi my name is ",$a,". I am ",$b;
The last one is actually the fastest operation.
3. Use single-quotes around array indexes.
So, $x['sales'] is alway best format and fast.
4. Don't use short open tags.
<?php is formal tag.
5. Use regular expressions only when you really need it.

When doing string operation, like replace part of string. strtr is the fastest.
str_replace is faster.
preg_replace is slow.

When coding in PHP in variety ways, some way is simple, some is not. But there must be one better way that can provide better performance.

Here is a list of 63+ best practice to optimize PHP code performances

I learn some from it.


  • echo is faster than print.

  • require_once() is expensive

  • If you need to find out the time when the script started executing, $_SERVER['REQUEST_TIME'] is preferred to time()

  • str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4

  • It's better to use select statements than multi if, else if, statements.

  • Close your database connections when you're done with them

  • $row['id'] is 7 times faster than $row[id]

  • Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time.

  • When echoing strings it's faster to separate them by comma instead of dot. Note: This only works with echo, which is a function that can take several strings as arguments.

  • Do NOT use SQL wildcard select. eg. SELECT *


Now PHP 5.2.3 is installed on Dreamhost. If you don't know how to do it, just refer to my previous post, Install customized PHP5 on Dreamhost.

Let us see how to add Zend Optimizer support on your own PHP installation.

1) Go to Zend official site. http://www.zend.com/

2) Find and download the Zend Optimizer 3.3. You may need sign an account to download it. To install it on Dreamhost, you may choose Linux x86 (32bit) (TAR.GZ) | 9.74MB | 3.3.3 package.

3) I suggest to download it through SSH.
wget http://downloads.zend.com/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz

4) Decompress it.

tar xvfz ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz

5) cd ZendOptimizer-3.3.3-linux-glibc23-i386

6) We use complied ZendOptimizer so file.

cd data/5_2_x_comp

7) There are two files.
ZendOptimizer.so is the complied file.

8) Copy this file to the PHP installation folder.

cp ZendOptimizer.so ~/jiuan4/php5/lib/php/

Now ZendOptimizer 3.3.3 installation finished.

9) To enable ZendOptimizer, you need to edit your domain's php.ini file.

cd php5/etc/php5/youdomainname

10) Edit php.ini file.

vi php.ini

Install a customized PHP5 on Dreamhost can help you to make php work better and work more. That means you can add more extension on it.

Let's go to the details of installation.
Install/Compile PHP 5
1) Copy the PHP5_installscript (see the last portion of this post) into a text editor and replace YOUR DOMAIN HERE on the 4th line with your site's domain name. For example your domain is abc.com, you need to add it same as it.
2) Copy the new contents to your clipboard.
3) Log in to your account using SSH, create a new folder as temp and cd temp.
4) Create a new file in your SSH by entering the command:

vi installscript

5) Hit i for insert mode, then right-click to paste your clipboard (the install script) contents, then hit Esc, type :wq (that's 'colon', 'w', 'q'), and press Enter to save and exit.
6) Make the file executable by entering the command:
chmod +x installscript

7) Run the script by entering the command:
./installscript

8) After it has finished you will need to edit your htaccess file appropriately. Add the following:

Options +ExecCGI
AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi

<FilesMatch "^php5?.(ini|cgi)$">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
</FilesMatch>


to a file called .htaccess and place it in the root folder of your domain you specified above (/home/YOUR USERNAME/YOUR DOMAIN HERE/.htaccess)

I have a post tell you how to install PHP 5.2.0 on Dreamhost in Chinese last December.

aMule is a replacement of eMule on Linux.

My request is to running aMule on Ubuntu server without monitor. I have to use web interface to control it.

SSH to Ubuntu server.
Runing following command to install amule-common and amule-daemon

sudo apt-get install amule-common amule-daemon

After finished installation, modify the configuration file to make it accept web control.
open /etc/default/amule-daemon
Make it run.

Open ~/.aMule/amule.conf
There is a setting for webserver.
Find AcceptExternalConnection, set it to 1.
Find ECPassword, set the password for web connection. But it is not the password itself, it is a MD5Sum value of password.

The question is how to get the MD5Sum value of password.
You can use a php page to generate a MD5Sum value by md5() function. Or use the command below.
echo -n yourpassword | md5sum | cut ' ' -f 1

After that, run amuleweb -w to make a setting file for amuleweb.

The last step is sudo /etc/init.d/amule-daemon start
aMule is running as a service.

Connect the aMuleweb through the post 4711.
So the web address is looks like http://yourserver:4711/

Joomla! is a wonderful open source CMS. But the performance of content on Search Engine Results is not good enough.

Some SEO (Search Engine Optimize) hacking should be taken to make it better on SERP.
The first one is H1 tag.

Joomla does not take H1 on it template. So the Search Engine can not find the important part of the page.

To add H1 on the page title, article title, you need to do following html hack.
Use whatever html editing tools you like, I use Dreamweaver now.
The template files are sitting here.
\website root\components\com-content\views\frontpage\tmpl\default_item.php
\website root\components\com-content\views\article\tmpl\default.php
\website root\components\com-content\views\category\tmpl\default.php
\website root\components\com-content\views\section\tmpl\default.php

Find "contentheading"
Then add <h1> </h1> around the heading tag.

Save them and upload them to site.

When you browse the page after H1 hacking, the title will looks bigger than before.
You can also use css to add H1 style for them.

I have a script file used in cron jobs.
I create and edit this file on Windows 2000. The editor is UltraEdit.
When I finished editing, I upload the file to Dreamhost by FTP.

I tried to use it through SSH command.
It failed with following error notes.

:bad interpreter: No such file or directory

I double checked the file by vi editor. It looks OK.

Do you know why? Let's go back to today's topic. Dos format and Unix format of text file.
The file I created is DOS format. The script running well on my Dreamhost when I convert it to Unix format.

dos-unix-format.gif

It is all DOS format fault.

During last two nights, I tried Ubuntu 8.04 server on my old computer.
Ubuntu 8.04 Long Term Support (LTS) Server Edition

The computer which I installed server on is used as my main desktop before. It has AMD CPU and mobo 7 years old and two old Harddisk, one 60G, one 40G. I put 3 memory modules, total 1,536M, or 1.5G.

The performance is good.

I would like to make it as my Home Server with following features.


  • File server for desktops and/or laptop in future.

  • Printer server, attached by Samsung printer.

  • Media server, with capacity for MP3, Video files.

  • Web Server for testing purpose.

The installation is very simply, no more words to say.

I have two news, one good, one bad.
The bad news is Dreamhost has no PEAR default.
The good news is we can install it by ourselves.

Let us go through the steps of install PEAR on Dreamhost.
1) SSH to Dreamhost.

2) Enter the command

pear config-create $HOME .pearrc

3) Enter the install command

pear install -o PEAR

Now you can enter pear help to see the information of PEAR you just installed.

The PEAR environment is installed.

I saw the official site said, new Ubuntu will release in 6 days. I am already waiting for months.

Can we upgrade it now?
DaNmarner said it is time to upgrade now.

Back up all your important files.
Make sure you have at least 1GB space on the Ubuntu partition.
Install update-manager in a terminal if you don't have it:

sudo aptitude install update-manager

Stay in the terminal:

update-manager -c -d

There's no need to use sudo here.
Update Manager will tell you that Ubuntu 8.04 is available now!
Don't hesitate to click the button "update"!
Next, you will see a release candidate for "Hardy Heron", feel free to neglect it (or read it, if you can wait), click the button "Upgrade".
There's not much left to do but wait in the next couple of hours. Except that you need to click "Yes" when the manager ask you about changing source.list.
When it almost comes to the end, a window asking if you want to delete the old packages, let's call it "Remove".
Well, you need to restart your machine before start exploring Hardy Heron.

Earn $$ with WidgetBucks!
Earn $$ with Bidvertiser!
DreamHost!
Sponsored Review!

Online Tools

About this Archive

This page is a archive of recent entries in the L.A.M.P. category.

jQuery is the previous category.

Money Maker is the next category.