Linux News|Linux Install sidebyside windows|Ubuntu|Linux Help|Installing Apache and php from source

Thursday, August 30, 2012

Converting CHM to PDF in Linux

CHM files, known as Microsoft Compressed HTML Help files, are a common format for eBooks and online documentation. They are basically a collection of HTML files stored in a compressed archive with the added benefit of an index.

Under Linux, you can view a CHM file with the xchm viewer. But sometimes that is not enough. Suppose you want to edit, republish, or convert the CHM file into another format such as the Plucker eBook format for viewing on your Palm. To do so, you first need to extract the original HTML files from the CHM archive.
This can be done with the CHMLIB (CHM library) and its included helper application extract_chmLib.
In Debian or Ubuntu:

$ sudo apt-get install libchm-bin
$ extract_chmLib book.chm outdir
where book.chm is the path to your CHM file and outdir is a new directory that will be created to contain the HTML extracted from the CHM file. In other Linuxes, you can install it from source. First download the libchm source archive from the above website. I could not get the extract_chmLib utility to compile under the latest version 0.38, so I used version 0.35 instead.

$ tar xzf chmlib-0.35.tgz
$ cd chmlib-0.35/
$ ./configure
$ make
$ make install
$ make
After doing the 'make examples', you will have an executable extract_chmLib in your current directory. Here is an example of running the command with no arguments and the output it produces:
$ ./extract_chmLib                    usage: ./extract_chmLib 
After running the utility to extract the HTML files from your CHM file, the extracted files will appear in . There would not be an 'index.html' file, unfortunately. So you will have to inspect the filenames and/or their contents to find the appropriate main page or Table of Contents.
Now the HTML is yours to enjoy!

   I have learnt this from lots of available sites and main reference I have given below.

References:http://madphilosopher.ca/2006/09/how-to-convert-chm-files-under-linux/

Monday, March 5, 2012

Install_flash_player_11_linux.x86_32.tar.gz,Install_flash_player_11_linux.x86_64.tar.gz in 64/32 bit in ubuntu/linux for firefox|Installing Adobe Flash Player in 32 and 64 bi ubuntu/linux for firefox|Installing latest version of Adobe Flash Player in ubuntu for firefox|Install latest Flash Player in ubuntu/linux for firefox|Installing Adobe flash player from source file for firefox.

To install flash player in ubuntu through source file is much easier as installing from binary file. when this post was written there was no debian file available for the current version of flash player although rpm package is available but no debian package available. Usually now flash player is coming as shared library which you have to put in a specified location and firefox and other browser will pick it automatically as follows. Download the source file for your machine from "here".

Now follow these steps:
Step 1:  Using the tar utility extract the file or right click on the file and extract the file.
Step 2:   Copy the file with ".so" extension to ".mozilla/plugins" directory which is in your home directory. Here ".mozilla" will be hidden in your home directory.If there is no "plugins" folder then create and copy that file in that folder and restart the firefox.

Tuesday, February 14, 2012

Installing firefox-10.0.1.tar.bz2 in ubuntu 10.04/Linux|Installing firefox in linux|Installing latest version of firefox in linux/ubuntu|Installing firefox in ubuntu/linux

Installing firefox is much easier as it is available precompiled archived in .tar.bz2,you don't have to compile and then install it,you just have to download and extract it and run the executable file named as firefox and firefox will be opened for you. Below I have given a simple method to install the latest version of firefox in linux as follows:

1. Download the firefox from http://www.mozilla.org/en-US/firefox/fx.

2. Extract the file using terminal by typing command [tar -xvjf firefox-10.0.1.tar.bz2]. This will extract the contents in the current directory.

3. First method:Now right click on desktop and click on create a launcher and fill the 'type' as 'application',fill in the name as you want,In the command text box browse the path to the firefox file which is in the extracted file and then click on 'ok'. Now click on firefox and your firefox will launch.
     
   Second Method:  Reach to the firefox-10.0.1 directory which is made after
extracting and then type in terminal[./firefox]. This will launch firefox from current directory.
 



Wednesday, February 8, 2012

How to install .bin file in ubuntu linux using terminal

Most of the developments kit are archived in .bin format which are ready to install binary files you just have to make them executable and your OS will interpret them. For example Real player/Adobe reader/Java is available in .bin format.To install proper .bin files proceed as follows and we are assuming the file name as file.bin:
1. Copy the file to Desktop.

2. Open the terminal and reach to desktop as follows:
    [cd Desktop]

3. Make the file executable using chmod,for more details use [man chmod]
    [sudo chmod +x file.bin].

4. [./file.bin]
5. Follow the instructions displayed on terminal.


Installing debian files in ubuntu 10.04|Saving debian files while installing software/packages in ubuntu|Installing vlc in ubuntu

For new users installing software in ubuntu is cumbersome as downloading your softwares again after every fresh installation is annoying here is a solution for you if you have installed ubuntu and you want to store the softwares as you do in windows for future use.

When you install any package in ubuntu using apt-get install it first get downloaded in the cache located in /var/cache/apt/archives. Here all the debian files which are required by your software are downloaded first or you can say all the dependencies related to your software are stored here and as the downloaded finishes dpkg which is debian package manager installs the debian files using the files in current directory.So if you have debian files stored some where you can manually install your software,so our target here is to store debian files as we install any software so that we can manually install it in future if required.


Take an example suppose we are installing vlc media player,do as follows:
1. Clean the cache
[sudo apt-get clean]

2. Install vlc
[sudo apt-get install vlc]

3. Save the debian files related to vlc to some directory ,here I am using /home/tarun/vlc,you can choose any directory.
[cp  /var/cache/apt/archives/*.deb   /home/tarun/vlc]

4. Now to reinstall vlc on some other machine having the same OS,copy the files to some place on the harddisk and reach to that directory using cd command.
[cd vlc]       //here you have to reach the vlc directory no matter where you have placed it
Now install vlc as follows:
[sudo dpkg -i *.deb]

Tuesday, February 7, 2012

Graphics.h in Linux for C and C++|Graphics.h in ubuntu|graphics.h in Linux


Graphics.h in Linux for C and C++

Most of the students in Windows use graphics.h header file in there programs that are written in Borland TurboC. This is a reason that some don’t wanna migrate to Linux well there is a solution for that to. Just follow the steps that i did in Linux/ubuntu.

First install the gcc and g++ compiler by running sudo apt-get build-essential to install necessary compiler tools.

Then, install the following packages:
libsdl-image1.2
libsdl-image1.2-dev
guile-1.8
guile-1.8-dev
libsdl1.2debian-arts
libartsc0-dev
libaudiofile-dev
libesd0-dev
libdirectfb-dev
libdirectfb-extra
libfreetype6-dev
libxext-dev
x11proto-xext-dev
libfreetype6(upgrade)
libaa1
libaa1-dev
libslang2-dev
libasound2
libasound-dev

We can install them via Synaptic Package Manager(System->Administration->Synaptic Package Manager) one by one or you can type the following command in the terminal :
sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev libsdl1.2debian-arts libartsc0-dev libaudiofile-dev libesd0-dev libdirectfb-dev libdirectfb-extra libfreetype6-dev libxext-dev x11proto-xext-dev libfreetype6(upgrade) libaa1 libaa1-dev libslang2-dev libasound2 libasound-dev

After this download libgraph-1.0.1 to your Home Folder.
Right click on it and press “Extract here”
Now type in the terminal
./configure
sudo make
sudo make install

This completes the installation.
You can compile your program like this:
g++ test.cpp -o test.o -lgraph
And execute the program by ./test.o

If on compile it gives u an error that says “could not load shared libraries” or something like that just run the following command and it should fix it
sudo cp /usr/local/lib/libgraph.* /usr/lib

An example program(to print a rectangle) :
#include
#include

int main(void)
{
int gd=DETECT, gm=VGAMAX;
initgraph(&gd, &gm, 0);
//moveto(0, 0);
rectangle(50,50,500,200);
closegraph();
return 0;
}

If there are any problems please leave a comment.
You can also see videos posted by Reversehack,this is a very good and clean video you need not to read the above text if you have downloaded the video from here.

Resources: www.itsanimesh.com|http://www.youtube.com/user/ReverseHack

Installing Grub after windows swipe out grub usinglive cd and supergrub

Here we are going to discuss two methods one is recovering from live cd and other is using super grub:
First method:
Boot in your machine from live cd and run the live desktop session using try ubuntu option and do as follows.

This is a simple and quick method to restore grub from live cd.  The terminal is used for entering commands and you must know the partition in which you have installed boot i.e sda1 or sda3 or hda1 like that,if you have not made a different boot partition then you must know your root partition. Now problem starts here because some use does not know the partition name correctly.
Open a terminal by selecting Applications, Accessories, Terminal from the menu bar.
Determine the partition with the Ubuntu installation. The fdisk option "-l" is a lowercase "L". 

[Sudo fdisk -l]
 
If you are not sure of partition then look for small partition you are comfortable for formatting.
 
Now the mount the partition onto /mnt using command below as follows:
 
[sudo mount /dev/sdxn /mnt

here n is replaced by integer "1","2" or "3" etc. and x is replaced by a,b or c etc.
 
Run the grub install command as described below,this will install grub again .
 
[sudo grub-install --root-directory=/mnt   /dev/sdx]

Now reboot and everything seems to be alright.

 Second Method:
 
Super grub disk is used to repair grub and restore original MBR, so that the disk does not get damaged once the Linux partition is formatted. Super Grub can be downloaded for free and then burned to a CD to make a Super Grub disk live CD.The live CD can be used to repair grub by fixing the boot of GNU Linux. The Super Grub disk can be used to restore MBR back to Windows, if the user wishes to leave the GNU Linux OS and install Windows. Before formatting the Linux partition, the Super Grub disk live CD has to be used to restore the original MBR. 

Super Grub Disk is used to repair Grub and the MBR and reinstall on another partition. 
It can also restore the original MBR uninstalling Grub for users wishing to leave GNU/Linux, without risk of making the computer unusable after formatting the Linux partition. 



You can download Super Grub Disk at this address: 
http://download.linux-live-cd.org/Super_Grub_Disk/download/binaries/sgd/cdrom/ 



Select the file. "Iso" the most recent. 
You can also download versions for other media (USB floppy) to this page: http://www.supergrubdisk.org/ 



The Use

As mentioned above, Super Grub Disk can be used to repair grub, either restore the original MBR.
Once the image. "Iso" download, see this tutorial for burning it.


Launch of Super Grub Disk
  • Start your computer from the CD Super Grub Disk.
  • Select "Super Grub Disk" from the list and click OK. Then select the language.
  • Some details are displayed, including an explanation of the main menu in text mode, click OK to continue.



Repair Grub

Sometimes, unfortunately, we should reinstall Windows, unfortunately after installation, Windows is the only system accessible from MBR because it has been rewritten.
  • From the main menu for Super Grub Disk, select "GNU / linux".
  • Then "Fix boot of GNU/linux"
  • A message will indicate that the operation was successful; Super Grub Disk will detect your installation of Linux and reinstalled GRUB on MBR using the configuration file found.

Confirm and return to the main menu by selecting the top of each menu.

  • Choose "Restart PC" to the last screen.


Restore MBR back to Windows

You may decide to leave GNU/Linux, here's how the world of free software will help you anyway in your approach. 

Perform the following before you format the partition GNU/Linux

  • From the main menu for Super Grub Disk, select "Windows".
  • Then select "Fix Windows startup.
  • A message will warn you that rewriting MBR is not a safe operation, the same warnings are given from a recovery CD of Windows when introducing the command to the C:

fixmbr 
fixboot 

NB: 
Despite the excellent free software GNU / Linux, these manipulations are not without risk, as there is not infallible, we prefer to advise you. 
But nothing ventured, nothing gained! Let us continue ... 

to emphasize that there are alternatives to uninstall Grub/Lilo MBR HERE
  • Then select your operating system Windows in the list.
  • Then select the disk in which MBR will be restored.
  • Operations continue after validation and MBR is restored successfully.
  • Navigate to the main menu by following the top of each menu.
  • And restart your PC.


Once the operations have been completed and your computer rebooted, Grub has disappeared leaving a conventional Windows startup.

Monday, February 6, 2012

Ubuntu 10.10 review


It seems like just yesterday that Ubuntu Linux 10.04 was released, but here we are and Ubuntu 10.10 has just been released. Wow! How time flies!

There has been some controversy over this release, with some folks saying that Canonical’s six-month release cycle is too often and that there aren’t enough things in this release to warrant an upgrade.

I politely disagree with that assessment, and I’ll show you why in this review. Ubuntu 10.10 is a worthwhile though not overwhelmingly impressive release; it’s worth considering as an upgrade if you are already running an earlier version of Ubuntu. It’s also certainly worth looking at if you are new to Ubuntu and are thinking about using it as your desktop operating system.

What’s New In This Release

Here’s a sample of the new features in this release:

The GNOME base platform has been updated to the current 2.32 versions. This particularly includes the new dconf and gsettings API.

Evolution was updated to the 2.30 version, which operates much faster compared to the version in Ubuntu 10.04 LTS.

The Sound Indicator has been enhanced to include music player controls.

The boot process is cleaner and faster.

New themes, new icons, and new wallpaper bring a dramatically updated look and feel to Ubuntu.

Shotwell has replaced F-Spot as the default photo manager.

Gwibber has been updated to support the recent change in Twitter’s authentication system, as well as changing the back end storage to improve performance.

The Sound Indicator has been enhanced to include music player controls.

The Ubuntu Software Center has an updated look and feel, including the new “Featured” and “What’s New” views for showcasing applications, an improved package description view, and a “For Purchase” software category has been added. You can also now easily access your package installation history too.

Ubuntu One: Polished desktop integration with new sign up and sign in process. Tighter integration with Ubuntu SSO. Nautilus enhancements for managing folder sync preferences. Faster file sync speed. Share links to music within the Ubuntu One Music Store.

I’m happy to see the update to GNOME 2.32. It goes beyond the scope of this review to delve into changes to GNOME in 2.32.

I’m glad that Gwibber has been changed to match Twitter’s new authentication system. If you use Gwibber you shouldn’t have a problem tweeting in this release.

The speed increase to Evolution is certainly a welcome development in this release of Ubuntu. These days I generally prefer webmail to local email, but I know a lot of people who still use Evolution. So it’s good to see a significant performance increase available for Evolution users.

Shotwell is arguably better than F-Spot as a photo manager. I can’t say that I’m wowed by either of them, but I don’t do a lot with photos so that’s probably why. I suspect we’ll hear some moaning and groaning from F-Spot fans about this decision though. Not to worry, you can get F-Spot in the Ubuntu Software Center so it’s still available.

This is just the basic overview,overall there are lot of changes have been done under the cover.

Ubuntu 11.04 review

Canonical has made great strides with its Ubuntu operating system in just a few years, more than other developers have made in a decade. Mark Shuttleworth, founder of the Ubuntu distribution, is known for his risk taking nature and Ubuntu 11.04 is evidence of that attitude.



Natty Narwhal has been promoted as a groundbreaking Linux distribution, especially regarding the new and almost unique interface, called Unity. It's still unclear if Canonical has managed to pull it off, as there is major resistance in the open source community towards embracing Unity and all its features, but we hope to shed some light on the new and improved Ubuntu 11.04 OS and sway people in a direction or another.


Ubuntu 11.04 (Natty Narwhal) has passed through the usual steps before reaching a stable version (3 Alphas and 2 Betas), but respecting the allotted schedule which practically states that a new version of Ubuntu surfaces once every six months.


First impressions
Lets assume that most users don't actually install alpha and beta distributions. What's the impact of a new interface, radically different from anything that has been done before, on the user's ability to maneuver and successfully comprehend what the developers have actually intended?


The first minute of contact with the new Unity environment is one of wonder and appreciation. Unfortunately, we now live in a time when people don't want to learn new stuff in order to use an operating system or a new program. That is precisely the reason why Linux, Microsoft and Apple developers don't make big jumps in terms of design and functionality, as they don't want to alienate people from their operating systems.


Unity


For some users, Unity is too big of a leap. Canonical has decided to scrap the conventional two-panel look and replace it with a lateral dock menu, which so far is stuck on the left side of the screen (sorry left-handed users). Unity can be shrunk and most of the icons can be moved or deleted, but some of them are fixed and, for now, can't be interfered with.












Right about now, Ubuntu users are probably grinding their teeth if they want to use Unity or not, thinking they can never accept an interface which is not as flexible as the old one. I promise, it has a lot of good features and even if we don't want to admit it, this is the future.


Some call it an omission and others call it negligence, but the feature that is most missed in Unity is the ability to group icons by category, like Internet, Office, Audio and Video and so on.


We don't want to be picky, but we have to mention that there are two icons on the bottom of the dock, that seem to have the purpose of gathering all the software installed in the system, in one single place. They are cumbersome and most likely will get redesigned in the near future or with Ubuntu 11.10.


Other changes
The biggest change, except Unity, is, of course, the introduction of the LibreOffice office suite, instead of outdated OpenOffice.org. This is a really good choice, LibreOffice being a lot lighter in memory usage and a lot prettier. It's still using the ODT format so there's no need to worry that your old documents and other projects from OpenOffice.org won't work.


Another significant change is the replacement of the old music player, Rhythmbox, with Banshee. I can't say it's much of a difference as they look very similar, but apparently it's a lot more stable. Even if it's written in GTK# and Mono, it integrates really well with the new menubar so users will have an easy time using it.


Lots of other software packages received smaller changes, but the last one worth mentioning are the new overlay scrollbars. Nautilus now uses a new set of scrollbars which are smaller and placed outside of the actual window. When the mouse gets close to where the scrollbar should be, they change their size and become draggable. It's a nice touch and it makes you wonder why this hasn't been done before. The environment looks a lot cleaner and spacious this way.


Conclusion


It's really hard to draw a line and take a firm stand, saying it's either good or bad. As we see it, Ubuntu 11.04, including Unity, is a major step forward. We would like nothing more than Canonical to use all the criticism and improve this amazing interface.


As we said in the beginning of the review, people have a hard time adjusting to major changes, but Unity is more than a change in perspective. It will be the new face of Ubuntu, and, like all major stars, it will endure some corrective surgery to make it more appealing to the broader masses.


It may seem odd to complain about tons of problems with the new interface and in the same time make a recommendation in favor of that interface, but the bottom line is that we liked Unity, with all its issues, and we hope that it will improve and finally move forward beyond what is most likely the last remaining bastion of a bygone era.


Ubuntu can only keep itself on the edge and in competition if it improves and changes faster than users expect. Change drives the innovation and Canonical has proved, with Unity, that they can compete in the next decade with all the major players in the world, when it comes to great operating systems.

Sunday, January 8, 2012

What is the difference between static RAM and dynamic RAM?


Your computer probably uses both static RAM and dynamic RAM at the same time, but it uses them for different reasons because of the cost difference between the two types. If you understand how dynamic RAM and static RAM chips work inside, it is easy to see why the cost difference is there,­ and you can also understand the names.
Dynamic RAM is the most common type of memory in use today. Inside a dynamic RAM chip, each memory cell holds one bit of information and is made up of two parts: a transistor and a capacitor. These are, of course, extremely small transistors and capacitors so that millions of them can fit on a single memory chip. The capacitor holds the bit of information -- a 0 or a 1 . The transistor acts as a switch that lets the control circuitry on the memory chip read the capacitor or change its state.
A capacitor is like a small bucket that is able to store electrons. To store a 1 in the memory cell, the bucket is filled with electrons. To store a 0, it is emptied. The problem with the capacitor's bucket is that it has a leak. In a matter of a few milliseconds a full bucket becomes empty. Therefore, for dynamic memory to work, either the CPU or the memory controller has to come along and recharge all of the capacitors holding a 1 before they discharge. To do this, the memory controller reads the memory and then writes it right back. This refresh operation happens automatically thousands of times per second.


A capacitor stores electrons in computer memory cells. The memory must then be refreshed or flip-flopped.
                                                             
This refresh operation is where dynamic RAM gets its name. Dynamic RAM has to be dynamically refreshed all of the time or it forgets what it is holding. The downside of all of this refreshing is that it takes time and slows down the memory.
Static RAM uses a completely different technology. In static RAM, a form of flip-flop holds each bit of memory . A flip-flop for a memory cell takes 4 or 6 transistors along with some wiring, but never has to be refreshed. This makes static RAM significantly faster than dynamic RAM. However, because it has more parts, a static memory cell takes a lot more space on a chip than a dynamic memory cell. Therefore you get less memory per chip, and that makes static RAM a lot more expensive.
So static RAM is fast and expensive, and dynamic RAM is less expensive and slower. Therefore static RAM is used to create the CPU's speed-sensitive cache, while dynamic RAM forms the larger system RAM space.


What is the BIOS or CMOS setup program?

The motherboard BIOS, which is short for Basic Input/Output System. PCs typically have what is called a flash BIOS, allowing the user to update the BIOS if necessary. The BIOS also includes a sort of diagnostic routine known as the POST (Power On Self Test). This test ensures that the computer meets the necessary requirements to boot up correctly. If the computer doesn't pass the POST you will hear a pattern of beeps that indicate the problem encountered.
CMOS (Complementary Metal Oxide Semiconductor) is the type of semiconductor chip on the motherboard which stores the system information and computer settings such as date, time, hard drive settings, boot sequence, parallel port settings, on-board audio & video, etc. This information can be accessed and changed through the BIOS/CMOS setup program which is available as the computer begins to boot up. As the computer boots, there will typically be some text on the screen such as "Press Del to enter Setup". Depending on the manufacturer, the key required to enter the BIOS setup may be F1, F2, Del, or Esc.Unlike earlier generations of PC's, the user is no longer required to go into the BIOS Setup and enter new information such as the number of cylinders, heads, sectors, etc. when changing IDE hard drives. These and many other settings are now detected automatically.

Note: If the CMOS battery dies, any changes made in the the BIOS Setup will be lost. After replacing the battery, the user will need to re-enter the Setup program and make the changes again

Friday, January 6, 2012

Running a C/C++ program in ubuntu


First check for the compiler installation as follows on your terminal:
[g++ --version]
if it gives the version of your compiler then run the programs as given below other wise just go through this tutorial:
Installing C/C++ compiler in Ubuntu


Running a c++ program


#include<iostream>
using namespace std;
int main()
{
cout<<"Hello world"<<endl;
}

Save it as first.cpp on your desktop.
Open the terminal and do as follows.
[g++ Desktop/first.cpp -o Desktop/first.o]
                                                         ^
                                                      first.o will be created if no error occurs
[cd Desktop]
[./first.o]

Running a C program


#include<stdio.h>
//using namespace std;
int main()
{
printf("Hello world\n");
}


Save it as second.c on your Desktop.

[g++ Desktop/second.c -o Desktop/second.o]
[cd Desktop]
[./second.o]

Here you can use gcc or g++ as g++ supports both.

If you have any question then write down the comments,I will be pleased to help you.

Removing Broken packges through command line in Ubuntu

Some times broken packages creates problem in installing new software so do the following step to remove the broken packages,some times some packages can't be removed they are upgraded so you need internet connection at that time so make sure that you have internet connection available:

[sudo apt-get clean]

[sudo apt-get install -f]

If you any questions regarding apt-get utility then do as follows:

[man apt-get]

Installing C/C++ compiler in Ubuntu|c++ package download for ubuntu linux|Running C/C++ program in ubuntu/linux

In this article I will be showing the way to install C/C++ compiler in ubuntu ,I am using ubuntu 10.04.
By the way it is same for all ubuntu distribution as far as I am concern. There are two things you will learn here,First is to install compiler and second is saving downloaded files so that if you install ubuntu again you don't need to download again all debian files.
Installing C/C++ compiler in Ubuntu|c++ package download for ubuntu linux|Running C/C++ program in ubuntu/linux
In debian distribution such as ubuntu is there are some binary packages with .deb as extension which are dependent on some other packages which are also with .deb extension. The compiler we will be installing is gcc for c and g++ for c++,g++ supports both c and c++.
First make sure that you should have internet connection on your machine.

Open the terminal by going through Applications->Accessories->Terminal.

Step 1: Update your machine as follows:
[sudo apt-get update]

Skip this step if you have already updated.

Step 2: Clean the cache
[sudo apt-get clean]

Step 3: Install the build-essential package which contains gcc(Gcc compiler collection) ,make utility and other utilities for installing the software from source,if you don't know about installing software from source then don't worrry you will learn by experience.

[sudo apt-get install build-essential]

Step 4: After installing copy the downloaded files so that you don't have to go through these downloads again as follows:
Make a directory on desktop named as build-essential as follows:
If you are in home directory which is shown by '~' sign in your terminal as

[tarun@chawla:~$]
                          ^
                           This shows your current location in the / directory

If you are not in your home directory then do as follows:
[cd ~]
[mkdir Desktop/build-essential]
[cp  /var/cache/apt/archives/*.deb  Desktop/build-essential]
[sudo apt-get clean]

Now suppose you have installed ubuntu again on your computer and you need to install compiler again and you have stored build-essential directory that you have made above safe at some place then proceed as follows:

copy the build-essential directory on your Desktop and open the terminal ,reach to the home directory and do the following steps:

[sudo dpkg -i  Desktop/build-essential/*.deb]
In the above case I have stored and installed form Desktop and if you want to install and store at any other place then change the path accordingly.
Now you have installed compiler within seconds.
Running a c++ program


#include<iostream>
using namespace std;
int main()
{
cout<<"Hello world"<<endl;
}

Save it as first.cpp on your desktop.
Open the terminal and do as follows.
[g++ Desktop/first.cpp -o Desktop/first.o]
                                                         ^
                                                      first.o will be created if no error occurs
[cd Desktop]
[./first.o]

Running a C program


#include<stdio.h>
//using namespace std;
int main()
{
printf("Hello world\n");
}


Save it as second.c on your Desktop.

[g++ Desktop/second.c -o Desktop/second.o]
[cd Desktop]
[./second.o]

Here you can use gcc or g++ as g++ supports both.

enjoy the day bhai......
If you have any question then write down the comments,I will be pleased to help you.

Wednesday, January 4, 2012

Installing Apache and Php from source in Linux


In this article you will learn how to install Apache and Php from source.If you are installing from binary files whether it is rpm or debian based then everything will be installed by default and you don't have to worry about inner details but if you are new to php and apache and I am assuming so,you should know some working details before going into programming. When I write this post I did not have any experience in php programming but I have installed php and apache from source but it has taken time. So I am here to solve your problem and give some details regarding inner working.So lets start to setup environment for php programming----

Installing Apache from source in any linux distribution:

I am using ubuntu 10.04(Lucid) for all compilation and installing in this tutorial. Before installing from source make sure that all tools required for installing is already installed on your linux system such as gcc compiler,make utility because all these tools are needed for installation from source.
I am using httpd-2.2.17.tar.gz ,extract it to the desired location and open the terminal and reach that location where you have extracted the httpd file.
Before proceeding further make a directory it is your installation directory where you will install apache,I am using "/home/tarun/apache" where all installed files will be stored.
After extracting a folder "httpd-2.2.17" will be made. Enter this folder using terminal.
Now follow these steps:

[] is used to differentiate commands from strings
Step 1:
[./configure --prefix="/home/tarun/apache" --enable-so] and press enter.
Here prefix option redirects the installation to your directory and second option enables shared library which I don't know as I am like you,we will learn as we will go on.
Other option are also available and to view them use command as [./configure --help].

Step 2:
If everythings goes fine without any error then proceed:
[make && make install]
if  your have read and write permission of your installation directory then you don't need to have root permission using sudo but if you don't have permission then use sudo before commands.Here I am assuming that you have some basic experience of any Linux OS.

Now check the folder now it contains files and folders.
Before moving further edit the httpd.conf file located in /home/tarun/apache/conf as follows:
Search for User & Group and set user to your name and group to your group.


Checking Apache installation:

Start the apache using this command and here you will need root permissions so use sudo as follows:
[sudo /home/tarun/apache/bin/apachectl start] and press enter Now open your browser and run http://localhost this will open by default html file for your server and will show positive results if installed correctly. By positive result means that the default html file is run correctly as default file may differ from one version to another. In my case default file shows "It Works" string if installed correctly.

Stop the server using command below:
[sudo /home/tarun/apache/bin/apachectl stop]



Php Installation in any Linux distribution from source:

Make a folder in your previous installation directory which will now be installtion directory for php and for this I am using "/home/tarun/apache/php".
As php is build to talk to many products and distribution so there are lots of option provided as in apache but here we will only configure those option which are sufficient for running php on your machine. So before going further extract the tar file on some location and reach to that php directory from terminal. Here I am using php-5.3.4.
So reach to php-5.3.4 in terminal where you have placed it and make sure you have reqired permission or you can use sudo to fulfill that.

Step 1:
[./configure --help] This will list the options available with php.

Step 2:
[./configure --with-apxs2=/home/tarun/apache/bin/apxs --prefix=/home/tarun/apache/php]
Here first option is for apache extension support for version 2,as previously said we will learn with use and second option directs the installation to specified directory.
If there is error regarding libxml2 then install the libxml library which is used to parse xml files as follows:

[sudo apt-get install libxml2-dev]

Step 3:
[make && make install]
Again I am specifying you should have permissions or other wise use sudo .

Now you have to edit certain text files so as to configure php as follows:
Now there are certain ini files in your php-5.3.4 which is source folder of php from where you have configured & installed php using configure and make commands and from which that particular ini file is to be copied to /usr/local/lib and rename it as php.ini.
[ls -l php*] will list files starting with php as follows:

-rw-r--r-- 1 tarun tarun  1489 2011-12-30 00:10 php5.spec
-rw-r----- 1 tarun tarun  1489 2007-09-26 21:14 php5.spec.in
-rw-r----- 1 tarun tarun  2523 2006-03-07 00:40 php.gif
-rw-r----- 1 tarun tarun 68760 2010-12-08 05:23 php.ini-development
-rw-r----- 1 tarun tarun 68990 2010-12-08 05:23 php.ini-production

Here we are interested in php.ini-development file and copy it to /usr/local/lib and rename it to as php.ini
Edit this file with the editor you want whether you are using gedit or nano or vim but the condition is that you should know how it works.[gedit php.ini] after reaching /usr/local/lib.
So search for "include" in that file until you find something like this:

Before Modification-----------

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
;
; PHP's default setting for include_path is ".;/path/to/php/pear"
; http://php.net/include-path

Here lines starting with ; are comments,so according to our requirement we will add this line as follows:

After Modification-----------

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
#Modified by Tarun_Chawla on 4 jan 2012
include _path ="/home/tarun/apache/php"
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
;
; PHP's default setting for include_path is ".;/path/to/php/pear"
; http://php.net/include-path

Now edit some apache files,move to /home/tarun/apache/conf/ and edit the httpd.conf in this directory.
[gedit httpd.conf]
Search for "php" until you find this line as follows:

# LoadModule foo_module modules/mod_foo.so
LoadModule php5_module        modules/libphp5.so
#

And modify it to :

# LoadModule foo_module modules/mod_foo.so
LoadModule php5_module        /home/tarun/apache/modules/libphp5.so
LoadModule php5_module        modules/libphp5.so
#

Now search for "AddType" until you see this as follows:

# AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
 
And modify it as follows so that apache recognizes .php and .phps as php files,.phps file when opened with apache will open php source file without compiling this will used for debugging purposes and .php files will be treated as php files and php will interpret them as required.

# AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
     Addtype application/x-httpd-php .php 
     Addtype application/x-httpd-php-source .phps
    #

There is another section you will have to look through,search for "index" in httpd.conf until you find these lines which follow as:

</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

After Modification:

</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

This is done so when your computer is accessed remotely as a server index.html or index.php will serve them according to the order in which you have written the names.
Now save the files and exit.

Start the apache server as:
[sudo /home/tarun/apache/bin/apachectl start] or restart if it is already running as [sudo /home/tarun/apache/bin/apachectl restart].

Now check your server which ready with php support as follows:

make a text file as hello.php in so path will be like this /home/tarun/apache/htdocs/hello.php and paste the following code below in it :

<html>
<head>
<title>
This is our first php script</title>
</head>
<body>
<?php 
phpinfo();
?>  

</body>

</html>

Now go to your browser and run http://localhost/hello.php
It will show the details regarding php installation and version.

If any problem persists write down here I will be pleased to help you.
ubuntuway.blogspot.com