Archive

Archive for the ‘ubuntu’ Category

Website Optimization 01: disable ETag in apache (debian/ubuntu)

October 20th, 2008 10 comments

From last few months i am working to optimize our somewhereinblog.net server, because right now we are getting huge amount of hits everyday (1,00,000 + hits). In this series i will describe the tricks that i learned 🙂


On my first post of this searies i will talk about ETag. Before disable this, first we need to know what is ETags. From wikipedia:

An ETag (entity tag) is an HTTP response header returned by an HTTP/1.1 compliant web server used to determine change in content at a given URL. When a new HTTP response contains the same ETag as an older HTTP response, the contents are determined to be the same without further downloading. The header is useful for intermediary devices that perform caching, as well as for client web browsers that cache results. One method of generating the ETag is based on the last modified time of the file and the size of the file.

In certain situations, ETags may not improve the performance of a web application. For instance, some ETag generation schemes incorporate the file’s inode on the system. The file’s inode is unique to the file only on one specific machine. If a site has multiple servers, each with its own copy of the file (i.e. load balancing), then a user’s request for the same file may get served by a different machine. In that case, the inode will almost certainly be different and, if it is used to generate the ETag, it will cause the file to be re-downloaded.

So, this is not always helpfull for all type of sites. Always remember, if you are not using anything, you should not enable or kept enable on server.

Apache by default enable this ETags. We need to disable this to get better performance. Here i am describing the steps for debian and ubuntu linux.

We will take help from mod_header to disable ETags, so first we need to enable the mod_header (apache module)

sudo a2enmod header

sudo /etc/init.d/apache2 restart

this command will enable mod_header. Now open /etc/apache2/apache2.conf with your faviourate browser.

sudo nano /etc/apache2/apache2.conf

then paste the under given code to this apache2.conf file

Header unset ETag
FileETag None

now restart the apache2, and check if it working or not. If every thing OK, then you will not see the etags anymore 🙂

For better understanding i am giving you 2 screenshots.

Before ETag disable


After ETag disable:


If you don’t have root access to server, you still can do this from .htaccess , just copy that code to .htaccess instate of apache conf file.

Ask me if you have any question or problem about ETag.

using ubunt ? need non-free software ?

April 4th, 2008 2 comments

today i passed some time tune my ubuntu gutsy (7.10). at the time of searching on the google i found www.medibuntu.org :). from that site:

Medibuntu (Multimedia, Entertainment & Distractions In Ubuntu) is a repository of packages that cannot be included into the Ubuntu distribution for legal reasons (copyright, license, patent, etc).

their package collection is so interesting. they have:

  • acrobat reader
  • w32codecs (also w64codecs)
  • googleearth
  • skype
  • etc 🙂

isn’t it interesting  ?

before getting this site, i was really missing my favourite “w32codecs”

to use this repository you have to run these commands (it’s too simple)

first get the repository address:

sudo wget http://www.medibuntu.org/sources.list.d/gutsy.list -O /etc/apt/sources.list.d/medibuntu.list

then add the gpg key to trusted keyring (so that you will not get warning each time you do something with apt)

wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add - && sudo apt-get update

too simple !!


thanks www.medibuntu.org for there hard work , to make life more easy :)

install imagemagick support to your debian/ubuntu server

February 2nd, 2008 3 comments

imagemagick is one of the best library to work with image. recently i have to install it to our production server. here is what i did:

$ apt-get install imagemagick

it downloads the package and all it’s dependences from debian/ubuntu repository, and installed. now i have to install the support of php (as our product running on php)

$ apt-get install php5-imagick

then i restarted the apache server to take effect this new package installation. if your using php4 then the package name should be php4-imagick

$ /etc/init.d/apache2 restart

that’s all 🙂

if you need imagemagick for your ruby , you can install the librmagick-ruby package.

**if this post doesn’t answer ur question, please post it in comment, i will try to help as much as possible. thanks for ur time.

mount your windows partition with write permission

October 19th, 2007 1 comment

I always get question from new linux users how to mount windows partition with read/write permission. That’s why writing this post…

to mount your other partition in linux, first you have to know what is there physical address. you can get this by:

ibrahim@lavluda:~$ su
Password:
lavluda:/home/ibrahim# fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 3270 26266243+ c W95 FAT32 (LBA)
/dev/sda2 3271 3513 1951897+ 82 Linux swap / Solaris
/dev/sda3 3514 5945 19535040 83 Linux
/dev/sda4 5946 14593 69465060 f W95 Ext’d (LBA)
/dev/sda5 8108 10247 17189518+ b W95 FAT32
/dev/sda6 10248 12420 17454591 b W95 FAT32
/dev/sda7 12421 14593 17454591 b W95 FAT32
/dev/sda8 5946 8107 17366202 83 Linux

Partition table entries are not in disk order
lavluda:/home/ibrahim#

now open your /etc/fstab with your favourite editor (i prefer nano for console)
and change according to your need. for batter understand you here is my fstab as example.

lavluda:/home/ibrahim#cd /media
lavluda:/home/ibrahim#mkdir c d e f
lavluda:/home/ibrahim# nano /etc/fstab

# /etc/fstab: static file system information.
#
# proc /proc proc defaults 0 0
/dev/sda3 / reiserfs notail 0 1
/dev/sda2 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/sda1 /media/c vfat rw,users,umask=000 0 0
/dev/sda5 /media/d vfat rw,users,umask=000 0 0
/dev/sda6 /media/e vfat rw,users,umask=000 0 0
/dev/sda7 /media/f vfat rw,users,umask=000 0 0

now time to mount these partitions 😀

lavluda:/home/ibrahim#mount -a

write comments if you still getting problem 😛

Categories: Linux, Linux Helps, ubuntu Tags:

how to move your php development environment to linux (Debian/Ubuntu)

August 4th, 2007 26 comments

Nowadays, lots of php developers are thinking to move their development environment to linux. And I am writing this tutorial for them. As I like Debian GNU/Linux (www.debian.org) best and ubuntu (www.ubutnulinux.org) is now doing great, in this tutorial I am using the commands for debian & ubuntu.

Ok, now starting:

First on all let’s make a list of software a PHP developer need mostly:

1.Apache
2.PHP
3.Mysql
4.PHP IDE

Ok, let’s start with Apache. Debian & ubuntu use APT to manage the packages. You can easily install apache using apt, here is the command

Debian user:

su

Ubuntu user:

sudo su

Rest of the command ar same for both debian & ubuntu.

apt-get install apache2

It will install all the apache2 & all the related packages (software)
If you need to enable mod_rewrite, follow this link
Now install the PHP

Apt-get install php5 libapache2-mod-php5

This will install the php5 and configure your apache2 server for PHP. You don’t need to do anything.
Lets test the server, if it working ok.

touch /var/www/info.php

Chown www-data:www-data info.php

Now edit this info.php with your feviourate editor and add write code to show phpinfo():
and now browse http://localhost/info.php from your browser. Now check if all your requested library are installed.
if you need any more library, you can check if it already available on your debian/ubuntu package list.

apt-cache search php5-

then you will get the list of available php5 library. Now simple use this command to install it.

apt-get install php5-gd

(example, if you want to install php5 GD library)

Remember: after installing every extra packages, you must need to restart apache server

/etc/init.d/apache2 restart

Ok, so you have now apache2 and php5 installed system. Let’s install mysql:

apt-get install mysql-server-5.0 php5-mysql

It will install all the necessary packages to run mysql-server.
Now restart your apache to take effect.
Complete!!!! Server is allmost ready.
Now i am going to derive how you will transfer your old code to this new environment. Belive me it’s too simple, so don’t worry.

First of all copy your source code to /var/www, here is the details procedure:

mkdir /windows

Here we make a folder for C drive of windows to mount.
mount /dev/hda1 /windows
then we mount the C drive to windows folder (here i use hda1 as example, if your hdd is sata then it will be sda1)

cp -r windows/Apache2/htdocs/xyz /var/www

here we copied our xyz site to /var/www (in debian and ubuntu, default apache2 root folder is /var/www)

cd /var/www

chown -R www-data:www-data xyz

Now change the ownership to www-data

Now we need to move the mysql database, there is two way:

1.use phpmyadmin
2.simple copy the database from data folder
I am deriving the 2nd way.

cp -r /windows/Mysql/data/xyz /var/lib/mysql

chown -R mysql:mysql /var/lib/mysql/xyz

You are done.

PHP Ide for linux environment:

    1.Zend ( i personaly use this)
    2.PHPEd
    3.PHPEclipse
    4.quanta plus
    5.emacs
    6.vi
    7.PHPedit

***I know this tutorial needs more edit, please make your comments if you got anything wrong, or missed anything. I want it a cool tutorial for php developers.

Read some reviewed, the best and most affordable php hosting solutions on the market.

how to enable mod_rewrite in apache2.2 (debian/ubuntu)

July 15th, 2007 323 comments

Here i am going to describe how to enable mod_rewrite in apache2.2 -specaily for debian.

In default installion of apache2.2 on debian never enable mod_rewrite default. So you may need to enable .

First install the apache2.2 with this command :
debian user please use “su” before start this process
ubuntu user please use “sudo su” before start this process

apt-get install apache2 (it will install apache 2.2)

on current debian system you can enable mod_rewrite with simple command

a2enmod rewrite

old style, you can skip this portion

now use locate to find if the mod_rewrite.so is availble on your server

updatedb
locate mod_rewrite.so

it will found in “/usr/lib/apache2/modules”

new apache follow some folders to enable and disable mods.
so now do this:

cd /etc/apache2/mods-enabled
touch rewrite.load
gedit rewrite.load (you may use any editor to edit this file)

now paste this following line

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

end of old style

Then edit /etc/apache2/sites-available/default or /etc/apache2/sites-available/000-default (check which one available on your system)

Find the following

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

and change it to

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

and finally restart Apache

/etc/init.d/apache2 restart
or
service apache2 restart

OK, you done 😀

don’t forget to comment, if it works or not.

thanks.

if you like my post, please tweet it, so other also can see this post.

Dell laptop with ubuntu 7.04

May 25th, 2007 2 comments

Read it first: http://direct2dell.com/one2one/archive/2007/05/24/15994.aspx

Dear *nix lovers,

Please don’t be happy too much. I think dell is doing a great cheating . Because with linux the price didn’t decrease, more over it increase.

2-3 month ago i bought a dell laptop from usa with 1057$ (including sales tax)-windows vista basic
Today i configured mostly same thing (even lower) with ubuntu – the price is 1080$ without tax 😛

Moreover check there support cost for ubuntu, it more then vista expense.

Categories: Linux, ubuntu Tags:

Speedup your apt

April 13th, 2007 No comments

Apt is the best friend for any deb dependend linux like debian , ubuntu etc.

You can speed up your apt by searching the nerestrepositery of apt (for your distro/linux)

I tested some tools to do this, APT-SPY shows the best performance 🙂

From manpage:

apt-spy is a program that tests a series of Debian archive mirrors for bandwith. It writes an /etc/apt/sources.list with the fastest server.

Run this command as su or root next thing will done by apt-spy, it will write a new /etc/apt/sources.list and the olde one will be backup with sources.list.bak

apt-spy -d unstable -n 5

Categories: Debian, Debian GNU/Linux, Linux, Tricks, ubuntu Tags:

Installing ttf fonts on Debian or Ubuntu Linux

January 31st, 2007 15 comments

Here is the simple step to install ttf font on Debian or Ubuntu or debian based linux.

First of all make a font directory to store the fonts. Better use “/usr/share/fonts/ttf”

So make the font directory:

Debian (login as root or use su):

mkdir /usr/share/fonts/ttf

Ubuntu:

sudo mkdir /usr/share/fonts/ttf

If u want to install the ttf font from windows, simple copy them from c:\windows\Fonts

Debian:

mkdir windows
mount /dev/hda1 windows
cd windows/Fonts
cp *.ttf /usr/share/fonts/ttf

Ubuntu:

mkdir windows
sudo mount /dev/hda1 windows
cd windows/Fonts
sudo cp *.ttf /usr/share/fonts/ttf

Now u need to generate the fonts.scale fonts.dir, so u have to install the ttmkfdir and mkfontdir.
Debian:

apt-get install ttmkfdir

cd /usr/share/fonts/ttf
ttmkfdir > fonts.scale
mkfontdir

Ubuntu:

sudo apt-get install ttmkfdir

cd /usr/share/fonts/ttf
sudo ttmkfdir > fonts.scale
sudo mkfontdir

Most of the works finished. U only need to add the font path to xwindows.

Debian:

nano /etc/X11/xorg.conf

Ubuntu:

sudo nano /etc/X11/xorg.conf

then add the fontpath to xorg.conf

FontPath “/usr/share/fonts/ttf”

Now restart ur display manager or total system.
Debian:

/etc/init.d/gdm restart

Ubuntu:

sudo /etc/init.d/gdm restart

If nothing goes wrong, ur done. Congrutulation!!!!!!!!

Categories: Debian, Linux, My Works, ubuntu, unix Tags:

Got 10 Ubuntu CD

November 29th, 2006 No comments

Today i got 10 Ubuntu CDs. Though i applied for these cd’s 3 month ago :(.

CD’s:

1> 8 i386 CDs

2> 1 64bit addition

3> 1 Mac Addition

Bad is, these are ubuntu dapper 🙁

Categories: My Computer, ubuntu Tags:
76 queries in 0.192 seconds