Friday, December 24, 2010

Features of Linux OS

LINUX:
  • Linux Kernel or Linux is an operating system kernel used by a family of Unix-like operating systems.  
  • Linux distribution is used to refer to various operating systems built on top of Linux Kernel.
  • The Linux kernel is released under the GNU General Public License version 2 (GPLv2) and developed by contributors worldwide.
  • Linux is one of the most prominent examples of Free / Open Source software.

How Linux Load while switch on the system:
System on
|
BIOS(Boot Strap)
|
Boot Loader(Grub)
|
O/S Operates
|
I/O & Other peripherals

Difference Between Closed and Open Source Softwares:





Linux Operating System Parts :
  1. Kernal
  2. Shell
  3. File Structure
  4. Utilities
1. Kernel:
  • Kernel is Central component of computer operating systems (OS). 
  • Its responsibilities include managing system's resources (communication between hardware and software components). 
  • Kernel -->Monolithic in Linux--> Core part of OS. It controls all part such as H/W and  S/W.
Monolithic:
  • Heavily loaded to control all operations
  • Complex and difficult to maintain.
Micro Kernel:
  • Micro Kernel has only basic functionalities
  • Additional components will handle remaining tools.
  • Easy to maintain

2. Shell:
  • A shell is a Command Interpreter and it provides an interface for user. It receives ommand from user, then interprets and sends commands to kernal for execution.
3. File Structure:
  • In Linux file structure files are grouped according to purpose. 
  • For ex: commands, data files, documentation. 
  • This file structure organizes way of files are stored in a storage device such as   disks and printers. 
  • All directories are grouped under root entry " / "
The Directories under Root are listed below:
root  -- The home directory for the root user
home -- Contains the user's home directories along with directories for services
  1. FTP
  2. HTTP
  3. Samba
  4. George
bin -- Commands needed during bootup that might be needed by normal users. Almost all user commands are in /bin or /usr/local/bin.
sbin -- Like bin but commands are not intended for normal users. Commands run by LINUX.
proc -- This filesystem is not on a disk. It is a virtual filesystem that exists in the kernels imagination which is memory. A directory with info about process number . Each process has a directory below proc.
usr -- Contains all commands, libraries, man pages, games and static files for normal operation.
include -- Header files for the C programming language. Should be below /user/lib for consistency.
lib -- Shared libraries needed by the programs on the root filesystem. Unchanging data files for programs and subsystems.
X11R6 -- The X windows system files. There is a directory similar to usr below this directory.
X386 -- Like X11R6 but for X11 release 5
boot -- Files used by the bootstrap loader, LILO. Kernel images are often kept here.
modules -- Loadable kernel modules, especially those needed to boot the system after disasters.
man -- Manual pages
info -- Info documents
doc -- Documentation  
dev -- Device files
etc -- Configuration files specific to the machine.
skel -- When a home directory is created it is initialized with files from this directory
sysconfig -- Files that configure the linux system for devices.
var -- Contains files that change for mail, news, printers log files, man pages, temp files
file
local -- The place for locally installed software and other files or Variable data for programs installed in /usr/local.
lock -- Lock files. Used by a program to indicate it is using a particular device or file
log -- Log files from programs such as login and syslog which logs all logins and logouts.
run -- Files that contain information about the system that is valid until the system is next booted
spool -- Directories for mail, printer spools, news and other spooled work.
tmp -- Temporary files. Programs running after bootup should use /var/tmp.
catman -- A cache for man pages that are formatted on demand
mnt -- Mount points for temporary mounts by the system administrator.

4. Utilities:
  • These are specialized programs such as editors, compilers, and communication programs that performs standard computing operations.

 

Thursday, December 23, 2010

PostgreSQL Connection with PHP

How to connect PostgreSQL with PHP:
  • All of the standard PostgreSQL connection parameters are available in the connection string. The most commonly used options and their meanings are listed below:
    * Dbname: Database to connect to (Default: $PGDATABASE)
    * User: User name to use when connecting (Default: $PGUSER)
    * password: Password for the specified user (Default: $PGPASSWORD or none)
    * Host: Name of the server to connect to (Default: $PGHOST or localhost)
    * hostaddr: IP address of the server to connect to (Default: $PGHOSTADDR)
    * Port: TCP/IP port to connect to on the server (Default: $PGPORT or 5432)

$db_handle1 = pg_connect("dbname=database1");
$db_handle2 = pg_connect("dbname=database2");
  • PHP provides a number of simple functions for retrieving information on the current database connection based on the connection handle provided. Such functions include:
    * pg_dbname() -- Returns the name of the current database
    * pg_host() -- Returns the hostname associated with the current connection
    * pg_options() -- Returns the options associated with the current connection
    * pg_port() -- Returns the port number of the current connection
    * pg_tty() -- Returns the TTY name associated with the current connection

PostgreSQL Functions to retrieve information from Database:

1. pg_fetch_all:
            $result = pg_exec("SELECT * from expense_master");
            $print0=pg_fetch_all($result);
            echo "<br><br>";print_r($print0);
output:
            Array ( [0] => Array ( [exp_id] => 4 [exp_desc] => Rent [exp_code] => re04 ) [1] => Array             ( [exp_id] => 5 [exp_desc] => Electricity [exp_code] => eb05 ) )

2. pg_fetch_array:
            $result = pg_exec("SELECT * from expense_master");
            $print1=pg_fetch_array($result,0);    // OR  $print1=pg_fetch_array($result);
            echo "<br><br>";print_r($print1);
output:
            Array ( [0] => 4 [exp_id] => 4 [1] => Rent [exp_desc] => Rent [2] => re04 [exp_code]=> re04 ) 

3. pg_fetch_assoc:
            $result = pg_exec("SELECT * from expense_master");
            $print2=pg_fetch_assoc($result,0);
            echo "<br><br>";print_r($print2);
output:
            Array ( [exp_id] => 4 [exp_desc] => Rent [exp_code] => re04 )

4. pg_fetch_object:
            $result = pg_exec("SELECT * from expense_master");
            $print3=pg_fetch_object($result,1);
            echo "<br><br>";print_r($print3);
output:
            stdClass Object ( [exp_id] => 5 [exp_desc] => Electricity [exp_code] => eb05 )

5. pg_fetch_result:
            $result = pg_exec("SELECT * from expense_master");  
            $print4=pg_fetch_result($result,0,1);
            echo "<br><br>";print_r($print4);
output:
            Rent

6. pg_fetch_row:
            $result = pg_exec("SELECT * from expense_master");
            $print5=pg_fetch_row($result,1);
            echo "<br><br>";print_r($print5);
output:
            Array ( [0] => 5 [1] => Electricity [2] => eb05 )

7. pg_fetch_all_columns:
            $result = pg_exec("SELECT * from expense_master");
            $print6=pg_fetch_all_columns($result,1);
            echo "<br><br>";print_r($print6);
output:
            Array ( [0] => Rent [1] => Electricity )

PHP Program to connect PostgreSQL:

Note : Red Color fonts denotes the Function Name
 
 <?php
$username = "madumeena";
$password = "meena123";
$hostname = "localhost";
$dbname = "testingdb";

// Connecting to database
$link = pg_connect("dbname=$dbname user=$username password=$password");

if ($link)
            {
            echo 'Connection attempt succeeded.';
            }
else
            {
            echo 'Connection attempt failed.';
            }

// Performing SQL query
pg_exec("SET SEARCH_PATH TO _100123");
$result = pg_exec("SELECT * from expense_master");

$print0=pg_fetch_all($result);
$print1=pg_fetch_array($result,0);
$print2=pg_fetch_assoc($result,0);
$print3=pg_fetch_object($result,1);
$print4=pg_fetch_result($result,0,1);
$print5=pg_fetch_row($result,0);
$print6=pg_fetch_all_columns($result,1);

// Print the output
echo "<br><br>";print_r($print0);
echo "<br><br>";print_r($print1);
echo "<br><br>";print_r($print2);
echo "<br><br>";print_r($print3);
echo "<br><br>";print_r($print4);
echo "<br><br>";print_r($print5);
echo "<br><br>";print_r($print6);

// Print whole table of expense_master in tabular format 
echo "<table border=1 align=center>";
echo "<thead>";
echo "<th> Expense ID </th>";
echo "<th> Expense Description </th>";
echo "<th> Expense Code </th>";

if (pg_num_rows($result) != 0)
            {
            while ($row = pg_fetch_array($result))
                        {
                        echo "<tr>";
                        echo "<td>".$row['exp_id']."</td>";
                        echo "<td>".$row['exp_desc']."</td>";
                        echo "<td>".$row['exp_code']."</td>";
                        echo "</tr>";
                        }
            }
echo "</table>";

// Print the Connection Information
echo "<h2>Connection Information</h2>";
echo "Database name:" . pg_dbname($link) . "<br>\n";
echo "Hostname: " . pg_host($link) . "<br>\n";
echo "Options: " . pg_options($link) . "<br>\n";
echo "Port: " . pg_port($link) . "<br>\n";
echo "TTY name: " . pg_tty($link) . "<br>\n";

// Closing connection
pg_close($link);
?>

Wednesday, December 22, 2010

Learn About XAJAX

About XJAX:
  • XAJAX is an open source PHP class library implementation of AJAX that allows developers to create web-based Ajax applications using HTML, CSS, JavaScript, and PHP. 
  • Applications developed with xajax can asynchronously call server-side PHP functions and update content without reloading the page. 
  • Unlike some other Ajax frameworks, Xajax is designed to allow the programmer to have no prior knowledge of JavaScript.
  • The xajax PHP object generates JavaScript wrapper functions for the PHP functions you want to be able to call asynchronously from our application. 
  • When called, these wrapper functions use JavaScript’s XMLHttpRequest object to asynchronously communicate with the xajax object on the server which calls the corresponding PHP functions. 
  • Upon completion, an xajax XML response is returned from the PHP functions, which xajax passes back to the application. 
  • The XML response contains instructions and data that are parsed by xajax’s JavaScript message pump and used to update the content of our application.
System Requirements:
  • Server-side xajax runs on any PHP 4.3.x and PHP 5.x Apache or IIS server.
  • Client-side xajax runs on (but is not limited to) Internet Explorer 6+, Firefox, Opera 8.0+, Safari 3.0.
Limitations of xajax:
  • Currently, xajax has no way to transfer data from client to server other than using XML. 
  • There are plans to change xajax to allow programmers to use JSON or any other means of communication.
  • Workaround is to use serialize function of PHP and unserialize function from php.js namespaced Javascript PHP port.
  • It is possible to send JSON using:
               <?php  $response->script('example ='.json_encode($example)); ?>
Using XAJAX in a PHP Script:
xajax is designed to be extremely easy to implement in both existing web applications as well as new projects. We can add the power of xajax to nearly any PHP script in seven easy steps: 

Step 1: Include the xajax class library, We always have to include this xajax class library.
             require_once("xajax_core/xajax.inc.php");
Step 2: Instantiate the xajax object. This objects handles all xajax processing.
             $xajax = new xajax();
Step 3: Register the names of the PHP functions, that we want to be able to call through xajax objects.
$xajax->registerFunction("makeBold");
 Step 4: Write the PHP functions we have already registered, and use the xajaxResponse object to return XML commands from them
function makeBold($p_sArg)
{
    // Just apply bold font for $p_SArg value and
    // put it into a variable like $sOut
    $sOut = '<b>'.$p_sArg.'</b>';
 
    // Instantiate the xajaxResponse object
    $objResponse = new xajaxResponse();
    
    // add a command to the response to assign the innerHTML attribute of
    // the element with id="my_element" to whatever the new content is
    $objResponse->addAssign("my_element","innerHTML", $sOut);
    
    //return the  xajaxResponse object
    return $objResponse->getXML();
} 
  • The above function takes a string argument $p_sArg and returns it within a html <b> tag. 
  • First we instantiate an xajaxResponse object which will handle the response to the client. 
  • Secondly, we assign a HTML element to update to the xajaxResponse object. 
  • The xajaxResponse->addAssign() method takes three arguments:
                         1.  The name of an HTML element in our page
                         2.  The property of the element we want to change client-side
                         3.  The stuff we want to send to the client
  • Finally, we return the response by using the xajaxResponse->getXML() method.
  • These actions ALWAYS occur in our server-side Ajax functions. 
  • But there's a bit more to tell about the xajaxResponse class. 
  • Besides the xajaxResponse->addAssign() method there are some more. 
I have listed the some more functions below:
  • addAssign($sTargetId, $sAttribute, $sData)
    Assigns the $sAttribute of the element identified by $sTargetId to $sData. With this we can replace the data of a specific element with new server-generated data. 

$objResponse->addAssign("contentDiv","innerHTML", "Some Text");
$objResponse->addAssign("checkBox1","checked","true");
  • addAppend($sTargetId, $sAttribute, $sData)
    Appends $sData to the $sAttribute of the element identified by $sTargetId. This means the original content inside the attribute is preserved but new content is appended right after it. 

$objResponse->addAppend("contentDiv","innerHTML", "Some Text");
  • addPrepend($sTargetId, $sAttribute, $sData)
    Prepends $sData to the $sAttribute of the element identified by $sTargetId. This means the original content inside the attribute is preserved but new content is added right before it. 

$objResponse->addPrepend("contentDiv","innerHTML", "Some Text");
  • addReplace($sTargetId, $sAttribute, $sSearch, $sData)
    Replaces all instances of $sSearch with $sData in the $sAttribute of the element identified by $sTargetId.

$objResponse->addReplace("contentDiv","innerHTML", "text","<strong>text</strong>");
  • addClear($sTargetId, $sAttribute)
     Clears the $sAttribute of the element identified by $sTargetId.

$objResponse->addClear("Input1","value");
  • addCreate($sParentId, $sTagname, $sId, $sType)
    Adds a new $sTagName child element to an existing element identified by $sParentId, and assigns it the id $sId and the optional type $sType. 

$objResponse->addCreate("form1","input", "pass", "password");
  • addRemove($sElementId)
     Removes the element identified by $sElementId from our application.

$objResponse->addRemove("div1");
  • addAlert($sMsg)
     Display a javascript alert box with $sMsg.

$objResponse->addAlert("The server said: Hi!");
  • addScript($sJS)
    Execute the JavaScript code $sJS. With this powerful method we can actually send javascript back to the client which is instantly executed.

$objResponse->addAlert("var txt = prompt('get some text');");
Step 5: Before our script sends any output, have xajax handle any requests. we can process the requests with this method
$xajax->processRequest();
Step 6: Between our <head> section tags, tell xajax to generate the necessary JavaScript
 <?php $xajax->printJavascript(); ?>
Step 7: Call the function from a JavaScript event or function in our application.
Now we can finish off our page and use the functions we defined in the first steps directly from within the client-side part of our application. Considering our simple example we'd need to have some HTML element having the ID 'my_element':

<div id="my_element">Hai Xajax</div>

If we had add a link to the page calling our backend-function, the text inside the above element would be made bold instantly without the browser window refreshing. We can call the backend xajax functions like this:

<a href="#" onclick="xajax_makeBold(document.getElementById('my_element'));">Kick This</a>

That's it! We have now created our first Ajax powered link.  As you can see, backend functions can always be called from within client-side javascript by prepending xajax_ to the name we originally gave it. In our example we call xajax_makeBold(). We use document.getElementById('my_element') to target the element to update. We can specify any element and it's content will be enclosed by <b> and </b>.

XAJAX Features:
Xajax offers the following features that, together, make it unique and powerful: 

1.   Xajax's unique XML response / javascript message-pump system does the work for you, automatically handling the data returned from our functions and updating our content or state according to the instructions you return from our PHP functions. Because xajax does the work, you don't have to write javascript callback handler functions.
2.   Xajax is object oriented to maintain tighter relationships between the code and data, and to keep the xajax code separate from other code. Because it is object oriented, you can add our own custom functionality to xajax by extending the xajaxResponse class and using the addScript() method.
3.   Xajax works in Firefox, Mozilla, probably other Mozilla based browsers, Internet Explorer, and Safari.
4.  In addition to updating element values and innerHTML, xajax can be used to update styles, css classes, checkbox and radio button selection, or nearly any other element attribute.
5.  Xajax supports passing single and multidimensional arrays and associative arrays from javascript to PHP as parameters to our xajax functions. Additionally, if you pass a javascript object into an xajax function, the PHP function will receive an associative array representing the properties of the object.
6.  Xajax provides easy asynchronous Form processing. By using the xajax.getFormValues() javascript method, you can easily submit an array representing the values in a form as a parameter to a xajax asynchronous function:
xajax_processForm(xajax.getFormValues('formId');
It even works with complex input names like "checkbox [ ] [ ]" and "name[first]" to produce multidimensional and associative arrays, just as if you had submitted the form and used the PHP $_GET array
7.  Using xajax you can dynamically send additional javascript to our application to be run in response to a request as well as dynamically update element attributes.
8.  Xajax automatically compares the data returned from the PHP functions to the data that is already in the attribute of the element you have marked for change. The attribute is only updated with the new data if it will actually change what is already in the attribute. This eliminates the flicker often observed in applications that update content at a regular time interval with data which may or may not differ from extant content.
9.  Each function registered to be accessible through xajax can have a different request type.All functions default to use POST unless GET is explicitly set. This is to encourage careful consideration of when to use GET requests
10. If no request URI is specified, xajax tries to autodetect the URL of the script. The xajax autodetection algorithm is sophisticated enough that, on most servers, it will work under a secure https:// protocol as well as http:// and with nonstandard ports.
11. Xajax encodes all of its requests and responses in UTF-8 so that it can support a wider range of characters and languages. xajax has been successfully tested with various unicode characters including Spanish, Russian, Arabic, and Hebrew
12. Nearly all of the javascript generated by xajax is included into our web application through dynamic external javascript. When you view the source of our application in our browser, the markup will be not cluttered by JavaScript function definitions.
13. Xajax can be used with the Smarty templating system by creating a variable in smarty   that contains the xajax javascript:
$smarty->assign('xajax_javascript', $xajax->getJavascript());
Then you can use {$xajax_javascript} in our header template to use xajax on our site.

Tuesday, December 21, 2010

PostgreSQL Commands

Commands and its Description:
  1. ABORT--abort the current transaction
  2. ALTER AGGREGATE--change the definition of an aggregate function
  3. ALTER CONVERSION--change the definition of a conversion
  4. ALTER DATABASE--change a database
  5. ALTER DOMAIN-- change the definition of a domain
  6. ALTER FUNCTION--change the definition of a function
  7. ALTER GROUP--change role name or membership
  8. ALTER INDEX--change the definition of an index
  9. ALTER LANGUAGE--change the definition of a procedural language
  10. ALTER OPERATOR--change the definition of an operator
  11. ALTER OPERATOR CLASS--change the definition of an operator class
  12. ALTER ROLE--change a database role
  13. ALTER SCHEMA--change the definition of a schema
  14. ALTER SEQUENCE-- change the definition of a sequence generator
  15. ALTER TABLE--change the definition of a table
  16. ALTER TABLESPACE--change the definition of a tablespace
  17. ALTER TRIGGER--change the definition of a trigger
  18. ALTER TYPE-- change the definition of a type
  19. ALTER USER--change a database role
  20. ANALYZE--collect statistics about a database
  21. BEGIN--start a transaction block
  22. CHECKPOINT--force a transaction log checkpoint
  23. CLOSE--close a cursor
  24. CLUSTER--cluster a table according to an index
  25. COMMENT--define or change the comment of an object
  26. COMMIT--commit the current transaction
  27. COMMIT PREPARED--commit a transaction that was earlier prepared for two-phase commit
  28. COPY--copy data between a file and a table
  29. CREATE AGGREGATE--define a new aggregate function
  30. CREATE CAST--define a new cast
  31. CREATE CONSTRAINT TRIGGER--define a new constraint trigger
  32. CREATE CONVERSION--define a new encoding conversion
  33. CREATE DATABASE--create a new database
  34. CREATE DOMAIN--define a new domain
  35. CREATE FUNCTION--define a new function
  36. CREATE GROUP--define a new database role
  37. CREATE INDEX--define a new index
  38. CREATE LANGUAGE--define a new procedural language
  39. CREATE OPERATOR--define a new operator
  40. CREATE OPERATOR CLASS--define a new operator class
  41. CREATE ROLE--define a new database role
  42. CREATE RULE--define a new rewrite rule
  43. CREATE SCHEMA--define a new schema
  44. CREATE SEQUENCE--define a new sequence generator
  45. CREATE TABLE--define a new table
  46. CREATE TABLE AS--define a new table from the results of a query
  47. CREATE TABLESPACE--define a new tablespace
  48. CREATE TRIGGER--define a new trigger
  49. CREATE TYPE--define a new data type
  50. CREATE USER--define a new database role
  51. CREATE VIEW--define a new view
  52. DEALLOCATE--deallocate a prepared statement
  53. DECLARE--define a cursor
  54. DELETE--delete rows of a table
  55. DROP AGGREGATE--remove an aggregate function
  56. DROP CAST--remove a cast
  57. DROP CONVERSION--remove a conversion
  58. DROP DATABASE--remove a database
  59. DROP DOMAIN--remove a domain
  60. DROP FUNCTION--remove a function
  61. DROP GROUP--remove a database role
  62. DROP INDEX--remove an index
  63. DROP LANGUAGE--remove a procedural language
  64. DROP OPERATOR--remove an operator
  65. DROP OPERATOR CLASS--remove an operator class
  66. DROP ROLE--remove a database role
  67. DROP RULE--remove a rewrite rule
  68. DROP SCHEMA--remove a schema
  69. DROP SEQUENCE--remove a sequence
  70. DROP TABLE--remove a table
  71. DROP TABLESPACE--remove a tablespace
  72. DROP TRIGGER--remove a trigger
  73. DROP TYPE--remove a data type
  74. DROP USER--remove a database role
  75. DROP VIEW--remove a view
  76. END--commit the current transaction
  77. EXECUTE--execute a prepared statement
  78. EXPLAIN--show the execution plan of a statement
  79. FETCH--retrieve rows from a query using a cursor
  80. GRANT--define access privileges
  81. INSERT--create new rows in a table
  82. LISTEN--listen for a notification
  83. LOAD--load or reload a shared library file
  84. LOCK--lock a table
  85. MOVE--position a cursor
  86. NOTIFY--generate a notification
  87. PREPARE--prepare a statement for execution
  88. PREPARE TRANSACTION--prepare the current transaction for two-phase commit
  89. REINDEX--rebuild indexes
  90. RELEASE SAVEPOINT--destroy a previously defined savepoint
  91. RESET--restore the value of a run-time parameter to the default value
  92. REVOKE--remove access privileges
  93. ROLLBACK--abort the current transaction
  94. ROLLBACK PREPARED--cancel a transaction that was earlier prepared for two-phase commit
  95. ROLLBACK TO SAVEPOINT--roll back to a savepoint
  96. SAVEPOINT--define a new savepoint within the current transaction
  97. SELECT--retrieve rows from a table or view
  98. SELECT INTO--define a new table from the results of a query
  99. SET--change a run-time parameter
  100. SET CONSTRAINTS--set constraint checking modes for the current transaction
  101. SET ROLE--set the current user identifier of the current session
  102. SET SESSION AUTHORIZATION--set the session user identifier and the current user identifier of the current session
  103. SET TRANSACTION--set the characteristics of the current transaction
  104. SHOW--show the value of a run-time parameter
  105. START TRANSACTION--start a transaction block
  106. TRUNCATE--empty a table or set of tables
  107. UNLISTEN--stop listening for a notification
  108. UPDATE--update rows of a table
  109. VACUUM--garbage-collect and optionally analyze a database
PostgreSQL Client Applications:
  1. clusterdb --cluster a PostgreSQL database
  2. createdb --create a new PostgreSQL database
  3. createlang --define a new PostgreSQL procedural language
  4. createuser --define a new PostgreSQL user account
  5. dropdb --remove a PostgreSQL database
  6. droplang --remove a PostgreSQL procedural language
  7. dropuser --remove a PostgreSQL user account
  8. ecpg --embedded SQL C preprocessor
  9. pg_config --retrieve information about the installed version of PostgreSQL
  10. pg_dump -- extract a PostgreSQL database into a script file or other archive file
  11. pg_dumpall --extract a PostgreSQL database cluster into a script file
  12. pg_restore -- restore a PostgreSQL database from an archive file created by pg_dump
  13. psql -- PostgreSQL interactive terminal
  14. reindexdb --reindex a PostgreSQL database
  15. vacuumdb --garbage-collect and analyze a PostgreSQL database
PostgreSQL Server Applications:
  1. initdb --create a new PostgreSQL database cluster
  2. ipcclean --remove shared memory and semaphores from a failed PostgreSQL server
  3. pg_controldata --display control information of a PostgreSQL database cluster
  4. pg_ctl --start, stop, or restart a PostgreSQL server
  5. pg_resetxlog --reset the write-ahead log and other control information of a PostgreSQL database cluster
  6. postgres --run a PostgreSQL server in single-user mode
  7. postmaster --PostgreSQL multiuser database server

Monday, December 20, 2010

Installation of Apache, PostgreSQL and PHP in Linux

Installation steps for PostgreSQL:
            Step 1: Open the konsole, go to directory as ---> cd/usr/local/src
            Step 2: Then extract tar file using following command,
                            Eg:  $usr/local/src> tar -xvjf home/postgresql-8.3.5.tar.bz2
            Step 3: Now Change the directory as,
                            Eg:  $usr/local/src>  cd postgresql-8.3.5/
            Stpe 4: Then configure the postgresql using
                            Eg:  $usr/local/src/postgresql-8.3.5>  . /configure
            Step 5: Then build a program from its source, give command as
                            Eg:  $usr/local/src/postgresql-8.3.5>  gmake
            Step 6: Then install the directory
                            Eg:  $usr/local/src/postgresql-8.3.5>  gmake install
            Step 7: Now Postgresql installed successfully.
            Step 8: Then add new user as ---->  useradd -M postgres
            Step 9: Then add the group as ---->  groupadd postgres
            Step 10: Then add another group as ---->  groupadd apache
            Step 11: Then add another user as ---->  useradd -M -g apache apache
            Step 12: Then create new directories as ---->  mkdir /usr/local/pgsql/data
            Step 13:Then change the owner as --->  chown postgres:postgres /usr/local/pgsql/data
            Step 14: Then set the Data directories,
                             su -c '/usr/local/pgsql/bin/initdb -D  /usr/local/pgsql/data' postgres
            Step 15: Then set postmaster directories,
                         su -c '/usr/local/pgsql/bin/postmaster -D  /usr/local/pgsql/data >logfile 2>&1&'  postgres
            Step 16: Then give the super user permission,
                             su -c '/usr/local/pgsql/bin/createuser USER NAME' postgres
            Step 17: Copy the start-script directories into init.d/postgresql directories,
                             cp contrib/start-scripts/linux   /etc/init.d/postgresql
            Step 18: Change the access mode of a file as,
                             chmod a+x /etc/init.d/postgresql
            Step 19: Change the access mode of a file as,
                             chmod a+x /usr/local/pgsql/bin/reindexdb
            Step 20: Then change directories as,
                              cd /etc/init.d
            Step 21: And give following commands to configure the postgresql,
                             chkconfig --add postgresql
                             chkconfig postgresql on
                             /etc/init.d/postgresql start
            Step 22: Then give profile path in bottom of .profile file,
                             # cd /home$ vi .profile
                             # PATH=/usr/local/pgsql/bin:$PATH:$HOME
            Step 23: Then Postgresql Installation Completed

Installation steps for Apache server:
            Step 1: Open the konsole, go to directory as --->  cd /usr/local/src
            Step 2: Then convert zip file into tar file using following command,
                             Eg:  $usr/local/src>  tar -xvzf /home/apache_1.3.31.tar.gz
            Step 3: Then change the directories as,
                             Eg:  $usr/local/src>  cd apache_1.3.31/
            Step 4: Then make configure apache as,
                             Eg:  $usr/local/src/apache_1.3.31>  . /configure –enable-module=so
            Step 5: Then build a program from its source, give command as,
                             Eg:  $usr/local/src/apache_1.3.31>  gmake
            Step6: Then make installation in current directories as,
                             Eg:  $usr/local/src/apache_1.3.31>  gmake install
            Step 7: Then, Apache Installation Completed

Installation steps for PHP:
            Step 1: Open the konsole, go to directory as --->  cd /usr/local/src
            Step 2: Then extract tar file into current directories, give following command as,
                      Eg:  $usr/local/src>  tar -xvjf /home/php-5.2.5.tar.bz2
            Step 3: Change the directories as,
                            Eg:  $usr/local/src>  cd php-5.2.5/
            Step 4: Then configure current directories using following command as,
                            Eg:  $usr/local/src/php-5.2.5>  ./configure --with-pgsql –with-apxs2 =/usr/local/apache2/bin/apxs    
            Step 5: Then build a program from its source, give command as,
                            Eg:  $usr/local/src/php-5.2.5>  gmake
            Step 6: Then make installation current directories
                            Eg:  $usr/local/src/php-5.2.5>  gmake install
            Step 7: Then, PHP Installation Completed.

After installing the Apache and PHP, steps to start the Apache server:
            Step 1: Copy the httpd file from apache directories, and paste into /etc/init.d/
                            cp /usr/local/apache2/bin/httpd   /etc/init.d/
            Step 2: Then change directories as,
                            cd /etc/init.d
                            chkconfig --add httpd
                            chkconfig httpd on
                            /etc/init.d/httpd start
            Step 3:  Create the new php file as following line,
                             <?
                                 phpinfo();
                             ?>

                            and saved as phpinfo.php into this following directory /usr/local/apache2/htdocs
              Step 4: Installation process is successfully completed.