lamp technology

Post on 26-Jun-2015

1.451 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

LAMP TECHNOLOGY

PRESENTED BY.,

M.HARIHARAN.,

MCA “A” SEC( II YEAR).

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.

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

MySQL

multithreaded, multi-user, SQL database management system

PHP

reflective programming language originally designed for

producing dynamic web pages

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

LINUX ( OPERATING SYSTEM )

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.

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..

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.

ADVANTAGES:

Cost.

Security.

Choice(freedom).

Software.

Hardware.

DISADVANTAGES:

Understanding.

Compatibility.

Alternative Programs.

BASIC LINUX COMMANDS:

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

$ w

2.Show who is logged on.

$ who

3.Create empty file of 0 byte

$ touch

4.Remove file

$ rm

5. List files.

$ ls

6. Create/Make a new directory.

$ mkdir

7. Clear the terminal screen.

$clear

8.Display information on free used memory.

$ free

9.Check current date and time.

$ date

10.Compare two files.

$ cmp file1 file2

11.To save and exit.

Ctrl -d

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.

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

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

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)

LINUX DIRECTORY STRUCTURE

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.

< /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.

< /usr/bin >

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

< /dev >

The devices that are available to a Linux system.

< /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.

< /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.

< /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.

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)

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

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.

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.

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.

APACHE ( HTTP SERVER )

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.

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.

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.

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

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

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

* 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

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

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

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.

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.

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.

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

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.

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

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

RUNNING APACHE continue..

To restart Apache without aborting current connections, run:

# /usr/local/sbin/apachectl graceful

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.

MySQL(DATABASE SOFTWARE)

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.

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

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.

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.

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.

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.

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");

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");

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");

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,...) ");

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");

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");

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.

LTRIM :

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

string.

RTRIM:

It works like LTRIM, but it removes trailing spaces.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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 ;

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.

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

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.

For example:

delimiter // create function circumference (r double) returns

double

deterministic

begin

declare c double;

set c = 2 * r * pi();

return c;

end // delimiter ;

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.

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

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

PHP

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.)

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

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)

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.

DISADVANTAGES

Security flaws due to unknown vulnerabilities .

Not good to create desktop Applications.

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.

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.

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.

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.

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.

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.

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:

{}|&~![()".

CONTENTS OF "test.ini"

[names]

me = Robert

you = Peter

[urls]

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

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

PHP CODE:

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

?>

OUTPUT :

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

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

)

ANY QUERIES

top related