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

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