Balanzan Theme, Nice Ubuntu Theme

Ubuntu comes originally with the Human-theme, but since Ubuntu is using the Gnome desktop environment it is possible to change the theme to any other Gnome theme to enhance your Ubuntu experience. I have found a really nice theme for my Ubuntu desktop. It retains the brownish coloring of Ubuntu and it looks really nice and light.

Now How to install it ?

add the following lines at the end of your sources.list if it’s not already in it :

##Themes du ZgegBlog: Project Bisigi

deb http://ppa.launchpad.net/bisigi/ppa/ubuntu jaunty main

deb-src http://ppa.launchpad.net/bisigi/ppa/ubuntu jaunty main

Then open a terminal and do:

sudo apt-get update  && sudo apt-get install balanzan-theme

To Do List After installing Ubuntu 9.04 aka Jaunty Jackalope

This post is a follow up of this. In Ubuntu Jaunty Jackalope , as you would expect from any upgrade, the packages are a bit different, so i decided to write the Jaunty’s To Do List on its own. So here you go :

1 – Expand the Software Repository List

First of all, lets make Ubuntu “see” more packages. Go to the terminal and edit your sources.list with :

sudo gedit /etc/apt/sources.list

Here is the content of my sources.list which I think is quite complete to have all the necessary applications you could ever need. So delete the whole content of your sources list and replace it with the content of mine

Save it. Go to the Terminal and type:

sudo apt-get update && sudo apt-get upgrade

Now all your programs will run on the last version.

2 – Anti-Virus

Windows equivalent : AVG AntiVirus, NAV, TrendMicro, F-Prot, Kaspersky, …

Ubuntu equivalent : Avast

Avast

wget http://files.avast.com/files/linux/avast4workstation_1.3.0-2_i386.deb && sudo dpkg -i  avast4workstation_1.3.0-2_i386.deb

Access it through Accessories → avast! Antivirus .

3 – Essential tools for compiling from sources

sudo apt-get install build-essential checkinstall cdbs devscripts dh-make fakeroot libxml-parser-perl check avahi-daemon

4 – Java runtime environment

Java is a very important thing to install, now that many programs like Azureus need it to run. So type:

sudo apt-get install sun-java6-fonts sun-java6-jre sun-java6-plugin equivs ttf-sazanami-gothic ttf-sazanami-mincho

5 – More Fonts

Here you will find a bunch of fonts you can install on your system, but remember that you don’t need to install all of them

sudo mkdir -p /usr/lib/X11/fonts/Type1 && sudo apt-get install msttcorefonts && sudo apt-get install ttf-larabie-straight ttf-larabie-deco mplayer-fonts xfonts-terminus-dos xfonts-terminus xfonts-terminus-oblique xfonts-mona tv-fonts ttf-tuffy ttf-sjfonts ttf-sil-padauk ttf-sil-ezra ttf-paktype ttf-georgewilliams ttf-fifthhorseman-dkg-handwriting ttf-farsiweb ttf-essays1743 ttf-opensymbol ttf-nafees ttf-mgopen ttf-gentium ttf-freefont ttf-dustin ttf-devanagari-fonts ttf-dejavu-extra ttf-dejavu-core ttf-dejavu ttf-bpg-georgian-fonts ttf-bitstream-vera ttf-alee

6 – Ubuntu Control Panel

Ubuntu Tweak

Ubuntu Tweak allows you to tweak your system settings, all in one place. You can install new applications, customize your desktop settings, configure your startup applications, changing the system filetype association and many more tweaks in this single application.

sudo apt-get install ubuntu-tweak

Then access it through Applications → System Tools → Ubuntu Tweak

7 – Nice Right Click Sub-Menus

For some useful right click menus in nautilus

sudo apt-get install nautilus-actions nautilus-gksu nautilus-image-converter nautilus-open-terminal nautilus-script-audio-convert nautilus-script-collection-svn nautilus-script-manager nautilus-sendto nautilus-share nautilus-wallpaper

App Runner

App Runner is a small open source utility that makes it very easy to run any type of program/executable/script on any distro/OS that uses the nautilus file manager: Debian/Ubuntu/Super OS/Fedora/etc

wget http://hacktolive.org/files/app_runner/App_Runner_0.2.deb && sudo dpkg -i App_Runner_0.2.deb 

Then right-click the file -> Scripts -> Run This App or Run This App (root)

8 – Multimedia

Windows equivalent : windows media player, real player, vlc, mplayer

Ubuntu equivalent : vlc, mplayer, helix player

To have Ubuntu playing all kinds of stuff, you need to install many codecs. So on the Terminal, type:

* Installing vlc and mplayer (plays almost everything):

sudo apt-get install vlc mplayer

* Common packs

sudo apt-get install non-free-codecs libxine1-ffmpeg gxine mencoder mpeg2dec vorbis-tools id3v2 mpg321 mpg123 libflac++6 ffmpeg  toolame libmp4v2-0 totem-mozilla icedax tagtool easytag id3tool lame nautilus-script-audio-convert mozilla-helix-player helix-player libmad0 libjpeg-progs libmpcdec3 libquicktime1 flac faac faad sox toolame  ffmpeg2theora libmpeg2-4 uudeview flac libmpeg3-1 mpeg3-utils mpegdemux liba52-dev

* Gstreammer 0.10

sudo apt-get install gstreamer0.10-ffmpeg gstreamer0.10-fluendo-mp3 gstreamer0.10-fluendo-mpegdemux gstreamer0.10-gnonlin gstreamer0.10-pitfdll gstreamer0.10-sdl gstreamer0.10-plugins-bad-multiverse gstreamer0.10-schroedinger gstreamer0.10-plugins-ugly-multiverse totem-gstreamer

* More programs

sudo apt-get install gstreamer-dbus-media-service gstreamer-tools ubuntu-restricted-extras

* Enable dvd support

sudo aptitude install libdvdcss2 && sudo /usr/share/doc/libdvdread4/./install-css.sh

* Flash

sudo apt-get install gsfonts gsfonts-x11 flashplugin-nonfree

9. Tweak your eyecandy

Ubuntu 9.04 comes with compiz fusion effects OOTB but doesn’t offer a way to customize them.

In a terminal copy/paste this:

sudo apt-get install simple-ccsm

Now navigate to System → Preferences → Simple CompizConfig Settings Manager .

10 – Missing Windows software?? Run Windows softwares in Linux!!!

Wine

Wine is a compatibility layer for running Windows programs in Linux.

sudo apt-get install wine

Then just double click .exe file.

Note: Not all windows software can run.A list is available in the website.

11 – Play Windows Games in Linux

Install PlayonLinux.Games like world of warcraft ,counterstrike and many other can be played.Playonlinux is based on wine.

Click here for list of games available

sudo apt-get install playonlinux

12 – Clipboard Management

By Default in ubuntu when u copy something from an application and closes the application u will not be able to access it from the clipboard. And also when u copy severals text in serial u only have the last on available to you in the clipboard. To solve that install either of the following but Glipper is better because it supports plugins.

Glipper

sudo apt-get install glipper

Then right click ur panel → Add to Panel then drag Clipboard Manager to ur panel

Parcellite

sudo apt-get install parcellite

13 – Archiver/ Packing software

Windows equivalent : winrar, zip, 7zip

Ubuntu equivalent : tar, unrar, p7zip, arj, unace

It’s bad when you don’t have Internet on your computer/notebook, but you have to pack/unpack something but the file format isn’t recognized by the system. To prevent from this bad situation, you can install a bunch of packing software by typing this on the terminal:

sudo apt-get install unace rar unrar zip unzip p7zip-full p7zip-rar sharutils aish uudeview mpack lha arj cabextract file-roller

14 – Graphical web browser

Windows equivalent : Internet explorer, firefox, opera

Ubuntu equivalent : Firefox, opera

Opera

sudo apt-get install opera

Firefox (installed by default intrepid)

sudo apt-get install firefox

15 – Download Manager

Windows equivalent : Free download manager

Ubuntu equivalent : Multiget

MultiGet is a http/ftp downloader with a nice GUI for linux desktop users. It can run on almost all desktops without any configuration. It has many powerful functions comparing to others.

sudo apt-get install multiget

Access it through Applications → Internet → MultiGet .

16 – Graphical Email client

Windows equivalent : Outlook

Ubuntu equivalent : Evolution, Thunderbird

Evolution (installed by default in intrepid)

sudo apt-get install evolution

Access it through Applications → Internet → Evolution Mail .

Thunderbird

sudo apt-get install thunderbird

Access it through Applications → Internet → Mozilla Thunderbird Mail/News .

17 – Instant Messanging protocal clients

Windows equivalent : MSN messenger, Yahoo messenger, QQ, AIM, Gtalk, ICQ,IRC

Ubuntu equivalent : Pidgin, emesene

Pidgin (installed by default in intrepid)

Pidgin is an easy to use and free chat client used by millions. Connect to AIM, MSN, Yahoo, and more chat networks all at once. Supported chat networks: AIM, Bonjour, Gadu-Gadu, Google Talk, Groupwise, ICQ, IRC, MSN, MySpaceIM, QQ, SILC, SIMPLE, Sametime, XMPP, Yahoo!, Zephyr

sudo apt-get install pidgin pidgin-data pidgin-lastfm pidgin-guifications msn-pecan pidgin-musictracker pidgin-plugin-pack pidgin-themes

Access it through Applications → Internet → Pidgin Internet Messenger .

Emesene only for MSN Messenger.

sudo apt-get install emesene

Access it through Applications → Internet → Emesene .

18 – VOIP

Windows equivalent : skype

Ubuntu equivalent : skype, ekiga

Skype

sudo apt-get install skype

Access it through Applications → Internet → Skype.

Ekiga (installed by default in intrepid)

sudo apt-get install ekiga

Access it through Applications → Internet → Ekiga SoftPhone.

19 – Viewing PDF files

Windows equivalent : Adobe Reader

Ubuntu equivalent : Adobe Reader

Adobe Reader

sudo apt-get install acroread acroread-plugins mozilla-acroread acroread-plugin-speech acroread-fonts

Access it through Applications → Office → Adobe Reader.

20– Adobe Air

wget http://airdownload.adobe.com/air/lin/download/latest/AdobeAIRInstaller.bin
chmod +x . /AdobeAIRInstaller.bin
./AdobeAIRInstaller.bin

Access it through Applications → Accessories → Adobe Air Application Installer.

21 – Music / MP3 / OGG Players

Windows equivalent : iTunes, Winamp

Ubuntu equivalent : Rhythmbox, Amarok

Rhythmbox

sudo apt-get install rhythmbox

Access it through Applications → Sound & Video → Rhythmbox Music Player.

Amarok

sudo apt-get install amarok  amarok-common

Access it through Applications → Sound & Video → Amarok.

22 – Hard Disk Partitions Manager

Windows equivalent : Symanted Partition Magic

Ubuntu equivalent : GParted, Disk-Manager

GParted

sudo apt-get install gparted ntfsprogs

Access it through System → Administration → Partition Editor.

23 – Vector Graphics Editor

Windows equivalent : Adobe Illustrator

Ubuntu equivalent : Inkscape

Inkscape

sudo apt-get install inkscape

Access it through Applications → Graphics → Inkscape Vector Graphics Editor.

24 – Image Editor

Windows equivalent : Adobe Photoshop

Ubuntu equivalent : GIMP

GIMP

sudo apt-get install gimp gimp-data gimp-plugin-registry

Access it through Applications → Graphics → GIMP Image Editor.

25 – 3D Graphics Applications

Windows equivalent : 3D Studio MAX

Ubuntu equivalent : Blender

Blender

sudo apt-get install blender

Access it through Applications → Graphics → Blender (windowed).

26 – Simple Yet Advanced Text Editor

Windows equivalent : Notepad ++

Ubuntu equivalent : GEdit

GEdit

sudo apt-get install gedit gedit-plugins

Access it through Applications → Accessories → Text Editor.

27 – Office Applications

Windows equivalent : Microsoft Office

Ubuntu equivalent : OpenOffice

OpenOffice

sudo apt-get install  openoffice.org

Access it through Applications → Office

28 – Microsoft Visio

Windows equivalent : Microsoft Visio

Ubuntu equivalent : Dia

Dia

sudo apt-get install dia

Access it through Applications → Graphics → Dia Diagram Editor

29 – Microsoft Project

Windows equivalent : Microsoft Project

Ubuntu equivalent : OpenProj

OpenProj

wget http://nchc.dl.sourceforge.net/sourceforge/openproj/openproj_1.4-2.deb && sudo dpkg -i openproj_1.4-2.deb

Access it through Applications → Office → OpenProj

30 – Development IDE

Windows equivalent : Dreamweaver

Ubuntu equivalent : Quanta, Kompozer, NetBeans

Quanta

sudo apt-get install quanta

Access it through Applications → Programming → Quanta Plus

Komposer

sudo apt-get install kompozer nvu

Access it through Applications → Internet → Kompozer

NetBeans

sudo apt-get install netbeans

Access it through Applications → Programming → NetBeans IDE

31 – Graphical FTP clients

Windows equivalent : CuteFTP, SmartFTP

Ubuntu equivalent : FileZilla

FileZilla

This is great FTP program, very complete, in my opinion, the best one for linux.

On the terminal type:

sudo apt-get install filezilla filezilla-common

Access it through Applications → Internet → FileZilla FTP Client.

32 – P2P Clients / Servers, File Sharing

Windows equivalent : utorrent, azureus, emule

Ubuntu equivalent : Deluge, azureus, amule

Bittorent clients

Deluge (written in python)

sudo apt-get install deluge-torrent

Access it through Applications → Internet → Deluge Torrent.

Azureus: Uses Java to run, very complete but a bit heavy

sudo apt-get install azureus

Access it through Applications → Internet → Azureus.

Emule Donkey Clients

Amule

sudo apt-get install amule

Access it through Applications → Internet → aMule.

33 – Programs for CD burning with GUI

Windows equivalent : Nero, Roxio Easy CD Creator

Ubuntu equivalent : K3b, Brasero

K3b

Nero is available for linux,but its not free.A trial is available for 1 month usage and later it asks or activation code.But K3B is as good as Nero.Have a good feature set as Nero.

sudo apt-get install k3b k3b-data k3b-i18n libk3b3

Access it through Applications → Sound & Video → K3B.

Brasero (installed by default in Intrepid)

sudo apt-get install brasero

Access it through Applications → Sound & Video → Brasero Disc Burning .

34 – Mountings ISO files

Windows equivalent : Alcohol

Ubuntu equivalent : acetoneiso

Acetoneiso

The best one for linux ACETONEISO,which is similar to ALCOHOL in windows

its supports almost all formats. AcetoneISO is CD/DVD image manipulator for Linux.Using this tool it is very easy to Mount and Unmount ISO,MDF,NRG Images . I dont think its available in ubuntu repository.

sudo apt-get install libksba8 libenca0 libtwolame0 fuseiso kommander p7zip-full gnupg-agent gnupg2 pinentry-qt mencoder cdrdao
wget http://darkstar.ist.utl.pt/getdeb/ubuntu/intrepid/ac/acetoneiso_2.0.2-0~getdeb1_i386.deb && sudo dpkg -i acetoneiso_2.0.2-0~getdeb1_i386.deb

35 – Install Vista like gadgets.

Windows equivalent : Vista Sidebar

Ubuntu equivalent : google-gadgets

Google gadgets

wget http://neacm.fe.up.pt/pub/getdeb/ubuntu/intrepid/go/google-gadgets_0.10.5-1~getdeb2_i386.deb && sudo dpkg -i google-gadgets_0.10.5-1~getdeb2_i386.deb

This will complete the installation.

Now press Alt+F2, and type “ggl-gtk” to start them. You should see a small icon show up in your system tray, and a sidebar. Right click on any of them and select ‘Add Gadgets’ to show a menu. If you’d like to have Google Gadgets start automatically, go to System – Preferences – Session, click ‘Add’, paste ‘Google Gadgets’ for the name and ‘ggl-gtk’ for the command. Click OK and Close, and you’re good to go.

36 – Google Desktop

Google Desktop allows one to full text search of a user’s e-mail, computer files, music, photos, chat, and Web pages viewed,OpenOffice documents , PDF files and more .

Now similar tools already existed on Linux like beagle (supported by novell ) , meta tracker etc . However Google Desktop search is not based on any of these tools and uses its proprietary algorithms to search for files on the computer ,also being 1.0 release and more stable then these products it could be preferred over tools like beagle .

To install Google Desktop Search type the following command in the terminal window : -

sudo apt-get install google-desktop-linux

Access it through Applications → Google Desktop → Google Desktop

Now after choosing appropriate option through Applications → Google Desktop → Google Desktop Preferences, you would find Google Desktop icon in the bar at the top of the screen , now it would automatically scan and index files on computer and store it in local database which could be searched using web browser .

37 – Photo Management

Google Picasa

Google Picasa is an extremely professional good looking photo management application available on Windows ,Linux and Mac OS (??) . Now Google Picasa has a number of features that many photo management software on Linux dont have further Google Picasa looks very user friendly as compared to similar open source application available on linux . Now Google Picasa for Linux is not a native linux application but runs on Linux thru application layer called wine which allows many windows application to run flawlessly on Linux.

Now to install Google – Picasa type the following command in the terminal window

sudo apt-get install picasa

Access it through Applications → Graphics → Picasa → Picasa

38 – Map Viewing and Management

Google Earth

To install Google Earth type the following command in the Terminal Window.

sudo aptitude install googleearth

After downloading is over you will get a screen like this press ¨Yes¨ to accept the license agreement and complete software installation.

Now you can launch Google Earth from Application → Internet → Google Earth

39 – Gmail Notification

Checkgmail

If you would like to get notified when you have a new mail in your google mail account, checkgmail is for you. To install Checkgmail type the following command in the Terminal Window.

sudo apt-get install checkgmail

Now you can launch it from Application → Internet → CheckGmail

40 – Configure Firewall

If you are concern about your security, then it is pertinent that you activate the firewall and prevent any unauthorized access to your computer.

UFW is installed by default, but if you need a graphical interface, install GUFW.

sudo apt-get install gufw
41 – Gnome Do

Gnome Do is a small application that allows you to search and do things faster and more efficiently in your Ubuntu machine. It is similar to QuickSilver in Mac and Launchy in Windows. For those who have not tried Gnome Do before, it might take some time for you to get used to it. But once you’re hooked to it, there will be no turning back for you.Gnome Do also comes with a dock interface that you can use it like any other docks.

sudo apt-get install gnome-do

Now you can launch it from Application → Accessories → Gnome Do

Installing OpenERP (aka TinyERP) Stack on Ubuntu Intrepid 8.10

OpenERP, previously called TinyERP, but renamed due to the mismatch between its name and its size, is an open-source ERP system written (mostly) in Python and initiated in Belgium.

On Ubuntu Intrepid, the available openERP package from APT is still the old version 4.2.2 while the current one is 5.0.0.3 and the name of the package is still tinyerp-server and tinyerp-client. In Ubuntu Jaunty Jackalope, the default packages available from APT are current and have their name changed to openerp.

So, if your want to get the latest release of OpenERP on Intrepid , continue reading.

Installing The Pre requisites

You will need python, postgresql and some other necessary packages. So go ahead and open your terminal and type :

sudo apt-get install python python-setuptools python-psycopg2 python-reportlab python-egenix-mxdatetime python-xml python-tz python-pychart python-pydot python-lxml python-libxslt1 python-vobject python-gtk2 python-glade2 python-matplotlib python-hippocanvas evince xpdf flashplugin-nonfree postgresql

Installing Open ERP Server

Now, we need to download the tar file, extract it , then install it. Open your terminal and run each of the following line commands at a time.

wget http://www.openerp.com/download/stable/source/openerp-server-5.0.0-3.tar.gz 
tar -xzf openerp-server-5.0.0-3.tar.gz 
cd openerp-server-5.0.0-3 
sudo python setup.py install

If your PostgreSQL server is up and running, login as the default superuser for PostgreSQL which is called postgres :

sudo su - postgres 

you can now run the server using the following command:

openerp-server

Installing Open ERP Client

Open your terminal and type :

wget http://www.openerp.com/download/stable/source/openerp-client-5.0.0-3.tar.gz 
tar -xzf openerp-client-5.0.0-3.tar.gz 
cd openerp-client-5.0.0-3 
sudo python setup.py install

You can now run the client using the following command:

openerp-client

You will be presented with some survey, you can fill the fields or cancel.
Then you need to create a database for the application. Through the menu, navigate to File → Databases → New Database

On the interface you can customize your server address and connection, database name and create an administration account for the application. Fill in the fields and click ok.

Follow the wizard to set up your basic application.

Installing Open ERP Web Client

We need to install TurboGears first. Open your terminal and type :

sudo easy_install TurboGears==1.0.8 

Check whether it’s properly installed by typing :

tg-admin info

You should see the version information of TurboGears and related packages.

Now install the web client by typing :

sudo easy_install -U openerp-web

The configuration file is located at :

/usr/lib/python2.5/site-packages/openerp_web-5.0.0_3.1-py2.5.egg/config/default.cfg
Now start the web server with start-openerp-web command:

start-openerp-web

If you see message showing cherrypy._cperror.NotReady: Port not free, then make sure no other application is running on the specified port (8080 is default).

You can change port for by changing server.socket_port value in config/default.cfg.

If everything is fine, open your favorite web browser and type http://localhost:8080, and your can see the welcome page with the login screen.

Please make sure cookies are enabled in your browser.

Of course, OpenERP Server must be running at that time. If you have not previously created a database , you should create a database from the DBAdmin interface by clicking on Manage button that you can see besides the Database selection box. After creating a new database login with the admin/admin or demo/demo to see OpenERP in action…

Run Open ERP Web Client as service (daemon)

Open your terminal and type :

sudo cp /usr/lib/python2.5/site-packages/openerp_web-5.0.0_3.1-py2.5.egg/scripts/openerp-web /etc/init.d
sudo cp /usr/lib/python2.5/site-packages/openerp_web-5.0.0_3.1-py2.5.egg/config/default.cfg /etc/openerp-web.cfg
sudo chmod +x /etc/init.d/openerp-web

Make sure the user is terp in /etc/init.d/openerp-web :

sudo gedit /etc/init.d/openerp-web

Make sure you have : USER=”terp”
Now let’s edit /etc/openerp-web.cfg :

sudo gedit /etc/openerp-web.cfg

find :

args="('server.log',)" 

and change it to :

args="('/var/log/openerp-web.log',)"

Create /var/log/openerp-web.log with proper ownership :

sudo touch /var/log/openerp-web.log
sudo chown terp /var/log/openerp-web.log

Now, run following command to start the OpenERP Web automatically on system startup :

sudo update-rc.d openerp-web defaults

Start the deamon :

sudo /etc/init.d/openerp-web start

Git, Fast and Distributed Source Code Management

Today I did a presentation in my company to try to convince my fellows to use git like me for their source code management stuff even though we use subversion in the company. Since you end up here because you wanted more information about git, here you go for the actual presentation :)

Setting Up Apache2 with SSL on Ubuntu Intrepid 8.10 using OpenSSL

This guide will help you setup SSL with apache2. This assumes you have already installed the default lamp stack in Ubuntu Intrepid.

In order to make sure we have the necessary packages in place, open your terminal and type :

sudo apt-get install apache2 apache2.2-common apache2-utils openssl openssl-blacklist openssl-blacklist-extra

To set up your secure server, use public key cryptography to create a public and private key pair. In most cases, you send your certificate request (including your public key), proof of your company’s identity, and payment to a Certificate Authority (CA). The CA verifies the certificate request and your identity, and then sends back a certificate for your secure server.

Alternatively, you can create your own self-signed certificate. Note, however, that self-signed certificates should not be used in most production environments. Self-signed certificates are not automatically accepted by a user’s browser. Users are prompted by the browser to accept the certificate and create the secure connection.

Once you have a self-signed certificate or a signed certificate from the CA of your choice, you need to install it on your secure server.

Whether you are getting a certificate from a CA or generating your own self-signed certificate, the first step is to generate a key.

Generating a Certificate Signing Request (CSR)

To generate the Certificate Signing Request (CSR), you should create your own key. You can run the following command from a terminal prompt to create the key:

openssl genrsa -des3 -out server.key 4096

You can also run your secure web server without a passphrase. This is convenient because you will not need to enter the passphrase every time you start your secure web server. But it is highly insecure and a compromise of the key means a compromise of the server as well.

In any case, you can choose to run your secure web server without a passphrase by leaving out the -des3 switch in the generation phase or by issuing the following command at a terminal prompt:

openssl rsa -in server.key -out server.key.insecure>

You can use this file to generate the CSR without passphrase.

Then create a certificate signing request with it. This command will prompt for a series of things (Country Name, State or Province Name, Locality Name, Organization Name, Organizational Unit Name, Common Name, Email Address, A Challenge password, An Optional Company Name ). Think carefully when inputting a Common Name (CN) as you generate the .csr file below. This should match the DNS name, or the IP address you specify in your Apache configuration. If they don’t match, client browsers will get a “domain mismatch” message when going to your https web server.

The default values for the questions ([AU], Internet Widgits Pty Ltd, etc.) are stored here: /etc/ssl/openssl.cnf. So if you’ve got a large number of certificate signing requests to process you probably want to carefully edit that file where appropriate. Otherwise, to create the CSR, run the following command at a terminal prompt:

openssl req -new -key server.key -out server.csr

You can submit this CSR file to a CA for processing. The CAN will use this CSR file and issue the certificate. On the other hand, you can create self-signed certificate using this CSR.

Creating a Self-Signed Certificate

Now sign the certificate signing request. This example lasts 365 days. Run the following command at a terminal prompt:

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

The above command will prompt you to enter the passphrase (if using the secure key). Once you enter the correct passphrase, your certificate will be created and it will be stored in the server.crt file.

Installing the Certificate

Copy the server.crt and server.key files into position.

sudo mkdir /etc/apache2/ssl/
sudo cp server.crt /etc/apache2/ssl/
sudo cp server.key /etc/apache2/ssl/

Enable the SSL module for Apache2

open your terminal and type :

sudo a2enmod ssl

Create and enable the SSL site

First we need to create a virtualhost for our site by copying the default skeleton:

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/www.salimane.com

Then edit the content to look like the following :

sudo gedit /etc/apache2/sites-available/www.salimane.com
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
	ServerName www.salimane.com
	LogLevel warn
	ErrorLog /var/log/apache2/www.salimane.com.error.log
	CustomLog /var/log/apache2/www.salimane.com.access.log combined

	DocumentRoot /var/www/www.salimane.com/

	<Directory /var/www/www.salimane.com/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>

        SSLEngine On
        SSLCertificateFile    /etc/apache2/ssl/server.crt
        SSLCertificateKeyFile /etc/apache2/ssl/server.key
        SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>

Now enable the site by typing :

sudo a2ensite www.salimane.com

Instruct Apache to listen to 443
we have to edit apache ports configuration file located at /etc/apache2/ports.conf :

sudo gedit /etc/apache2/ports.conf

By default it looks like :

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    Listen 443
</IfModule>

we have to add the https NameVirtualHost. So edit it to look like :

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    NameVirtualHost *:443
    Listen 443
</IfModule>

Don’t forget to edit your /etc/hosts file if you’re running on your local box with www.salimane.com pointing to 127.0.0.1

Now you should restart the server. If you used a key with a passphrase , you will be prompted to enter the passphrase every time you want to restart the server. Once you enter the correct passphrase, the secure web server will be started.

sudo /etc/init.d/apache2 restart

Accessing the Server

You can access the secure server pages by typing https://www.salimane.com in your browser address bar.  If you use a self- signed certificate , you will be greeted with “Secure Connection Failed” on firefox. Just ignore that and click “Or you can add an exception…” then  “Add Exception…”

APC, an Open Source PHP opcode Cache on Ubuntu Intrepid 8.10 using PECL and APT

PHP is interpreted, PHP code is parsed and translated to opcodes (primitive instructions — akin to assembly language — that the PHP engine executes directly) every time it executes. An opcode cache eliminates that rework, making PHP applications faster.

Of course, an opcode cache will not help your site if your bottleneck in not CPU or memory. For example, if your bottleneck is in the database, or disk, the opcode cache will not directly help. However, since scripts start and end faster than without one, you may experience less contention in some cases.

Among available free opcode caches, we have :

  • APC: Alternative PHP Cache. A free opcode cache maintained by PHP code developers.

  • eAccelerator, a free fork of the now abandoned Turck MMCache.

  • XCache. A free project by lighttpd.

With several servers running Ubuntu 8.04.01 LTS, Apache 2.2.8 and PHP 5.2.4 I have found that neither eAccelerator nor XCache are stable. In a matter of a day or so, you will get segmentation faults in Apache 2. Well you can watch the segmentation faults in apache error log and put the server back on when that happens . But it’s kind of a pain , so I went for APC . On the contrary, APC — currently using 3.0.19 — is very stable and never experiences segmentation faults.

APC is maintained by core PHP developers, including Rasmus Lerdorf and others. APC does not utilize a disk cache, unlike both eAccelerator and Xcache (although it is configurable). Xcache is a viable option, specially if you find installing APC daunting.

But it’s important to note that APC can perform poorly if you don’t give it enough memory to cache all of the code that your site uses. So, changing APC to use 64 MB of shared memory instead of the default 30 MB should be all right. APC uses this memory to cache the parsed and tokenized scripts for later calls.

Now let’s install APC . This assumes you’ve already installed the default LAMP Stack in Ubuntu.

Open a terminal and type :

sudo apt-get install php-pear php5-dev apache2-prefork-dev build-essential && sudo pecl install apc && sudo apt-get remove php5-dev apache2-prefork-dev

Now let’s edit the configuration file of apc. On your command prompt type :

gksudo gedit /etc/php5/conf.d/apc.ini

add these settings to the file :

extension=apc.so
apc.apc.stat = 0
apc.include_once_override = 1
apc.shm_size = 64

and restart apache 2 :

sudo /etc/init.d/apache2 restart

Now, let’s test an application. Choose an application or two to test. You can use your own code . I used phpMyAdmin for the sample. I assume you’ve already installed phpMyAdmin.

Running a benchmark

The Apache HTTP Web server ships with a utility named ab, short for Apache HTTP server benchmarking tool. Use ab to automate a large number of requests for PHP pages.

The ab utility is simple to use: Provide a repeat count and a URL. The ab utility requests that URL many times over and returns statistics. Because APC is already enabled, the first benchmark will show performance with acceleration.

Before you run ab, point your browser to http://localhost/phpmyadmin/. Visiting this page once loads all the PHP code used to render the page into the cache. Now, run the benchmark shown below, iterating 100,000 times.

ab -n 100000 http://localhost/phpmyadmin/

Here is part of the output on my local :

Time taken for tests:   25.857 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Non-2xx responses:      100000
Total transferred:      64000000 bytes
HTML transferred:       35000000 bytes
Requests per second:    3867.47 [#/sec] (mean)
Time per request:       0.259 [ms] (mean)
Time per request:       0.259 [ms] (mean, across all concurrent requests)
Transfer rate:          2417.17 [Kbytes/sec] received

The statistics of interest are requests per second and the total time to complete all the tests. For the former, a higher value is better; for the latter, lower is better.

Now, disable APC by editing the apc.ini file :

gksudo gedit /etc/php5/conf.d/apc.ini

comment out all the lines :

;extension=apc.so
;apc.apc.stat = 0
;apc.include_once_override = 1
;apc.shm_size = 64

and restart apache 2 :

sudo /etc/init.d/apache2 restart

Now run the benchmarch again :

ab -n 100000 http://localhost/phpmyadmin/

here is the output on my local :

Concurrency Level:      1
Time taken for tests:   26.579 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Non-2xx responses:      100000
Total transferred:      64000000 bytes
HTML transferred:       35000000 bytes
Requests per second:    3762.32 [#/sec] (mean)
Time per request:       0.266 [ms] (mean)
Time per request:       0.266 [ms] (mean, across all concurrent requests)
Transfer rate:          2351.45 [Kbytes/sec] received

Here, with APC disabled, the number of requests per second fell, reflecting that the Apache server took longer for each request. The time to run the entire suite of tests climbed, as well.

Although this is a simple benchmark — the phpMyAdmin connection to the database could have been disabled to limit processing time to interpreting PHP alone — and not highly scientific, it does demonstrate what you can achieve with APC. For a tiny investment (and, thankfully, no need to recompile PHP or Apache), APC can yield a relatively large return. The more complex your code, the greater the possible benefits.

Master-Slave MySQL 5.0 Replication On Ubuntu Intrepid 8.10

Replication enables data from one MySQL database server (called the master) to be replicated to one or more MySQL database servers (slaves). Replication is asynchronous – your replication slaves do not need to be connected permanently to receive updates from the master, which means that updates can occur over long-distance connections and even temporary solutions such as a dial-up service. Depending on the configuration, you can replicate all databases, selected databases, or even selected tables within a database. This is not a backup policy because an accidentally issued DELETE command will also be carried out on the slave; but replication can help protect against hardware failures though. This setup is for linux boxes since that’s the only boxes I know how to use :) .

Pre Requisites

Master Server

  • OS : Ubuntu Intrepid (but will work for any other linux box without or with a slight of changes)
  • MySQL server installed
  • Database to be replicated on server

Slave Server

  • OS : Ubuntu Intrepid (but will work for any other linux box without or with a slight of changes)
  • MySQL server installed
  • No replicated database on server

1 Database Transfer

Make a dump of the database to be replicated on the master

time mysqldump -u root -p –-host=localhost --opt salimane_db > /home/salimane/backup/salimane_db_dump.sql

Now transfer this file to your slave server! . You can use scp or any other means. Then on the Slave Server, create a new database (replace salimane_db of course):

mysqladmin -u root -p create salimane_db;

then load the dump file on the slave server

time mysql -u root -p --database=salimane_db < /path/to/file/on/slave/salimane_db_dump.sql

2 Configure The Master

First we have to edit the master mysql configuration /etc/mysql/my.cnf.

gksudo gedit /etc/mysql/my.cnf

We have to enable networking for MySQL, and MySQL should listen on all IP addresses, therefore we comment out these lines (if existant):

#skip-networking
#bind-address            = 127.0.0.1

For replication to work, you must enable binary logging on the master. If binary logging is not enabled, replication will not be possible as it is the binary log that is used to exchange data between the master and slaves. Add to your my.cnf, located at /etc/mysql/my.cnf in the default lamp stack in Ubuntu, in the [mysqld] block replacing “salimane_db” with you related database (don’t put it at the end of the file) :

# Replication Block
log-bin 	= 	/var/lib/mysql/master-bin.log
log-bin-index = 	/var/lib/mysql/master-bin.index.log
binlog-do-db	=	salimane_db
server-id	=	1

Note
For the greatest possible durability and consistency in a replication setup using InnoDB with transactions, you should also add :

innodb_flush_log_at_trx_commit=1
sync_binlog=1

Then we restart MySQL:

sudo /etc/init.d/mysql restart

Then we need to create a user on the Master Server that the Slave Server will connect as with replication privileges. So still on the Master Server:

mysql -u root -p

Now on the MySQL shell, type (Replace mysql_slave_user with your settings) :

GRANT REPLICATION SLAVE ON *.* TO 'mysql_slave_user'@'%' IDENTIFIED BY 'mysql_slave_user';

Then to refresh the privileges, type:

FLUSH PRIVILEGES;

Next (still on the MySQL shell) do this:

USE salimane_db;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;

The last command will show something like this:

mysql> show master status;

+-------------------+----------+--------------+------------------+

| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+-------------------+----------+--------------+------------------+

| master-bin.000002 |       98 | salimane_db         |                  |

+-------------------+----------+--------------+------------------+

1 row in set (0.00 sec)

Write down this information, we will need it later on the slave!

2 Configure The Slave

Now we have to tell MySQL on the slave that it is the slave, that the master is 123.456.78.90, and that the Master database to watch is salimane_db. Therefore, we add the following lines to /etc/mysql/my.cnf :

# Replication Settings
read-only
server-id=2
master-connect-retry=60
replicate-do-db=salimane_db

Then we restart MySQL:

/etc/init.d/mysql restart

Now log on the Slave mysql shell :

mysql -u root -p

Next , type :

stop slave;

In the next command (still on the Slave MySQL shell) , you have to replace the values appropriately:

CHANGE MASTER TO MASTER_HOST=''123.456.78.90', MASTER_USER='mysql_slave_user', MASTER_PASSWORD='mysql_slave_user', MASTER_LOG_FILE='master-bin.000002', MASTER_LOG_POS=98;

Now let’s explain a bit :

  • MASTER_HOST is the IP address or hostname of the master (in this example it is 123.456.78.90).
  • MASTER_USER is the user we granted replication privileges on the master.
  • MASTER_PASSWORD is the password of MASTER_USER on the master.
  • MASTER_LOG_FILE is the file MySQL gave back when you ran SHOW MASTER STATUS; on the master.
  • MASTER_LOG_POS is the position MySQL gave back when you ran SHOW MASTER STATUS; on the master.

Now all that is left to do is start the slave. Still on the MySQL shell we run :

start slave;

That’s it! Now whenever salimane_db is updated on the master, all changes will be replicated to salimane_db on the slave. Test it!

Redirect All Users to Access Your Site WITH/WITHOUT ‘www.’ Prefix

The basic idea here is when the user enter salimane.com, they get redirected to www.salimane.com . Some people prefer the opposite. In the default drupal .htaccess  you have the following :

# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Let me tell you straight, it doesn’t work . The working solution that i found is to have two virtual hosts :
- http://example.com/
- http://www.example.com/

and the former permanently redirect to the later or vice versa.  You can have one apache virtual host configuration  that looks like this for the site : salimane.com

	<VirtualHost *:80>
	       ServerAdmin webmaster@localhost
	       ServerName salimane.com
	       Redirect permanent / http://www.salimane.com
        </VirtualHost>

        <VirtualHost *:80>
	       ServerAdmin webmaster@localhost
	       ServerName www.salimane.com
	       LogLevel warn
	       ErrorLog /var/log/apache2/salimane.com.error.log
	       CustomLog /var/log/apache2/salimane.com.access.log combined
	       DocumentRoot /var/www/salimane.com/
	       <Directory /var/www/salimane.com/>
		      Options Indexes FollowSymLinks MultiViews
		      AllowOverride All
		      Order allow,deny
		      allow from all
	       </Directory>
        </VirtualHost>

Of course, you have to customise that to your settings.

Update : Another solution is to use CNAME as mentioned by Lukas in the comments.  CNAME records are domain name aliases. It can be used to provide access to a web-server using both the standard “www.salimane.com” and “salimane.com”.
This is usually done by creating an A-record for the short name (without www), and a CNAME-record for the www name pointing to the short name. By the way, A CNAME-record should always point to an A-record to avoid circular references.
you can have something like this :

; zone fragment for salimane.com
$TTL 2d ; zone default = 2 days or 172800 seconds
$ORIGIN salimane.com.
....
salimane.com   IN      A      192.168.0.3
www        	IN      CNAME  salimane.com

Installing Xdebug on Ubuntu LAMP Stack Using APT

This assumes you have installed your LAMP stack using APT (the default LAMP stack in Ubuntu not xampp for linux). It has never got easier to install xdebug using APT compared to compiling it from source. If you don’t know what is xdebug, its uses and benefits, check out my post here and here. As opposed to compiling it from source, you just need to do :

sudo apt-get install php5-xdebug php5-dev

The configuration file for xdebug is located at : /etc/php5/conf.d/xdebug.ini

you can check out my post here on configuring xdebug.

then restart apache 2

sudo /etc/init.d/apache2 restart

Installing a LAMP Stack on Ubuntu Using APT

This is to help people set-up and install a LAMP (Linux-Apache-MySQL-PHP) stack in Ubuntu, including Apache 2, PHP 5 and MySQL 5.0. You can actually do it with one line of commands but since that’s not the point, let’s go step by step.

Installing Apache 2

open up the Terminal and then type this line:

sudo apt-get install apache2 apache2-utils

To restart the server

sudo /etc/init.d/apache2 restart

By default when restarting you will get this warning :

apache2: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
You will have to edit the apache configuration located at : /etc/apache2/apache2.conf

gksudo gedit /etc/apache2/apache2.conf

then add

ServerName localhost

to the file and save, restart apache2

Browse to http://localhost , you should see displayed a text message “it works”

By default, your document root folder is located at : /var/www/ . Out of the box, you won’t have write permission to this folder, so first of all we need to change that by changing the ownership of the folder to your user.

At a terminal, do the following (replacing salimane with your login name):

sudo chown -R salimane /var/www

By default, Ubuntu’s Apache 2 will ignore the directives in your .htaccess files. To make .htaccess files work as expected, you need to edit the file /etc/apache2/sites-available/default (sometimes /etc/apache2/sites-available/000-default)
Look for a section that looks like this:

        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                # Uncomment this directive is you want to see apache2's
                # default start page (in /apache2-default) when you go to /
                #RedirectMatch ^/$ /apache2-default/
        </Directory>

You need to modify the line containing “AllowOverride None” to read “AllowOverride All”. This tells Apache that it’s okay to allow .htaccess files to over-ride previous directives.

You must reload Apache before this change will have an effect:

sudo /etc/init.d/apache2 reload

Installing MySQL Server

open up the Terminal and then type this line:

sudo apt-get install mysql-server

In order for other computers on your network to view the server you have created, you must first edit the “Bind Address”. Begin by opening up Terminal to edit the MySQL configuration file my.cnf .

gksudo gedit /etc/mysql/my.cnf

remove or comment out the line

bind-address = 127.0.0.1

and restart mysql server with :

sudo /etc/init.d/mysql restart

Installing PHP5

open up the Terminal and then type this line:

sudo apt-get install php5

Installing PHP5 module for apache2

open up the Terminal and then type this line:

sudo apt-get install libapache2-mod-php5

In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:

sudo /etc/init.d/apache2 restart

To ensure there are no issues with PHP let’s give it a quick test run. In the terminal copy/paste the following line:

echo "<?php phpinfo(); ?>" > /var/www/phpinfo.php

Now open your web browser and type the following into the web address: http://localhost/phpinfo.php

Installing MySQL module for PHP5

open up the Terminal and then type this line:

sudo apt-get install php5-mysql mysql-client

then edit the PHP configuration file php.ini and uncomment the following line by taking out the semicolon (;).
Change this line:

;extension=mysql.so

To look like this:

extension=mysql.so

Now just restart Apache and you are all set!

sudo /etc/init.d/apache2 restart

Installing PHPMyAdmin

One of the easiest ways to manage your new MySQL database server is to use the graphical tool PHPMyAdmin.
Simply go to your terminal again and enter the following command:

sudo apt-get install phpmyadmin libapache2-mod-auth-mysql

The phpmyadmin configuration file will be installed in: /etc/phpmyadmin
Now you will have to edit the apache config file by typing :

gksudo gedit  /etc/apache2/apache2.conf

and include the following line:

Include /etc/phpmyadmin/apache.conf

Restart Apache :

sudo /etc/init.d/apache2 restart

Now just point your browser at http://localhost/phpmyadmin/.

Installing some useful modules in PHP

If you have installed xampp for Linux you will see that by default they are already some modules installed for you . But unfortunately for the default lamp stack in Ubuntu it’s not, so let’s install those common used modules in php like gd,pear,curl,memcache,xmlrpc,xsl…

sudo apt-get install php5-dev php5-gd php-pear php5-curl php5-memcache php5-xmlrpc php5-xsl  php5-imagick php5-mcrypt php5-mhash

Restart Apache

sudo /etc/init.d/apache2 restart

Next Page »