SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
Home Page




 Title Page
                     Linux, Apache, Mysql, PHP

                       Sameer D. Sahasrabuddhe
                         KReSIT, IIT Bombay
Page 1 of 39
               http://www.it.iitb.ac.in/˜sameerds/
 Go Back




Full Screen




   Close




    Quit
Home Page




 Title Page




               The World Wide Web

Page 2 of 39




 Go Back




Full Screen




   Close




    Quit
Home Page
                                  Client-Server Architecture
 Title Page

               • Server: provides services.
               • Client: generates requests for services.
               • May or may not run on the same machine.
Page 3 of 39
               • Typically, they use a standard protocol for communication.
               • For example, Apache is a webserver, the browser is a client and the
 Go Back
                 protocol used is HTTP.
Full Screen




   Close




    Quit
What’s a webserver?
Home Page

               • A processs that responds to requests for resources on port 80.
 Title Page
               • Typical requests are for hypertext files and related objects.
               • The client uses a Universal Resource Locator (URL).
               • Example - http://www.kernel.org/pub/
               • A typical HTTP transaction:
Page 4 of 39
                  1. The browser (client) makes a request to the website.
 Go Back          2. The webserver looks up the resource specified.
                  3. The webserver reads/generates the corresponding content and
Full Screen
                     sends it to the browser (client).
   Close




    Quit
The Apache HTTP Server
Home Page




 Title Page
               • The number one http server on the Internet - 63% websites, as of
                 August 2002.
               • A project of the Apache Software Foundation.
               • Provides full source code and comes with an unrestrictive license -
                 the Apache Software License.
Page 5 of 39
               • Runs on Windows NT/9x, Netware 5.x and above, OS/2, and most
                 versions of Unix, as well as several other operating systems.
 Go Back

               • Can be customised by writing “modules” using the Apache module
Full Screen      API.

   Close




    Quit
What are modules?
Home Page

               Apache’s functionality is contained in modules that you can choose to
 Title Page    include or exclude.

                                         Types of modules

               static modules compiled into the httpd binary.
Page 6 of 39   dynamic modules stored separately and can be optionally loaded at run-
                  time.
 Go Back
               third-party modules modules that are not included in the standard
Full Screen
                   Apache HTTP Server distribution.

   Close




    Quit
Home Page




 Title Page                         Some common modules

               mod cgi Execution of CGI scripts.
               mod imap Server-side imagemap processing.
               mod include Server-parsed html documents (Server Side Includes).
Page 7 of 39

               mod php Server-side scripting in PHP (PHP Hypertext Preprocessor).
 Go Back




Full Screen




   Close




    Quit
Home Page
                                       Controlling Apache
 Title Page
               /etc/httpd/conf/httpd.conf The configuration file for the Apache HTTP
                   server.
               .htaccess File used to control Apache’s behaviour on a per-directory ba-
                   sis.
Page 8 of 39   /etc/init.d/httpd Script used to control the httpd process - start, stop,
                   restart, reload, status.
 Go Back
               /var/log/httpd/ Contains the Apache logs - error.log, access.log
Full Screen




   Close




    Quit
Home Page
                                       Apache content
 Title Page

               /var/www/html/ The “DocumentRoot” - all websites are served from
                  here by default.
               $home/public html/ User’s directory for serving webpages. For exam-
                  ple, http://www.it.iitb.ac.in/˜sameerds/ is served
Page 9 of 39
                  from /home/sameerds/public html/
               index.html “DirectoryIndex” that is used by default when a request
 Go Back
                  specifies a directory.
Full Screen




   Close




    Quit
Dynamic Content Generation
Home Page
                • Client-Server decoupling: the client never knows the physical format
 Title Page
                  of a resource.
                • The reply to a request is a data stream from the server.
                • The server may transparently create or modify data. Even images can
                  be generated on the fly!
                • This can be done in several ways:
Page 10 of 39

                   1. CGI - Common Gateway Interface to external programs.
  Go Back
                   2. SSI - Server-Side Includes.
                   3. Server Side Scripts - the most flexible way to use dynamically
 Full Screen
                      generated webpages.
   Close




    Quit
Home Page




 Title Page




                PHP: Hypertext Preprocessor


Page 11 of 39




  Go Back




 Full Screen




   Close




    Quit
Home Page                                  What is it?

 Title Page
                • A general purpose scripting language that is especially good for
                  server-side scripting.
                • A project maintained by the Apache Software Foundation.
                • All major operating systems - Linux, many Unix variants, Microsoft
                  Windows, Mac OS X, RISC OS, and probably others.
Page 12 of 39

                • All major webservers - Apache, Microsoft IIS, PWS, Netscape and
  Go Back         iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, Omni-
                  HTTPd, and many others.
 Full Screen




   Close




    Quit
Home Page                              What can PHP do?
 Title Page
                • Server-side scripting.
                • Command line scripting.
                • Writing client-side GUI applications: PHP-Gtk
                • Text processing features such as PCRE’s, XML documents, XSLT
Page 13 of 39     transformation.

  Go Back
                • Abilities also included generating images, PDF files and even Flash
                  movies, on the fly.
 Full Screen




   Close




    Quit
External services
Home Page




 Title Page
                • Database connectivity
                   – A wide range of databases - MySQL, PostgreSQL, Informix,
                     ODBC, Oracle ... too many more to list.
                   – DBX and ODBC interfaces, that allow scripting independent of
                     the database backends.
Page 14 of 39   • Network services such as IMAP, POP, SMTP, DNS, LDAP, SNMP
                  etc. as well as raw TCP sockets!
  Go Back
                • Support for instantiating Java objects, remote CORBA objects, and
 Full Screen
                  COM on windows.

   Close




    Quit
PHP on the Web

Home Page
                       PHP can be directly embedded in HTML markup.

 Title Page
                <html>
                    <head>
                        <title>Hello World!</title>
                    </head>
                    <body>

Page 15 of 39           <?php
                        echo "Hi, I’m a PHP script!";
  Go Back               ?>

 Full Screen        </body>
                </html>
   Close




    Quit
Home Page
                             PHP on the Web (continued)
 Title Page     <html>
                    <head>
                        <title>Hello World!</title>
                    </head>
                    <body>

Page 16 of 39
                        Hi, I’m a PHP script!
                    </body>
  Go Back
                </html>
 Full Screen




   Close




    Quit
Home Page

                                        Language features
 Title Page


                • Variables - pre-defined, external, user-defined, variable variables, ref-
                  erences.
                • Standard data-types such as booleans, integers, floating point num-
                  bers, strings and arrays.
Page 17 of 39
                • Control structures - if-then-else while, do-while, switch, foreach.
  Go Back       • Functions - user-defined functions similar to C, variable functions.

 Full Screen




   Close




    Quit
Variables in PHP


Home Page       Variable variables!
                $foo = "bar";
 Title Page     $$foo = "value";


                The result is that the variable $bbar, gets the value value.

                References
Page 18 of 39
                <?php
                $foo = ’Bob’;
  Go Back       $bar = &$foo;
                $bar = "My name is $bar";
 Full Screen    echo $bar;
                echo $foo;
   Close
                ?>

    Quit
Arrays
                $a = array( 1 => ’one’,
Home Page                   2 => ’two’,
                            3 =>’three’ );
 Title Page     $a[1] = ’one’;
                $a[2] = ’two’;
                $a[3] = ’three’;
                $a[] = ’four’;

                $a = array( ’color’   =>   ’red’
Page 19 of 39
                          , ’taste’   =>   ’sweet’
                          , ’shape’   =>   ’round’
  Go Back
                          , ’name’    =>   ’apple’
                          ,                4
 Full Screen
                          );
   Close
                $a[] = ’four’;

    Quit
Home Page                        Arrays functions
                unset ($a[’color’]);
 Title Page



                reset ($a);
                while (list($key, $value) = each ($a)) {
                    echo "Key: $key; Value: $value<br>n";
                }
Page 20 of 39

                foreach ($a as $key => $value) {
  Go Back           echo "Key: $key; Value: $value<br>n";
                }
 Full Screen




   Close




    Quit
Functions
                <?php
                function foo()
Home Page       {
                    echo "In foo()<br>n";
 Title Page     }

                function bar($arg = ’’)
                {
                    echo "In bar(), with ’$arg’.<br>n";
                }
Page 21 of 39


                foo();
  Go Back
                $func = ’foo’; $func();
 Full Screen
                bar(’test’);
                $func = ’bar’; $func(’test’);
   Close
                ?>
    Quit
OOP in PHP
                <?php
                class Cart
Home Page       {
                    var $items;
 Title Page         ...

                    function add_item ($artnr, $num) { ... }

                    function remove_item ($artnr, $num) { ... }
                }
Page 22 of 39


                $cart = new Cart;
  Go Back
                $cart->add_item("10", 1);
 Full Screen
                $another_cart = new Cart;
                $another_cart->add_item("0815", 3);
   Close
                ?>
    Quit
HTML Forms
                <form action="foo.php" method="post">
                Name: <input type="text" name="username"><br>
Home Page       Email: <input type="text" name="email"><br>
                <input type="submit" name="submit">
 Title Page     </form>

                <?php
                   print $_POST[’username’];
                   print $_REQUEST[’username’];

Page 23 of 39
                     // g, p and c type variables:
                     import_request_variables(’p’, ’p_’);
  Go Back
                     print $p_username;
 Full Screen
                     print $HTTP_POST_VARS[’username’];
                     print $username;
   Close
                ?>
    Quit
Home Page

                                        Session handling
 Title Page


                • A way to preserve certain data across subsequent accesses.
                • A visitor accessing your web site is assigned a unique session id,
                  which is used in two ways.
                • Cookies that are stored on the client, to be read on subsequent ac-
Page 24 of 39
                  cesses.
  Go Back       • Session ID’s that are propagated in the URL - more reliable.

 Full Screen




   Close




    Quit
Home Page
                                  Session example
                <?php
 Title Page     session_register ("count");
                $count++;
                ?>

                Hello visitor, you have seen this page
                 <?php echo $count; ?> times.<p>
Page 25 of 39


                To continue,
  Go Back
                 <A HREF="nextpage.php?<?=SID?>">
                 click here</A>
 Full Screen




   Close




    Quit
Cookies
Home Page

                 • A mechanism for storing data in the client.
 Title Page
                 • Any cookies sent from the client will automatically be turned into a
                   PHP variable.
                setcookie ("cookie[three]", "cookiethree");
                setcookie ("cookie[two]", "cookietwo");
                setcookie ("cookie[one]", "cookieone");
Page 26 of 39   if (isset ($cookie)) {
                  while(list ($name, $value) = each($cookie)) {
  Go Back             echo "$name == $value<br>n";
                  }
 Full Screen
                }
   Close




    Quit
Home Page




 Title Page




                MySQL


Page 27 of 39




  Go Back




 Full Screen




   Close




    Quit
Home Page
                                             What is it?
 Title Page

                • The most popular Open Source SQL database.
                • Developed, distributed and supported by MySQL AB.
                • Several different client programs, libraries and administrative tools..
Page 28 of 39
                • A wide range of programming interfaces (APIs).
                • Works on a wide range of operating systems including Windows,
  Go Back
                  Unix variants, Mac OS X, etc.
 Full Screen




   Close




    Quit
Installation
Home Page


                • Installation on Red Hat Linux is a breeze, using rpms for mysql,
 Title Page
                  mysql-server and mysqlclient.
                • Control script - /etc/init.d/mysqld.
                • Users on the server are distinct from those on the system.
                • The user accounts and database details are stored in a database called
Page 29 of 39     mysql.
                • All other users are created and controlled by the mysql root.
  Go Back

                • Users can create databases, tables, other users, etc depending on priv-
 Full Screen      ileges provided by the root.

   Close




    Quit
Using the mysql client
Home Page
                Use mysql to connect to a MySQL server.
                shell> mysql -h host -u user -p
 Title Page


                shell> mysql -h host -u user -p < batch-file

                Configuration files
                /etc/my.cnf Global options
Page 30 of 39

                DATADIR/my.cnf Server-specific options
  Go Back
                defaults-extra-file The file specified with –defaults-extra-file=#
 Full Screen    /.my.cnf User-specific options

   Close




    Quit
User administration
Home Page
                shell> mysql -u root mysql
                mysql> SET PASSWORD FOR
 Title Page
                    ->   root@localhost=PASSWORD(’new_password’);

                shell> mysqladmin -u root password new_password

                mysql> GRANT ALL PRIVILEGES ON *.* TO monty@localhost
Page 31 of 39
                    ->   IDENTIFIED BY ’some_pass’ WITH GRANT OPTION;
                mysql> GRANT ALL PRIVILEGES ON foo.* TO bar@"%"
  Go Back
                    ->   IDENTIFIED BY ’some_pass’;
                mysql> GRANT USAGE ON *.* TO simpleton@some.server
 Full Screen        ->   IDENTIFIED BY ’some_pass’;

   Close




    Quit
Home Page




 Title Page
                                      MySQL Privilege System
                Managed by tables in the database called mysql.
                user global privileges of each user.
                db which user can access which database from which host.
Page 32 of 39
                host extension to db for multiple hosts.
  Go Back




 Full Screen




   Close




    Quit
Home Page                          Data, Databases and Tables

 Title Page
                • SQL - Structured Query Language
                • Queries such as create, delete, select, update, insert, etc.
                • Numeric Datatypes - INT, BIGINT, TINYINT, FLOAT, DECIMAL,
                  etc
Page 33 of 39   • String Datatypes - CHAR, VARCHAR, TEXT, BLOB
                • ENUM and SET - “one”, “two”, “three”
  Go Back

                • DATETIME, DATE, TIMESTAMP
 Full Screen




   Close




    Quit
MySQL databases
                mysql> SHOW DATABASES;
Home Page       +----------+
                | Database |
 Title Page     +----------+
                | mysql    |
                | test     |
                | tmp      |
                +----------+

Page 34 of 39
                mysql> CREATE DATABASE menagerie;
                mysql> USE menagerie
  Go Back
                Database changed
 Full Screen
                mysql> SHOW TABLES;
                Empty set (0.00 sec)
   Close




    Quit
Home Page




 Title Page




                Putting it together


Page 35 of 39




  Go Back




 Full Screen




   Close




    Quit
Home Page


                                            Resources
 Title Page

                The resources listed here are usually installed on the system, under
                /usr/share/doc/
                 • The Apache Manual http://httpd.apache.org/
                 • The PHP Manual http://www.php.net/manual/en/
Page 36 of 39
                 • The MySQL Manual
  Go Back
                   http://www.mysql.com/documentation/

 Full Screen




   Close




    Quit
Home Page




 Title Page




                RTFM

Page 37 of 39




  Go Back




 Full Screen




   Close




    Quit
Home Page




 Title Page




                Thanks..
Page 38 of 39




  Go Back




 Full Screen




   Close




    Quit
Home Page




 Title Page




Page 39 of 39




  Go Back




 Full Screen




   Close




    Quit

Weitere ähnliche Inhalte

Was ist angesagt?

Apache web server
Apache web serverApache web server
Apache web server
zrstoppe
 
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find Them
Ross Wolf
 
Configuring the Apache Web Server
Configuring the Apache Web ServerConfiguring the Apache Web Server
Configuring the Apache Web Server
webhostingguy
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
Vadym Lotar
 

Was ist angesagt? (20)

Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server Tutorial
 
Apache ppt
Apache pptApache ppt
Apache ppt
 
Apache web server
Apache web serverApache web server
Apache web server
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Chef for DevOps - an Introduction
Chef for DevOps - an IntroductionChef for DevOps - an Introduction
Chef for DevOps - an Introduction
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find Them
 
An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...
An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...
An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...
 
Configuring the Apache Web Server
Configuring the Apache Web ServerConfiguring the Apache Web Server
Configuring the Apache Web Server
 
SecDevOps
SecDevOpsSecDevOps
SecDevOps
 
Xampp Ppt
Xampp PptXampp Ppt
Xampp Ppt
 
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
 
Exploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in JavaExploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in Java
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command Line
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
 
Attribute-Based Access Control in Symfony
Attribute-Based Access Control in SymfonyAttribute-Based Access Control in Symfony
Attribute-Based Access Control in Symfony
 
System Hardening Using Ansible
System Hardening Using AnsibleSystem Hardening Using Ansible
System Hardening Using Ansible
 

Ähnlich wie Linux, Apache, Mysql, PHP

symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Fabien Potencier
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
Jeanho Chu
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
Jeanho Chu
 

Ähnlich wie Linux, Apache, Mysql, PHP (20)

Front end for back end developers
Front end for back end developersFront end for back end developers
Front end for back end developers
 
Presentation on php and Javascript
Presentation on php and JavascriptPresentation on php and Javascript
Presentation on php and Javascript
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Surviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studySurviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-study
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
 
Fundamentals of web_design_v2
Fundamentals of web_design_v2Fundamentals of web_design_v2
Fundamentals of web_design_v2
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb
 
Lecture 7: Server side programming
Lecture 7: Server side programmingLecture 7: Server side programming
Lecture 7: Server side programming
 
Building dynamic websites with Mod perl and apache
Building dynamic websites with Mod perl and apacheBuilding dynamic websites with Mod perl and apache
Building dynamic websites with Mod perl and apache
 
Intro to Dynamic Web Pages
Intro to Dynamic Web PagesIntro to Dynamic Web Pages
Intro to Dynamic Web Pages
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance Drupal
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
02 intro
02   intro02   intro
02 intro
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
 
Cloud Computing in Systems Programming Curriculum
Cloud Computing in Systems Programming CurriculumCloud Computing in Systems Programming Curriculum
Cloud Computing in Systems Programming Curriculum
 
Lecture8
Lecture8Lecture8
Lecture8
 

Mehr von webhostingguy

Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
webhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
webhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
webhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
webhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
webhostingguy
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
webhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
webhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
webhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
webhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
webhostingguy
 

Mehr von webhostingguy (20)

File Upload
File UploadFile Upload
File Upload
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
 
Notes8
Notes8Notes8
Notes8
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
 

Linux, Apache, Mysql, PHP

  • 1. Home Page Title Page Linux, Apache, Mysql, PHP Sameer D. Sahasrabuddhe KReSIT, IIT Bombay Page 1 of 39 http://www.it.iitb.ac.in/˜sameerds/ Go Back Full Screen Close Quit
  • 2. Home Page Title Page The World Wide Web Page 2 of 39 Go Back Full Screen Close Quit
  • 3. Home Page Client-Server Architecture Title Page • Server: provides services. • Client: generates requests for services. • May or may not run on the same machine. Page 3 of 39 • Typically, they use a standard protocol for communication. • For example, Apache is a webserver, the browser is a client and the Go Back protocol used is HTTP. Full Screen Close Quit
  • 4. What’s a webserver? Home Page • A processs that responds to requests for resources on port 80. Title Page • Typical requests are for hypertext files and related objects. • The client uses a Universal Resource Locator (URL). • Example - http://www.kernel.org/pub/ • A typical HTTP transaction: Page 4 of 39 1. The browser (client) makes a request to the website. Go Back 2. The webserver looks up the resource specified. 3. The webserver reads/generates the corresponding content and Full Screen sends it to the browser (client). Close Quit
  • 5. The Apache HTTP Server Home Page Title Page • The number one http server on the Internet - 63% websites, as of August 2002. • A project of the Apache Software Foundation. • Provides full source code and comes with an unrestrictive license - the Apache Software License. Page 5 of 39 • Runs on Windows NT/9x, Netware 5.x and above, OS/2, and most versions of Unix, as well as several other operating systems. Go Back • Can be customised by writing “modules” using the Apache module Full Screen API. Close Quit
  • 6. What are modules? Home Page Apache’s functionality is contained in modules that you can choose to Title Page include or exclude. Types of modules static modules compiled into the httpd binary. Page 6 of 39 dynamic modules stored separately and can be optionally loaded at run- time. Go Back third-party modules modules that are not included in the standard Full Screen Apache HTTP Server distribution. Close Quit
  • 7. Home Page Title Page Some common modules mod cgi Execution of CGI scripts. mod imap Server-side imagemap processing. mod include Server-parsed html documents (Server Side Includes). Page 7 of 39 mod php Server-side scripting in PHP (PHP Hypertext Preprocessor). Go Back Full Screen Close Quit
  • 8. Home Page Controlling Apache Title Page /etc/httpd/conf/httpd.conf The configuration file for the Apache HTTP server. .htaccess File used to control Apache’s behaviour on a per-directory ba- sis. Page 8 of 39 /etc/init.d/httpd Script used to control the httpd process - start, stop, restart, reload, status. Go Back /var/log/httpd/ Contains the Apache logs - error.log, access.log Full Screen Close Quit
  • 9. Home Page Apache content Title Page /var/www/html/ The “DocumentRoot” - all websites are served from here by default. $home/public html/ User’s directory for serving webpages. For exam- ple, http://www.it.iitb.ac.in/˜sameerds/ is served Page 9 of 39 from /home/sameerds/public html/ index.html “DirectoryIndex” that is used by default when a request Go Back specifies a directory. Full Screen Close Quit
  • 10. Dynamic Content Generation Home Page • Client-Server decoupling: the client never knows the physical format Title Page of a resource. • The reply to a request is a data stream from the server. • The server may transparently create or modify data. Even images can be generated on the fly! • This can be done in several ways: Page 10 of 39 1. CGI - Common Gateway Interface to external programs. Go Back 2. SSI - Server-Side Includes. 3. Server Side Scripts - the most flexible way to use dynamically Full Screen generated webpages. Close Quit
  • 11. Home Page Title Page PHP: Hypertext Preprocessor Page 11 of 39 Go Back Full Screen Close Quit
  • 12. Home Page What is it? Title Page • A general purpose scripting language that is especially good for server-side scripting. • A project maintained by the Apache Software Foundation. • All major operating systems - Linux, many Unix variants, Microsoft Windows, Mac OS X, RISC OS, and probably others. Page 12 of 39 • All major webservers - Apache, Microsoft IIS, PWS, Netscape and Go Back iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, Omni- HTTPd, and many others. Full Screen Close Quit
  • 13. Home Page What can PHP do? Title Page • Server-side scripting. • Command line scripting. • Writing client-side GUI applications: PHP-Gtk • Text processing features such as PCRE’s, XML documents, XSLT Page 13 of 39 transformation. Go Back • Abilities also included generating images, PDF files and even Flash movies, on the fly. Full Screen Close Quit
  • 14. External services Home Page Title Page • Database connectivity – A wide range of databases - MySQL, PostgreSQL, Informix, ODBC, Oracle ... too many more to list. – DBX and ODBC interfaces, that allow scripting independent of the database backends. Page 14 of 39 • Network services such as IMAP, POP, SMTP, DNS, LDAP, SNMP etc. as well as raw TCP sockets! Go Back • Support for instantiating Java objects, remote CORBA objects, and Full Screen COM on windows. Close Quit
  • 15. PHP on the Web Home Page PHP can be directly embedded in HTML markup. Title Page <html> <head> <title>Hello World!</title> </head> <body> Page 15 of 39 <?php echo "Hi, I’m a PHP script!"; Go Back ?> Full Screen </body> </html> Close Quit
  • 16. Home Page PHP on the Web (continued) Title Page <html> <head> <title>Hello World!</title> </head> <body> Page 16 of 39 Hi, I’m a PHP script! </body> Go Back </html> Full Screen Close Quit
  • 17. Home Page Language features Title Page • Variables - pre-defined, external, user-defined, variable variables, ref- erences. • Standard data-types such as booleans, integers, floating point num- bers, strings and arrays. Page 17 of 39 • Control structures - if-then-else while, do-while, switch, foreach. Go Back • Functions - user-defined functions similar to C, variable functions. Full Screen Close Quit
  • 18. Variables in PHP Home Page Variable variables! $foo = "bar"; Title Page $$foo = "value"; The result is that the variable $bbar, gets the value value. References Page 18 of 39 <?php $foo = ’Bob’; Go Back $bar = &$foo; $bar = "My name is $bar"; Full Screen echo $bar; echo $foo; Close ?> Quit
  • 19. Arrays $a = array( 1 => ’one’, Home Page 2 => ’two’, 3 =>’three’ ); Title Page $a[1] = ’one’; $a[2] = ’two’; $a[3] = ’three’; $a[] = ’four’; $a = array( ’color’ => ’red’ Page 19 of 39 , ’taste’ => ’sweet’ , ’shape’ => ’round’ Go Back , ’name’ => ’apple’ , 4 Full Screen ); Close $a[] = ’four’; Quit
  • 20. Home Page Arrays functions unset ($a[’color’]); Title Page reset ($a); while (list($key, $value) = each ($a)) { echo "Key: $key; Value: $value<br>n"; } Page 20 of 39 foreach ($a as $key => $value) { Go Back echo "Key: $key; Value: $value<br>n"; } Full Screen Close Quit
  • 21. Functions <?php function foo() Home Page { echo "In foo()<br>n"; Title Page } function bar($arg = ’’) { echo "In bar(), with ’$arg’.<br>n"; } Page 21 of 39 foo(); Go Back $func = ’foo’; $func(); Full Screen bar(’test’); $func = ’bar’; $func(’test’); Close ?> Quit
  • 22. OOP in PHP <?php class Cart Home Page { var $items; Title Page ... function add_item ($artnr, $num) { ... } function remove_item ($artnr, $num) { ... } } Page 22 of 39 $cart = new Cart; Go Back $cart->add_item("10", 1); Full Screen $another_cart = new Cart; $another_cart->add_item("0815", 3); Close ?> Quit
  • 23. HTML Forms <form action="foo.php" method="post"> Name: <input type="text" name="username"><br> Home Page Email: <input type="text" name="email"><br> <input type="submit" name="submit"> Title Page </form> <?php print $_POST[’username’]; print $_REQUEST[’username’]; Page 23 of 39 // g, p and c type variables: import_request_variables(’p’, ’p_’); Go Back print $p_username; Full Screen print $HTTP_POST_VARS[’username’]; print $username; Close ?> Quit
  • 24. Home Page Session handling Title Page • A way to preserve certain data across subsequent accesses. • A visitor accessing your web site is assigned a unique session id, which is used in two ways. • Cookies that are stored on the client, to be read on subsequent ac- Page 24 of 39 cesses. Go Back • Session ID’s that are propagated in the URL - more reliable. Full Screen Close Quit
  • 25. Home Page Session example <?php Title Page session_register ("count"); $count++; ?> Hello visitor, you have seen this page <?php echo $count; ?> times.<p> Page 25 of 39 To continue, Go Back <A HREF="nextpage.php?<?=SID?>"> click here</A> Full Screen Close Quit
  • 26. Cookies Home Page • A mechanism for storing data in the client. Title Page • Any cookies sent from the client will automatically be turned into a PHP variable. setcookie ("cookie[three]", "cookiethree"); setcookie ("cookie[two]", "cookietwo"); setcookie ("cookie[one]", "cookieone"); Page 26 of 39 if (isset ($cookie)) { while(list ($name, $value) = each($cookie)) { Go Back echo "$name == $value<br>n"; } Full Screen } Close Quit
  • 27. Home Page Title Page MySQL Page 27 of 39 Go Back Full Screen Close Quit
  • 28. Home Page What is it? Title Page • The most popular Open Source SQL database. • Developed, distributed and supported by MySQL AB. • Several different client programs, libraries and administrative tools.. Page 28 of 39 • A wide range of programming interfaces (APIs). • Works on a wide range of operating systems including Windows, Go Back Unix variants, Mac OS X, etc. Full Screen Close Quit
  • 29. Installation Home Page • Installation on Red Hat Linux is a breeze, using rpms for mysql, Title Page mysql-server and mysqlclient. • Control script - /etc/init.d/mysqld. • Users on the server are distinct from those on the system. • The user accounts and database details are stored in a database called Page 29 of 39 mysql. • All other users are created and controlled by the mysql root. Go Back • Users can create databases, tables, other users, etc depending on priv- Full Screen ileges provided by the root. Close Quit
  • 30. Using the mysql client Home Page Use mysql to connect to a MySQL server. shell> mysql -h host -u user -p Title Page shell> mysql -h host -u user -p < batch-file Configuration files /etc/my.cnf Global options Page 30 of 39 DATADIR/my.cnf Server-specific options Go Back defaults-extra-file The file specified with –defaults-extra-file=# Full Screen /.my.cnf User-specific options Close Quit
  • 31. User administration Home Page shell> mysql -u root mysql mysql> SET PASSWORD FOR Title Page -> root@localhost=PASSWORD(’new_password’); shell> mysqladmin -u root password new_password mysql> GRANT ALL PRIVILEGES ON *.* TO monty@localhost Page 31 of 39 -> IDENTIFIED BY ’some_pass’ WITH GRANT OPTION; mysql> GRANT ALL PRIVILEGES ON foo.* TO bar@"%" Go Back -> IDENTIFIED BY ’some_pass’; mysql> GRANT USAGE ON *.* TO simpleton@some.server Full Screen -> IDENTIFIED BY ’some_pass’; Close Quit
  • 32. Home Page Title Page MySQL Privilege System Managed by tables in the database called mysql. user global privileges of each user. db which user can access which database from which host. Page 32 of 39 host extension to db for multiple hosts. Go Back Full Screen Close Quit
  • 33. Home Page Data, Databases and Tables Title Page • SQL - Structured Query Language • Queries such as create, delete, select, update, insert, etc. • Numeric Datatypes - INT, BIGINT, TINYINT, FLOAT, DECIMAL, etc Page 33 of 39 • String Datatypes - CHAR, VARCHAR, TEXT, BLOB • ENUM and SET - “one”, “two”, “three” Go Back • DATETIME, DATE, TIMESTAMP Full Screen Close Quit
  • 34. MySQL databases mysql> SHOW DATABASES; Home Page +----------+ | Database | Title Page +----------+ | mysql | | test | | tmp | +----------+ Page 34 of 39 mysql> CREATE DATABASE menagerie; mysql> USE menagerie Go Back Database changed Full Screen mysql> SHOW TABLES; Empty set (0.00 sec) Close Quit
  • 35. Home Page Title Page Putting it together Page 35 of 39 Go Back Full Screen Close Quit
  • 36. Home Page Resources Title Page The resources listed here are usually installed on the system, under /usr/share/doc/ • The Apache Manual http://httpd.apache.org/ • The PHP Manual http://www.php.net/manual/en/ Page 36 of 39 • The MySQL Manual Go Back http://www.mysql.com/documentation/ Full Screen Close Quit
  • 37. Home Page Title Page RTFM Page 37 of 39 Go Back Full Screen Close Quit
  • 38. Home Page Title Page Thanks.. Page 38 of 39 Go Back Full Screen Close Quit
  • 39. Home Page Title Page Page 39 of 39 Go Back Full Screen Close Quit