lamp technology

99
LAMP TECHNOLOGY PRESENTED BY., M.HARIHARAN., MCA “A” SEC( II YEAR).

Upload: 2tharan21

Post on 26-Jun-2015

1.451 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Lamp technology

LAMP TECHNOLOGY

PRESENTED BY.,

M.HARIHARAN.,

MCA “A” SEC( II YEAR).

Page 2: Lamp technology

LAMP TECHNOLOGY

LAMP is an acronym for a solution stack of free, open source software, originally coined from the first letters of

Linux (operating system),

Apache HTTP Server,

MySQL (database software) and

PHP.

Page 3: Lamp technology

Linux

Unix-like computer operating system, open-source

software where source code is provided with operating

system, which can be edited according to specific needs.

Apache

free software/open source web server

Page 4: Lamp technology

MySQL

multithreaded, multi-user, SQL database management system

PHP

reflective programming language originally designed for

producing dynamic web pages

Page 5: Lamp technology

ADVANTAGES OF LAMP

Easy to code with PHP and MySQL.

Easy to deploy a PHP app. Once you’ve got MySQL running,

simply upload your .php files.

Develop locally

Cheap and ubiquitous hosting

Page 6: Lamp technology

LINUX ( OPERATING SYSTEM )

Page 7: Lamp technology

WHAT IS LINUX?

It is an operating system.

It is designed for to provide personal computer users a free or at

very low-cost .

It has a reputation as a very efficient & fast performing systems.

Linux was developed by Linux Torvalds at the University of

Helsinki in Finland.

Page 8: Lamp technology

WHY WE ARE USING LINUX? We dont have to buy the office system requirements

separately.

No need to buy costly hardwares for the basic need(like

RAM,Processor).

We are free from viruses no need to buy the antivirus

softwares separately..

Page 9: Lamp technology

WHY WE ARE USING LINUX? Continue..

We can update everthing on our system with just one update manager.

It is free from pirated software so that we can share it with

others is legal.

It wont get slow like windows operating system.

It upgrades all installation automatically.

Page 10: Lamp technology

ADVANTAGES:

Cost.

Security.

Choice(freedom).

Software.

Hardware.

Page 11: Lamp technology

DISADVANTAGES:

Understanding.

Compatibility.

Alternative Programs.

Page 12: Lamp technology

BASIC LINUX COMMANDS:

1.Show who is logged on and what they are doing.

$ w

2.Show who is logged on.

$ who

Page 13: Lamp technology

3.Create empty file of 0 byte

$ touch

4.Remove file

$ rm

5. List files.

$ ls

Page 14: Lamp technology

6. Create/Make a new directory.

$ mkdir

7. Clear the terminal screen.

$clear

8.Display information on free used memory.

$ free

Page 15: Lamp technology

9.Check current date and time.

$ date

10.Compare two files.

$ cmp file1 file2

11.To save and exit.

Ctrl -d

Page 16: Lamp technology

12.Short listing of directory contents $ls -

-a list hidden files.

-d list the name of the current directory.

-F show directories with a trailing '/'

executable files with a trailing '*'.

-t sort by time modified instead of name.

Page 17: Lamp technology

Short listing of directory contents $ls- continue..

-g show group ownership of file in long listing

-i print the inode number of each file

-l long listing giving details about files and directories

Page 18: Lamp technology

13.Prints a calendar for the specified month of the specified

year.

$cal month year

14.It will show you the full path to the directory you are

currently in.

$pwd ( print working directory)

Apr 13, 202318

Page 19: Lamp technology

15.Type mv followed by the current name of a directory and the new name of the directory.

$mv( change the name of a directory)

Page 20: Lamp technology

LINUX DIRECTORY STRUCTURE

Page 21: Lamp technology

LINUX DIRECTORIES:

< / >

The root directory where the Linux system begins contains

only subdirectories. .

The starting point of your directory structure.

Every other file and directory on system is under the root

directory.

Page 22: Lamp technology

< /boot >

The place where Linux keeps information that it needs when

booting up.

< /bin >

It contains the most important programs that the system

needs to operate, such as the shells, ls, grep, and other

essential things.

Page 23: Lamp technology

< /usr/bin >

/usr/bin in turn contains applications for the system's users.

< /dev >

The devices that are available to a Linux system.

Page 24: Lamp technology

< /etc >

The configuration files for the Linux system.

Most of these files are text files and can be edited by hand.

< /home >

This is where users keep their personal files are allowed to

write files.

Page 25: Lamp technology

< /lib >

The shared libraries for programs that are dynamically

linked.

< /mnt >

This directory is used for mount points.

< /sbin, /usr/sbin >

Most system administration programs are stored in these

directories.

Page 26: Lamp technology

< /usr >

It contains user applications and source codes, and pictures,

docs, or config files .

</usr/share>

Config files and graphics for many user apps.

< /usr/local >

This is where you install apps and other files for use on the

local machine.

Page 27: Lamp technology

SOME OF THE LINUX EDITORS

ed - Original UNIX line-based editor, useful in scripts

emacs - GNU editor and fully integrated user

environment

ex - Powerful line-based editor

(integrated with vi)

Page 28: Lamp technology

SOME OF THE LINUX EDITORS continue..

gawk - GNU awk, powerful text editor for records containing fields.

sed - Stream-oriented (non- interactive) line-based editor

vi - Classic screen-based editor for UNIX

vim - Vi IMproved, enhanced support for programmers

Page 29: Lamp technology

CRONTAB & CRONJOB

The term cron is derived from the word chronograph.

The Cron, at, batch Command is used for Scheduling

Execution of Command according to requirements.

Cron is a system deamon that keeps sleeping most of the

time.

Page 30: Lamp technology

CRONTAB & CRONJOB continue..

It typically wakes up every one minute and checks it

crontab file for any jobs to be executed during this minute.

The name of this crontab file will be the user's login name.

Page 31: Lamp technology

CRONTAB & CRONJOB continue..

The Scheduled jobs will be present in the Crontab files .

Cron tab files will be present in the

/var/ spool/ cron/ crontabs directory.

It Should be executed periodically at a specific day, date

and time.

Page 32: Lamp technology

APACHE ( HTTP SERVER )

Page 33: Lamp technology

WHAT IS APACHE?

An open source web server used mostly for Unix, Linux and Solaris platforms.

It is very secure, fast, and reliable.

The name "Apache" derives from the word "patchy" that

the Apache developers used to describe early versions of

their software.

Page 34: Lamp technology

IMPLEMENTATION:

DBM databases for authentication

Customized responses to errors and problems

Virtual Hosts

Multiple DirectoryIndex directives

It has been tested thoroughly by both developers and users.

Page 35: Lamp technology

APACHE WEB SERVER

It provides a full range of Web server features, including CGI, SSL, and virtual domains.

Apache also supports plug-in modules for extensibility.

Page 36: Lamp technology

The Apache Web Server has

HTTP

IIS

SSL

The Apache Web server has been ported to Windows and

other network operating systems (NOS).

Apr 13, 202336

Page 37: Lamp technology

HTTP

HTTP is an Hypertext Transfer Protocol.

It provides a standard for Web browsers and servers to

communicate.

It is a technical specification of a network protocol that

software must implement.

HTTP is an application layer network protocol built on

top of TCP.Apr 13, 202337

Page 38: Lamp technology

HTTP clients (such as Web browsers) and servers

communicate via HTTP request and response messages.

The three main HTTP message types are

GET, POST, and HEAD.

HTTP utilizes TCP port 80 by default.

Apr 13, 202338

Page 39: Lamp technology

* Though other ports such as 8080 can alternatively be

used.

* The HTTP also includes.

ARP-(Address Resolution Protocol)

DHCP-(Dynamic Host Configuration Protocol)

FTP(File Transfer Protocol)

Apr 13, 202339

Page 40: Lamp technology

ARP

ARP converts an Internet Protocol (IP) address to its

corresponding physical network address.

It is implemented in the device drivers of network

operating systems.

It is most commonly seen on Ethernet networks, ATM,

Token Ring, and other physical networks.

Apr 13, 202340

Page 41: Lamp technology

DHCP

DHCP allows a computer to join an IP-based network

without having a pre-configured IP address.

DHCP is a protocol that assigns unique IP addresses to

devices, then releases and renews these addresses as

devices leave and re-join the network.

Apr 13, 202341

Page 42: Lamp technology

FTP

Apr 13, 202342

FTP allows you to

transfer files between

two computers on the

Internet. FTP is a simple network

protocol based on

Internet Protocol.

Page 43: Lamp technology

SSL

Secure Sockets Layer.

SSL security technology helps to improve the safety of

Internet communications.

SSL is a standard for encrypted client/server

communication between network devices.

A network protocol, SSL runs on top of TCP/IP.

Page 44: Lamp technology

CONFIGURATION

Instead of using a point-and-click graphic user interface (GUI) or Windows Registry keys as most other modern software packages, Apache generally relies on simple text files for its configuration settings.

Page 45: Lamp technology

CONFIGURING FILES

It uses a system text files for managing its configuration data.

These files appear in Apache's ./conf directory and are

designed to be edited by system administrators:

httpd.conf for general settings

srm.conf for resource settings

access.conf for security settings

Page 46: Lamp technology

RUNNING APACHE

Apache does not run from the inetd super server as many other network servers do.

It is configured to run standalone for better performance for

incoming HTTP requests from client web browsers.

Page 47: Lamp technology

RUNNING APACHE continue..

A shell script wrapper is included to make starting, stopping,

and restarting the server as simple as possible.

To start up Apache for the first time, just run:

# /usr/local/sbin/apachectl start

Page 48: Lamp technology

RUNNING APACHE continue..

You can stop the server at any time by typing:

# /usr/local/sbin/apachectl stop

After making changes to the configuration file for any

reason, you will need to restart the server:

# /usr/local/sbin/apachectl restart

Page 49: Lamp technology

RUNNING APACHE continue..

To restart Apache without aborting current connections, run:

# /usr/local/sbin/apachectl graceful

Page 50: Lamp technology

The family of .conf files supports most, but not all of Apache's configuration options.

Other important mechanisms for managing an Apache

Web server include the

.htaccess file, the mime.types file,and the family of log files.

Page 51: Lamp technology

MySQL(DATABASE SOFTWARE)

Page 52: Lamp technology

WHAT IS MySQL?

The most popular open source SQL database management system.

It is used to add,access and process data stored in a computer

database.

It is a RDBMS store in a separate tables rather than putting all

the data in one big store room.It adds speed and flexibility.

Page 53: Lamp technology

It is very fast,reliable and easy to use,due to the

connectivity,speed ,security.

It works in Client/Server or embedded system.

A large amount of contributed MySQL software is

available.

WHAT IS MySQL? continue..

Apr 13, 202353

Page 54: Lamp technology

WHAT IS MySQL? continue..

Apr 13, 202354

It consists of multithreaded SQL server that support:

Different backends,

Several different client programs,

Libraries,

Administration tools,

Wide range of API's.

Page 55: Lamp technology

WHY WE ARE USING MYSQL?

It is free .

It is fast comparing to other Database system such as

PostgreSQL,mSQL.

It is light weight yet offers a rich and highly useful function

set.

It is supported well by users community.

Page 56: Lamp technology

BASIC QUERIES

CREATE Command - is used to create a database/table.

SELECT Command - is used to retrieve data from the

database.

DELETE Command - is used to delete data from the database.

Page 57: Lamp technology

BASIC QUERY COMMANDS IN MySQL continue..

INSERT Command - is used to insert data into a database.

UPDATE Command - is used to update the data in a table.

DROP Command - is used to delete or drop the

database/table.

Page 58: Lamp technology

SYNTAX FOR QUERY COMMANDS

1.CREATE Command :

The Create command is used to create a table by

specifying the tablename, fieldnames and constraints as shown

below:

Syntax:

$createSQL=("CREATE TABLE tblName");

Page 59: Lamp technology

2.SELECT Command :

It is used to select the records from a table using

its field names, '*' is used to select all the fields in a table.

Syntax:

$selectSQL=("SELECT field_names FROM tablename");

Page 60: Lamp technology

3.DELETE Command :

The Delete command is used to delete the records

from a table using conditions as shown below:

Syntax:

$deleteSQL=("DELETE * FROM tablename WHERE

condition");

Page 61: Lamp technology

4.INSERT Command :

The Insert command is used to insert records into a

table. The values are assigned to the field names as shown

below:

Syntax:

$insertSQL=("INSERT INTO blname(fieldname1,fieldname2..)

VALUES(value1,value2,...) ");

Page 62: Lamp technology

5.UPDATE Command :

It is used to update the field values using conditions.

This is done using 'SET' and the fieldnames to assign new

values to them.

Syntax:

$updateSQL=("UPDATE Tblname SET

(fieldname1=value1,fieldname2=value2,...) WHERE

fldstudid=IdNumber");

Page 63: Lamp technology

6. DROP Command:

The Drop command is used to delete all the records

in a table using the table name as shown below:

Syntax:

$dropSQL=("DROP tblName");

Page 64: Lamp technology

ADVANCED QUERIES

INNER JOIN:

It is used to retrieve the data from all tables

listed.

REPLACE:

It searches a character string and replaces characters

found in search string.

Page 65: Lamp technology

LTRIM :

It removes any leading (left-hand) spaces in a character

string.

RTRIM:

It works like LTRIM, but it removes trailing spaces.

Page 66: Lamp technology

SIGN :

It takes in a numeric expression and returns one of the

following values based on the sign of the input number:

−1 - Input number is negative.

0 - Input number is zero.

1 - Input number is positive.

Null - Input number is null.

Page 67: Lamp technology

SQRT :

It takes in a single numeric expression and returns its

square root.

CEILING (CEIL) :

It rounds up to the next nearest whole number.

FLOOR :

It rounds down to the next nearest whole number.

Page 68: Lamp technology

DATE and TIME :

ADD_MONTHS:

Adds the supplied number of months to the

supplied date.

CURRENT_DATE:

Returns the current date in the time zone set for

the DB session.

Page 69: Lamp technology

EXTRACT:

Extracts the specified date field from the supplied

date.

LAST_DAY:

Returns of supplied date with the day shifted to the

last day of the month.

Page 70: Lamp technology

PROCEDURES AND FUNCTIONS

Subroutines and functions can be made available to

a single program or many; and that, of course, is what stored

procedures and stored functions are - they are procedures (or

subroutines) and functions stored in the database.

Page 71: Lamp technology

WHY USE PROCEDURES AND FUNCTIONS?

The real advantage to using stored procedures and

stored functions is that they provide functionality which is

platform and application independant.

Page 72: Lamp technology

WHY USE PROCEDURES & FUNCTIONS? continue..

For example, a team of developers may provide:

a Visual Basic application on Windows

a Gambas application on Linux

a PHP application on a web server

With procedures and functions the functionality only

has to be developed once.

Page 73: Lamp technology

CREATING MySQL PROCEDURES

A stored procedure is the same as a subroutine in

that it cannot directly return a result, however it can receive

variables that can be modified by the procedure.

Page 74: Lamp technology

These variables are defined as:

in - the variable can only be used as an input to the

procedure.

out - the variable can only be used as an output from the

procedure.

inout - this is both an input to, and an output from, the

procedure.

Page 75: Lamp technology

Procedures are always declared as:

Define the procedure name, inputs and outputs,body of

the procedure.

For example:

delimiter //

create procedure circle_area (in r double, out a double)

begin

set a = r * r * pi();

end

//delimiter ;

Page 76: Lamp technology

RUNNING MySQL PROCEDURES

A MySQL stored procedure is run by using the call method:

call circle_area(22, @a);

select @a;

In this example 1520.5308443375 would be displayed on

the screen.

Page 77: Lamp technology

CREATING MYSQL FUNCTIONS

Unlike stored procedures stored functions always return a result, they will also be one of two types:

not deterministic - may produce different results for the same

inputs .

deterministic - will always produce the same result for any

given inputs

Page 78: Lamp technology

Like procedures, all functions are created :

define the function name,

declare any inputs,

define the data type to be returned by the function,

state whether or not the function is deterministic,

define the body of the function.

Page 79: Lamp technology

For example:

delimiter // create function circumference (r double) returns

double

deterministic

begin

declare c double;

set c = 2 * r * pi();

return c;

end // delimiter ;

Page 80: Lamp technology

RUNNING MySQL FUNCTIONS

Unlike stored procedures stored functions are

used as part of a select statement:

select circumference(22);

In this case (for anyone that's interested) the result would be

138.23007675795.

Page 81: Lamp technology

IMPORT A MySQL DATABASE

This to restore data from a backup or to import from another MySQL server.

Start by uploading the FILE.sql file to the server where we

will be running this command.

# mysql -u username -ppassword database_name < FILE.sql

Page 82: Lamp technology

EXPORT A MySQL DATABASE

Replace username, password and database_name with your MySQL username, password and database name.File FILE.sql now holds a backup of your database, download it to your computer.

# mysqldump -u username -ppassword database_name >

FILE.sql

Page 83: Lamp technology

PHP

Page 84: Lamp technology

WHAT IS PHP?

PHP : Hypertext Preprocessor

It is an open source software and free to download to use.

It is a server-side scripting language, like ASP and scripts

are executed on the server.

It supports many databases (MySQL, Informix, Oracle,

Sybase, Solid, PostgreSQL, Generic ODBC, etc.)

Page 85: Lamp technology

The PHP is very simple for a beginner, but offers many advanced features for a professional script writer.

Three main areas where PHP scripts are used :

Server-side scripting

Command line scripting

Writing desktop applications

Page 86: Lamp technology

ADVANTAGES

It Support for both structural and Oops programming.

It can plugin with most of the databasesand use of variables $

$var.

It support services using protocols such as LDAP, IMAP,

SNMP, NNTP, POP3, HTTP, COM (on Windows)

Page 87: Lamp technology

ADVANTAGES continue..

PHP has extremely useful text processing features, from the

POSIX Extended or Perl regular expressions to parsing XML

documents.

Easy deployment and cost effective hosting.

Power ful built in functions.

Page 88: Lamp technology

DISADVANTAGES

Security flaws due to unknown vulnerabilities .

Not good to create desktop Applications.

Page 89: Lamp technology

WHY WE ARE USING PHP?

It enables programmers to create applications that will run on just about any computer, regardless of operating system.

If the computer can run web server software, the PHP application is portable across operating systems and environments ... PC, Mac, Linux, Windows, Internet, Intranet, etc.

Page 90: Lamp technology

BASIC PHP SYNTAX

*

A PHP scripting block always starts with

<?php ends with ?>

* For maximum compatibility, it is recommended that to use the standard form (<?php) rather than the shorthand form.

Page 91: Lamp technology

Each code line must end with a semicolon.

There are two basic statements to output text with PHP:

echo and print

Note:

The file must have a .php extension.

If the file has a .html extension, the PHP code will not be

executed.

Page 92: Lamp technology

PHP . ini

It is a configuration file that is used to customize behavior of PHP at runtime.

The Settings in which upload directory, register global

variables, display errors, log errors, max uploading size

setting, maximum time to execute a script and other

configurations is written in this file.

Page 93: Lamp technology

PHP .ini continue..

The configuration file (php.ini) is read when PHP starts up.

In order for PHP to read it, it must be named 'php.ini‘.

The php.ini directives allows us to set configure our PHP

setup.

Page 94: Lamp technology

The parse_ini_file() function parses a configuration (ini) file

and returns the settings in it in an array.

Syntax:

parse_ini_file(file,process_sections)

file-Required. Specifies the ini file to check.

process_sections-Optional.Default is FALSE.

Page 95: Lamp technology

The following reserved words must not be used as keys for

ini files:

null, yes, no, true, and false.

The following reserved characters that must not be used

in the keys:

{}|&~![()".

Page 96: Lamp technology

CONTENTS OF "test.ini"

[names]

me = Robert

you = Peter

[urls]

first = "http://www.example.com"

second = "http://www.sample.com"

Page 97: Lamp technology

PHP CODE:

<?phpprint_r(parse_ini_file("test.ini"));

?>

OUTPUT :

([me] => Robert[you] => Peter

[first] => http://www.example.com[second] => http://www.w3schools.com

)

Page 98: Lamp technology
Page 99: Lamp technology

ANY QUERIES