Enable image caching in apache for better Google Page Speed results


High page speed and short page load times of your website are essential for good search engine rankings. To enable Image caching and http requests in apache, you need to enable the expires module on Ubunto or Debian. This module allows the apache web server to set HTTP headers. It sets the modification header for static assets like image and CSS files that do not change often.


a2enmod headers expires

Add the following directives inside the vhost file of the web site or at the end of the file /etc/apache2/apache2.conf to enable it globally.

Header set Cache-Control "max-age=3024000, public"
</FilesMatch

On ISPConfig 3 servers, this can be added in the “Apache Directives” field of the website instead. There is no apache reload required as ISPConfig takes care about that

Advertisements

Nokia N900


My Nokia N900 suddenly started losing battery charge fast. I have updated the latest beta repositories and installed as much as new (useful) applications I can. The situation became so bad, that I cannot use my phone for even few calls. I was charging my phone more rather than using it. So, I decided to do something about it.

I then flashed my phone from one of the US kernels, i downloaded before. It was successful but I was not getting any network at all and hence could not make any calls. After pulling my hair for several days and going through abundant resources from the net, I downloaded the latest US kernel and did the flashing once again. This time I was successful.

Guess, what was the problem. Never downgrade from the previous version of kernel or whatever on the N900. The same kernel worked for me before, now it didn’t because. I have updated to the latest kernel after installing it and hence applying the old kernel do not work 🙂

Customizing Gedit as Web Developer’s IDE


These tips I followed from Micah Carrick’s blog

1. get the tag for gedit
wget http://www.micahcarrick.com/files/gedit_webdev_tags-0.1.tar.gz
tar -xzf gedit_webdev_tags-0.1.tar.gz
sudo mkdir /usr/share/gedit-2/plugins/taglist
sudo cp *.tags /usr/share/gedit-2/plugins/taglist/
rm -rf *.gz *.tags

2. get current version of PHP_Beautifier and other useful stuffs

sudo apt-get install csstidy linkchecker
sudo pear install PHP_Beautifier-0.1.14

3. use external tools plugin
for beautifying PHP (add command)

php_beautifier -s4 -l “ArrayNested() IndentStyles(style=bsd) NewLines(before=if:switch:while:for:foreach:function:T_CLASS:return:break,after=T_COMMENT)”

check PHP code for parse error (add command)
php -l

PHP function look up in browser firefox (add command)
xargs -I '{}' firefox \
'http://www.php.net/search.php?lang=en&show=quickref&pattern={}'

“Not working for me in Jaunty Jackalope”

4. get ftp support
run gconf-editor add ftp to the list at
/apps/gedit-2/preferences/editor/save/writable_vfs_schemes/

“Already updated in Jaunty Jackalope”

5.get symbol browser plugin

cd ~/.gnome2/gedit/
wget http://sourceforge.net/projects/symbol-browser/files/symbol-browser-bin/gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1/gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz
tar -xzf gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz
rm -rf *.gz
sudo apt-get install libgnomeprintui2.2-0 ctags

Now enable from menu Edit->Preferences-Plugins

6. get tidy plugin
cd plugins
wget http://www.eng.tau.ac.il/~atavory/gedit-plugins/html-tidy/html-tidy-gedit-plugin.tar.gz
tar -xzf html-tidy-gedit-plugin.tar.gz
sudo apt-get install tidy

7. get PHP autocomplete
wget http://downloads.sourceforge.net/project/gedit-autocomp/gedit-autocomp/gedit-autocomplete-0.9.6/gedit-autocomplete-0.9.6.tar.gz
tar -xzf gedit-autocomplete-0.9.6.tar.gz
cd gedit-autocomplete-0.9.6
mv *.* ../.
cd ..
rm -rf gedit-autocomplete
*

8. get python plugin for posting code into snipplr.com remotely.


wget http://geditsnipplr.googlecode.com/files/snipplrpy-0.4.tar.gz
tar -xzf snipplrpy-0.4.tar.gz
cd snipplrpy-0.4/
sudo python setup.py install
cd ..
wget http://geditsnipplr.googlecode.com/files/gedit_snipplr_plugin-1.0.tar.gz
tar -xzf gedit_snipplr_plugin-1.0.tar.gz
cd plugin
mv snipplr* ../.
cd ..
rm -rf plugin

if you have not signed up already, sign up with snipplr.com and get the api key from the site.

9. cleanup
rm -rf *.gz

Continue reading “Customizing Gedit as Web Developer’s IDE”

First Step before Creating a Webapp with YII


  1. Install LAMP Server
  2. Install PHPunit
  3. % sudo pear channel-discover pear.phpunit.de
    % sudo pear install phpunit/PHPUnit

  4. Install Selenium
  5. Download Selenium Remote Control (Selenium RC) zip file from http://seleniumhq.org/download/.
    Run Server from shell

    % java -jar selenium-server.jar

  6. Running the Functional Tests
  7. Before we can run this functional test, we need to make a couple of configuration changes to our application. First we need to alter protected/tests/WebTestCase. php to properly define our test URL that Selenium will attempt to open when it runs
    the tests. Open up that file and make sure the TEST_BASE_URL definition matches the URL to your webapp

    define(‘TEST_BASE_URL’,’http://localhost/webapp/index-test.php/&#8217;);

    The file protected/tests/phpunit.xml houses some configuration settings for Selenium Server. It is configured to use IE as the primary browser. We can remove the following highlighted line of code to ensure only Firefox will be used when running Selenium:

    name=”Internet Explorer” browser=”*iexplore”

    Now, as long as you have installed PHPUnitand have ensured that Selenium Server is running, and then we can navigate to our tests folder at the command prompt and run this functional test:

    % cd protected/tests/
    % phpunit functional/SiteTest.php

    What should happen is that you will see your browser being automatically invoked, as the Selenium Server platform is using the browser to access the end-user functionality of the site that we configured in the WebTestCase.php file. As it runs through the test methods, it actually automates the behavior of a real user of the site.

  8. Configure Gedit for PHP
  9. Install Netbeans
  10. SVN update the latest YII
  11. install the webapp in the webroot
  12. Testing the DB Connection
  13. we know we add our unit tests under protected/tests/unit/. Let’s create a simple database connectivity test file under this folder called DbTest.php. Create this new file with the following contents:

    class DbTest extends CTestCase
    {
    public function testConnection()
    {
    $this->assertTrue(true);
    }
    }

    Here we have added a fairly trivial test. The assertTrue() method, which is part of phpUnit, is an assertion that will pass if the argument passed to it is true, and it will fail if it is false. So, in this case, it will pass if true is true. Of course it is, so this test will pass. We are doing this to make sure our new application is working as expected for testing. Navigate to the tests folder and execute this new test:

    % cd /WebRoot/trackstar/protected/tests
    % phpunit unit/DbTest.php

    Change the trivial assertEquals(true) statement in the testConnection() test method to:

    $this->assertNotEquals(NULL, Yii::app()->db);

    And rerun the test:

  14. Configuring YII to use MySQL
  15. To customize our application configuration, we normally provide a configuration file
    to initialize its property values when the application instance is being created. The
    main application configuration file is located in /protected/config/main.php.

How to Install Apps from GetDeb


  1. Install the getdeb package.
  2. Or configure the repository manually:
  3. Go to System-Administration-Software Sources, Third-Party Software tab, Add

deb http://archive.getdeb.net/ubuntu lucid-getdeb apps

  1. Add the repository GPG key, open a terminal window and type:

wget -q -O- http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add –

  1. Click the “Install this now” button below the screenshot of the desired application.

Installing LAMP server to Ubuntu


  1. Installation
  2. If you have not already installed LAMP software, you can read my First steps after installing Ubuntu post, for installing the necessary Server software.

  3. Configuration
  4. if apache starts, you can see the below error in terminal.
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

    To rectify run the below code from terminal
    sudo echo "ServerName localhost" | sudo tee -a /etc/apache2/apache2.conf

  5. Adding Virtual Host
  6. By default, Ubuntu place its web root at /var/www. Since, we want to have have multiple hosts for development, add virtual host. We also want, to mimic the cpanel configuration we have at the production server.
    copy the default file to your new host name. It is not mandatory to have the host name, but it is easy to remember if you follow this convention.

    sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/example

    Now edit the example file so that it reads as below.

    ServerName “http://example&#8221;

    DocumentRoot /home/yourhomedir/public_html

    Options FollowSymLinks
    AllowOverride None

    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all

  7. Enabling the availble site http://example
  8. We want to have the production server name minus the .com or .net in the local development server, we can now enable our site using the command

    sudo a2ensite example

  9. Adding host name to the hosts file
  10. Since your Server does not know how to resolve the name http://example, configures the hosts file accordingly.

    gksu gedit /etc/hosts
    add the host name example next your existing machine name.

    127.0.0.1 yourmachine example

  11. Changing the process owner of Apache2
  12. It will be very difficult for us to change the username between apache default username ‘www-data’ and ‘your username’, every time you add a new webfolder/host, so change the apache process name to your username and group.

    gksu gedit /etc/apache2/envars

    change the two lines in file envars, so that it looks like below.

    export APACHE_RUN_USER=example
    export APACHE_RUN_GROUP=example

First steps after installing Ubuntu


  1. Remove unwanted packages
  2. I do not use certain software bundled with ubuntu. I will remove those to increase space and avoid confusion. Your choice may differ.

    sudo apt-get remove evolution evolution-doc* evolution-common evolution-data-server evolution-webcal rhythmbox totem totem-common games-common* gbrainy f-spot

  3. Add your desktop packages
  4. install the packages that are mostly available in windows too and share data across with my NTFS drive. This way I can share the data between many Operating Systems (Windows, Ubuntu).

    sudo apt-get install gedit-plugins pidgin vim-nox gimp msttcorefonts amsn unrar p7zip-full mozilla-plugin-vlc vlc filezilla gnome-do calibre planner epiphany-browser docker

  5. Add your server packages
  6. install those server packages if you want.

    sudo apt-get install php5 php-pear mysql-server postfix apache2 phpmyadmin

  7. update
  8. sudo apt-get update

  9. remove unwanted packages and clean
  10. sudo apt-get autoremove
    sudo apt-get autoclean

     

  11. Enable Medibuntu repository
  12. need some additional software that is not available in Ubuntu Main. So we add Medibuntu repository to apt so that it can fetch, them.

    sudo wget http://www.medibuntu.org/sources.list.d/lucid.list --output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update

  13. Get the latest Thunderbird and Firefox
  14. Ubuntu does not supply with the latest Thunderbird and Firefox. So we get them from a different source.

    echo -e "\ndeb http://downloads.sourceforge.net/project/ubuntuzilla/mozilla/apt all main" | sudo tee -a /etc/apt/sources.list > /dev/null
    sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C1289A29
    sudo apt-get update
    sudo apt-get install thunderbird-mozilla-build firefox-mozilla-build

     

  15. Get the missing packages from Medibuntu
  16. Now we have enabled Medibuntu for apt, we can install encrypted DVD playback capability to Lucid.

    sudo apt-get install libdvdcss2

  17. Install Skype
  18. Skype is no longer available in Ubuntu repositiory. Execute following code to install skype.

    echo "deb http://download.skype.com/linux/repos/debian/ stable non-free #Skype" | sudo tee -a /etc/apt/sources.list > /dev/null
    gpg --keyserver pgp.mit.edu --recv-keys 0xd66b746e && gpg --export --armor 0xd66b746e | sudo apt-key add -
    sudo aptitude update && sudo aptitude install skype

  19. Install Firefox addons
  20. add following addons

    scribefire xmarks

     

     

Customize Ubuntu to Roll out your own Distro


1. save this as

sudo apt-get install debootstrap
sudo rm -rf work
mkdir work
sudo cp 3_livecd_final.sh work/.
sudo cp 4_livecd_make_iso.sh work/.
cd work
mkdir chroot
sudo cp ../2_livecd_chroot_run.sh chroot/.
sudo cp ../portablelinux_0.9.3-0ubuntu1~ppa0~jaunty1_all.deb chroot/.
sudo debootstrap –arch i386 jaunty chroot
sudo cp /etc/resolv.conf chroot/etc/resolv.conf
sudo cp /etc/apt/sources.list chroot/etc/apt/sources.list
echo “entering into chrooted environment”
sudo chroot chroot
echo “run 2_livecd_chroot_run.sh”

2. save this as run 2_livecd_chroot_run.sh

mount /proc
mount /sys
mount -t devpts none /dev/pts
apt-get update
export HOME=/root
export LC_ALL=C
apt-get install –yes ubuntu-standard casper
apt-get install –yes discover1 laptop-detect os-prober
apt-get install –no-install-recommends linux-generic ubiquity
apt-get install –no-install-recommends slim xserver-xorg
apt-get install –yes xfce4 xfce4-goodies ristretto xfce4-taskmanager xfce4-messenger-plugin xfce4-volstatus-icon xfprint4 xfce4-session xfce4-notifyd xfce4-places-plugin xfce4-smartpm-plugin alsa-utils xchat xchm xscreensaver xarchiver catfish
sudo wget http://www.medibuntu.org/sources.list.d/jaunty.list –output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
apt-get install –no-install-recommends gedit abiword gnumeric gedit-plugins pidgin gimp skype thunderbird lightning-extension enigmail vim-nox transmission wpasupplicant msttcorefonts amsn planner scribus unrar p7zip-full ntfs-3g openssh-client vino miro evince gdebi system-config-printer-gnome aptitude network-manager-gnome gwibber
apt-get install –yes libdvdcss2 libdvdread4 w32codecs vlc firefox ubufox mozilla-plugin-vlc filezilla brasero parcellite
sudo /usr/share/doc/libdvdread4/install-css.sh

dpkg -i portablelinux_0.9.3-0ubuntu1~ppa0~jaunty1_all.deb
rm -rf portablelinux_0.9.3-0ubuntu1~ppa0~jaunty1_all.deb

cd /tmp
wget http://download.songbirdnest.com/installer/linux/i686/Songbird_1.2.0-1146_linux-i686.tar.gz
tar xvf Songbird_1.2.0-1146_linux-i686.tar.gz
mv Songbird /opt/songbird
rm Songbird*.tar.gz
/usr/sbin/alternatives –install /usr/bin/Songbird songbird /opt/songbird/songbird 2
chown -Rf nobody.nobody /opt/songbird
chmod -Rf 777 /opt/songbird/
wget -c -q http://www.psychocats.net/ubuntu/songbirdicon.png
mv songbirdicon.png /usr/share/pixmaps/songbird.png
wget -c -q http://www.psychocats.net/ubuntu/songbird.desktop
mv songbird.desktop /usr/share/applications/songbird.desktop

apt-get autoremove
apt-get upgrade
apt-get clean

echo “exiting from chrooted environment”
rm -rf /tmp/*
umount -l -f /proc
umount -l -f /sys
umount /dev/pts
exit
echo “install mysql-server phymyadmin exim4-daemon-light apache2 php5 php-pear”
echo “************ CHEERS ***********”
echo “not yet exited from chroot”

3.

echo “src=https://help.ubuntu.com/community/LiveCDCustomizationFromScratch”
rm -rf chroot/2_livecd_chroot_run.sh
sudo apt-get install syslinux squashfs-tools mkisofs sbm
rm -rf image
mkdir image image/casper image/isolinux image/install
echo “enter correct kernel name if the below fails”
cp chroot/boot/vmlinuz-2.6.28-15-generic image/casper/vmlinuz
cp chroot/boot/initrd.img-2.6.28-15-generic image/casper/initrd.gz
cp /usr/lib/syslinux/isolinux.bin image/isolinux/
cp /boot/memtest86+.bin image/install/memtest
cp /boot/sbm.img image/install/
echo ”
This is an KaShUbuntu Remix Live CD.

For the default live system, enter ‘live’. To verify the CD for errors, enter ‘check’. To run memtest86+, enter ‘memtest'” > image/isolinux/isolinux.txt

echo “If you put this at the beginning of the isolinux.txt, the splash image will be displayed along with the text. The ^X is the control character which is mandatory for the splash image to work. To enter ^X in editor, do ctrl-V and follow with ctrl-X.”

echo “^Xsplash.rle”

echo ”
DEFAULT live
LABEL live
menu label ^Start or install Ubuntu
kernel /casper/vmlinuz
append file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.gz quiet splash —
LABEL check
menu label ^Check CD for defects
kernel /casper/vmlinuz
append boot=casper integrity-check initrd=/casper/initrd.gz quiet splash —
LABEL memtest
menu label ^Memory test
kernel /install/memtest
append –
LABEL hd
menu label ^Boot from first hard disk
localboot 0x80
append –
DISPLAY isolinux.txt
TIMEOUT 300
PROMPT 1″ > image/isolinux/isolinux.cfg

“echo creating manifest”
sudo chroot chroot dpkg-query -W –showformat=’${Package} ${Version}\n’ | sudo tee image/casper/filesystem.manifest
sudo cp -v image/casper/filesystem.manifest image/casper/filesystem.manifest-desktop
REMOVE=’ubiquity casper live-initramfs user-setup discover1 xresprobe os-prober libdebian-installer4′
for i in $REMOVE
do
sudo sed -i “/${i}/d” image/casper/filesystem.manifest-desktop
done

echo “compress chroot”
sudo mksquashfs chroot image/casper/filesystem.squashfs

echo “information – appending -e chroot/boot for the previous line will erase the boot folder which is not needed for live usb”

echo “#define DISKNAME Ubuntu 9.04 “Jaunty Jackalope” – Release i386 **Remix**
#define TYPE binary
#define TYPEbinary 1
#define ARCH i386
#define ARCHi386 1
#define DISKNUM 1
#define DISKNUM1 1
#define TOTALNUM 0
#define TOTALNUM0 1″ > image/README.diskdefines

touch image/ubuntu
echo “Create hidden “.disk” folder. This is needed to make the USB Creator work with this custom iso image. ”
mkdir image/.disk
cd image/.disk
touch base_installable
echo “full_cd/single” > cd_type
echo ‘Ubuntu 9.04 “Kashubuntu” – i386 (20090429)’ > info
echo “http://ubuntu-rescue-remix.org&#8221; > release_notes_url
cd ../..

echo “Calculate MD5”
sudo -s
(cd image && find . -type f -print0 | xargs -0 md5sum > md5sum.txt)
exit

4. save this as
rm -rf 3_livecd_final.sh
echo “Turn the image directory into an iso image”
rm -rf *.iso
cd image
sudo mkisofs -r -V “$IMAGE_NAME” -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../kashubuntu-remix.iso .
cd ..
exit

5. save the below as
echo “WARNING”
echo “insert thumbdrive before running this script”
sudo mkdir -p /mnt/isoimage
sudo mount -o loop work/kashubuntu-remix.iso /mnt/isoimage
rm -rf /media/PORTABLELNX/boot{vmlinuz,initrd.gz}
sudo cp /mnt/isoimage/casper/{vmlinuz,initrd.gz} /media/PORTABLELNX/boot
echo “copying persistance”
cp casper-rw /media/PORTABLELNX/casper-rw
sudo umount /mnt/isoimage
sudo rmdir /mnt/isoimage
echo “copying iso image to usb”
sudo dd if=work/kashubuntu-remix.iso of=/dev/sdb2

6. I use my home brewed ubuntu in a thumb drive. so download latest portable linux deb package and save it in your folder that contains the above 5 files.

7. run the first script and sit back and enjoy