SlideShare uma empresa Scribd logo
1 de 46
Baixar para ler offline
Introduction to LAMP
    Cory Aitchison
   Software Engineer
        Novell Inc.
 caitchison@novell.com

March 24, 2006
Session Overview

    •   Introduction to LAMP
    •   Installation on OES Linux
    •   Optimization
    •   Some available applications
    •   Migration
    •   Creating Lamp Applications




2   © Novell Inc, Confidential & Proprietary
Introduction to LAMP
What is LAMP

    •   LAMP is a framework for developing and web
        applications rapidly
    •   LAMP stands for
        –   Linux
        –   Apache
        –   MySQL
        –   PHP (or Perl or Python)
    •   Each one of these components of the LAMP stack is
        interchangable



4   © Novell Inc, Confidential & Proprietary
Stack Model


                                                Apache


                                               mod_php


                                                 PHP


                                                MySQL


                                               Linux/OES


                                               Hardware


5   © Novell Inc, Confidential & Proprietary
Stack Model – MySQL

    You can use any database in place of MySQL:
       •    Oracle*
       •    PostgreSQL
       •    Access
       •    DB/2*


    MySQL is generally preferred for the following reasons:
        •   Ease of use
        •   Good documentation
        •   Open Source
        •   4.0.18

6   © Novell Inc, Confidential & Proprietary
Stack Model - PHP

    When people talk about LAMP the language
    generally referenced is PHP. Although, it is
    possible to use any web ready language at this
    point in the stack.
        •   OES Version 4.3.4
        •   Excellent documentation at http://www.php.net
        •   A lot of support in the open source community
        •   (http://hotscripts.com)
        •   Tight integration with Apache through mod_php
        •   You must take care of security concerns




7   © Novell Inc, Confidential & Proprietary
Stack Model - Apache

    Again here you could use any webserver, however, apache
     is perhaps the best and most widely used webserver
     available
        •   Highly configurable
        •   Very flexible
        •   Large market share
        •   OES Version 2.0.49




8   © Novell Inc, Confidential & Proprietary
Installation
OES Linux Installation

     •   During install ensure that required packages have
         been selected
         –   apache2-prefork
         –   mysql
         –   php4
         –   apache2-mod-php4
         –   php4-mysql
         –   php4-session
         –   php4-sockets
         –   php4-zlib



10   © Novell Inc, Confidential & Proprietary
OES Linux Installation

     •   Some additional configuration is helpful.
     •   Create the file /etc/apache2/httpd.conf.local
     •   Add the line:
         DirectoryIndex index.html index.php
     •   Edit the file /etc/sysconfig/apache2
     •   Add /etc/apache2/httpd.conf.local to the
         APACHE_CONG_INCLUDE_FILES line




11   © Novell Inc, Confidential & Proprietary
Errata

     •   Most services run in user space.
     •   Kernel is isolated from processes
     •   Development can be done on server
     •   Can be used as a desktop
     •   Admin skills are similar for desktop and server
     •   Easy to configure




12   © Novell Inc, Confidential & Proprietary
Apache
Apache

     •   Most popular web server on the planet
     •   Highly configurable
     •   can be clustered
     •   open source
     •   many modules and management applications
         available
     •   http://httpd.apache.org/




14   © Novell Inc, Confidential & Proprietary
Popular Apache Modules

     •   mod_rewrite
     •   mod_php
     •   prefork
     •   mod_auth
     •   mod_cgi
     •   optimization modules in following slides




15   © Novell Inc, Confidential & Proprietary
Apache Optimization

     •   Mod_Mem_Cache – Memory based storage manager
         (Experimental)
         –   CacheEnable – Enables memory or disk based caching
         –   MCacheSize - maximum amount of memory to be used by the
             cache (in Kbytes)
         –   MCacheMaxObjectCount - maximum number of objects to be
             cached
         –   MCacheMinObjectSize - minimum size of a document (in bytes)
         –   MCacheMaxObjectSize – maximum allowable size of a
             document (in bytes)
         –   http://httpd.apache.org/docs-2.0/mod/mod_mem_cache.html



16   © Novell Inc, Confidential & Proprietary
Apache Optimization

     •   Mod_Disk_Cache – Disk based storage manager (Experimental)
         –   CacheEnable
         –   CacheSize
         –   CacheMinFileSize
         –   CacheMaxFileSize
         –   http://httpd.apache.org/docs-2.0/mod/mod_disk_cache.html




17   © Novell Inc, Confidential & Proprietary
Apache Optimization

     •   Load Balancing with Mod_Proxy
         –   Most effect in environments where there is a lot of dynamic
             content in a distributed environment
         –   Disable forward proxy with “ProxyRequests Off”
         –   Redirect requests to the specific backend servers with
             “ProxyPass”
         –   Allow redirection headers to be fixed up with
             “ProxyPassReverse”
         –   Use in conjunction with mod_mem_cache
         –   http://httpd.apache.org/docs-2.0/mod/mod_proxy.html
     •       Logging
         –   LogLevel Directive (ie LogLevel error)
18   © Novell Inc, Confidential & Proprietary
Apache Configuration

     •   The configuration for apache is handled in many
         different files on SLES and therefore on OES. The
         main ones are
     •   /etc/apache/httpd.conf
     •   /etc/apache/httpd.conf.local
     •   /etc/apache/conf.d/*
     •   /etc/sysconfig/apache2




19   © Novell Inc, Confidential & Proprietary
Apache Configuration

     •   /etc/apache/httpd.conf

     •   Don't edit this file. It is owned by the apache package
         and will be over written if you install an update.

     •   /etc/apache/httpd.conf.local

     •   This is where you should make changes to you server
         as it is parsed after /etc/apache/httpd.conf




20   © Novell Inc, Confidential & Proprietary
Apache Configuration

     •   /etc/apache/conf.d/*
     •   All conf files in this directory are parsed. This is the
         best place to put specific module configuration (ala
         jk.conf)
     •


     •   /etc/sysconfig/apache2
     •   You can tell apache which modules to load here, as
         well as what other conf files to parse.
     •


     •   Apache has a LOT of options. Far to many to discuss
         here.
21   © Novell Inc, Confidential & Proprietary
MySQL
MySQL

     •   Popular database
     •   a lot of traffic in news groups
     •   open source
     •   excellent management tools
         –   phpMyAdmin
     •   clusterable
     •   easy to optimize




23   © Novell Inc, Confidential & Proprietary
MySQL Optimization

     My.INI

      Variable                                  Default >512 MB >1 GB
      key_buffer_size                            16M    128 M   256M
      table_cache                                 64     128    256
      sort_buffer_size                           2M      4M     8M
      myisam_sort_buffer_size                    8M     32M     64M
      read_buffer_size                           128K    1M     2M

24   © Novell Inc, Confidential & Proprietary
MySQL Optimization

     •   Use Indexes!!! - unique if possible
     •   NOT NULL – especially with indexed columns
     •   Fixed length fields
     •   Use binary logging.
     •   Use OPTIMIZE to defragment table files
     •   Use ANALYZE to store key distributions
     •   Use default values
     •   Do not SELECT *
     •   Use EXPLAIN to see how queries are performed
     •   –log-slow-queries
25   © Novell Inc, Confidential & Proprietary
PHP
PHP

     •   Very easy to use
     •   Powerful mysql integration
     •   Simple HTML integration
     •   Tied tightly to Apache
     •   Easy application deployment




27   © Novell Inc, Confidential & Proprietary
Scripting Optimization

     •   The default setting are good but you can make some
         changes (for example logging, memory usage, how
         long a script can run, . . .)
     •   In general let MySQL do the work for you. If you write
         good queries and have optimized your tables you will
         be in good shape.




28   © Novell Inc, Confidential & Proprietary
PHP Pages



     It is remarkably easy to combine php and html and have
     Apache render the pages for you correctly.

     You embed php into a page by surrounding your code with a
     scriptlet tag. In the case of php you use:

                       <?php . . . ?>




29   © Novell Inc, Confidential & Proprietary
PHP Pages



     So our first php program could look something like this:

                      <?php
                                        echo “Hello World”;
                      ?>

     As you may be able to guess this code would render Hello
     World in a browser.




30   © Novell Inc, Confidential & Proprietary
PHP Pages


     If we wanted to make this page compliant to the XHTML
     spec it would look something like this:

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     <html>
     <head><title>NDK Self Service</title></head>
     <body>
               <?php
                       echo “<div>Hello World</div>”;
               ?>
     </body>
     </html>



31   © Novell Inc, Confidential & Proprietary
PHP Pages


     We can do most anything inside those <?php . . . ?> tags
     that any programming language can:

       •conditional logic
       •loops
       •variables
       •objects
       •arrays
       •parameter passing (via gets             and posts)
       •and the list goes on and on




32   © Novell Inc, Confidential & Proprietary
PHP Pages


     We can do most anything inside those <?php . . . ?> tags
     that any programming language can:

       •conditional logic
       •loops
       •variables
       •objects
       •arrays
       •parameter passing (via gets             and posts)
       •and the list goes on and on




33   © Novell Inc, Confidential & Proprietary
PHP – MySQL Functions

     •   mysql_affected_rows                    •   mysql_fetch_field       •   mysql_info
     •   mysql_change_user                      •   mysql_fetch_lengths     •   mysql_insert_id
     •   mysql_client_encoding                  •   mysql_fetch_object      •   mysql_list_dbs
     •   mysql_close                            •   mysql_fetch_row         •   mysql_list_processes
     •   mysql_connect                          •   mysql_field_flags       •   mysql_num_fields
     •   mysql_create_db                        •   mysql_field_len         •   mysql_num_rows
     •   mysql_data_seek                        •   mysql_field_name        •   mysql_pconnect
     •   mysql_db_name                          •   mysql_field_seek        •   mysql_ping
     •   mysql_db_query                         •   mysql_field_table       •   mysql_query
     •   mysql_drop_db                          •   mysql_field_type        •   mysql_real_escape_string
     •   mysql_errno                            •   mysql_free_result       •   mysql_result
     •   mysql_error                            •   mysql_get_client_info   •   mysql_select_db
     •   mysql_escape_string                        mysql_get_host_info
                                                •
                                                                            •   mysql_stat
     •   mysql_fetch_array                          mysql_get_proto_info
                                                •
                                                                            •   mysql_thread_id
     •   mysql_fetch_assoc                          mysql_get_server_info
                                                •
                                                                            •   mysql_unbuffered_query


34   © Novell Inc, Confidential & Proprietary
PHP – Common MySQL Functions
     •   resource mysql_connect ( [string server [, string username [, string password [,
         bool new_link [, int client_flags]]]]] )

     •   int mysql_errno ( [resource link_identifier] )

     •   string mysql_error ( [resource link_identifier] )

     •   array mysql_fetch_array ( resource result [, int result_type] )

     •   resource mysql_query ( string query [, resource link_identifier] )

     •   bool mysql_select_db ( string database_name [, resource link_identifier] )




35   © Novell Inc, Confidential & Proprietary
PHP – DB Query Example

     <?php

     //getting the return var is not strictly necessary
     $conn = mysql_connect('localhost', 'admin', 'novell');

     mysql_select_db('address_book', $conn);

     $sql =           'SELECT name, address, email ' .
                      ' FROM address_book ';

     $rs = mysql_query($sql, $conn);

     foreach (list($name, $address, $email) = mysql_fetch_row($rs))
     {
                echo ...
     }

     ?>


36   © Novell Inc, Confidential & Proprietary
PHP – HTTP Parameter Passing

     •   HTTP parameters are accessible via “superglobal”
         variables
     •   Use on of the following
         –   $_GET['<parameter name>']
         –   $_POST['<parameter name>']
         –   $_REQUEST['<parameter name>']
     •   It is better security to access your variables with
         $_GET or $_POST (and only once at that).




37   © Novell Inc, Confidential & Proprietary
Other Useful Functions

     •   phpinfo()
     This function display all sorts of useful information
      regarding your php setup, and is a great tool for
      debugging.

     •   var_dump()
     Allows you to see the contents and type of your var.




38   © Novell Inc, Confidential & Proprietary
Deploying a LAMP Application
Deploying a LAMP Application

     •   One of the nicest things about LAMP is how easy the
         applications are to deploy.
     •   If apache is set up correctly it is a simple matter of
         copying your files into the directory that you want your
         application to reside.
     •   You do not need to restart anything or deploy
         anything, just save and copy.




40   © Novell Inc, Confidential & Proprietary
Available Applications/Migration
Applications

     •   phpMyAdmin (http://www.phpmyadmin.net)
     •   xoops (http://www.xoops.org)
     •   Most everything at http://www.hotscripts.com/ should
         work.




42   © Novell Inc, Confidential & Proprietary
Migration




     Generally there are no migration issues. Some things you
     may want to look for in migrating a LAMP application are:

       Embedded path problems
       System calls




43   © Novell Inc, Confidential & Proprietary
References

     •   http://www.mysql.com
     •   http://www.php.net
     •   http://www.apache.org




44   © Novell Inc, Confidential & Proprietary
Unpublished Work of Novell, Inc. All Rights Reserved.
This work is an unpublished work and contains confidential, proprietary, and trade secret information of Novell,
Inc. Access to this work is restricted to Novell employees who have a need to know to perform tasks within the
scope of their assignments. No part of this work may be practiced, performed, copied, distributed, revised,
modified, translated, abridged, condensed, expanded, collected, or adapted without the prior written consent of
Novell, Inc. Any use or exploitation of this work without authorization could subject the perpetrator to criminal
and civil liability.

General Disclaimer
This document is not to be construed as a promise by any participating company to develop, deliver, or market
a product. Novell, Inc., makes no representations or warranties with respect to the contents of this document,
and specifically disclaims any express or implied warranties of merchantability or fitness for any particular
purpose. Further, Novell, Inc., reserves the right to revise this document and to make changes to its content,
at any time, without obligation to notify any person or entity of such revisions or changes. All Novell marks
referenced in this presentation are trademarks or registered trademarks of Novell, Inc. in the United States and
other countries. All third-party trademarks are the property of their respective owners.

Mais conteúdo relacionado

Mais procurados

Utosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptUtosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.ppt
webhostingguy
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
Luis Rodríguez Castromil
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
WordCamp Cape Town
 

Mais procurados (19)

Performance all teh things
Performance all teh thingsPerformance all teh things
Performance all teh things
 
Utosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptUtosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.ppt
 
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
 
Tomcatx performance-tuning
Tomcatx performance-tuningTomcatx performance-tuning
Tomcatx performance-tuning
 
Better encryption & security with MariaDB 10.1 & MySQL 5.7
Better encryption & security with MariaDB 10.1 & MySQL 5.7Better encryption & security with MariaDB 10.1 & MySQL 5.7
Better encryption & security with MariaDB 10.1 & MySQL 5.7
 
Sizing your alfresco platform
Sizing your alfresco platformSizing your alfresco platform
Sizing your alfresco platform
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin CharlesOSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin Charles
 
Bee con2016 presentation_20160125004_installing
Bee con2016 presentation_20160125004_installingBee con2016 presentation_20160125004_installing
Bee con2016 presentation_20160125004_installing
 
Guide to alfresco monitoring
Guide to alfresco monitoringGuide to alfresco monitoring
Guide to alfresco monitoring
 
201511 - Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...
201511 -  Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...201511 -  Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...
201511 - Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...
 
Top 15 MySQL parameters
Top 15 MySQL parameters Top 15 MySQL parameters
Top 15 MySQL parameters
 
Zend Core on IBM i - Security Considerations
Zend Core on IBM i - Security ConsiderationsZend Core on IBM i - Security Considerations
Zend Core on IBM i - Security Considerations
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
Scale ColdFusion with Terracotta Distributed Caching for Ehchache
Scale ColdFusion with Terracotta Distributed Caching for EhchacheScale ColdFusion with Terracotta Distributed Caching for Ehchache
Scale ColdFusion with Terracotta Distributed Caching for Ehchache
 
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
 
SharePoint is from Mars, SQL Server is from Venus (SQL Server for SharePoint ...
SharePoint is from Mars, SQL Server is from Venus (SQL Server for SharePoint ...SharePoint is from Mars, SQL Server is from Venus (SQL Server for SharePoint ...
SharePoint is from Mars, SQL Server is from Venus (SQL Server for SharePoint ...
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
 
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories. Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
 
NGINX 101 - now with more Docker
NGINX 101 - now with more DockerNGINX 101 - now with more Docker
NGINX 101 - now with more Docker
 

Destaque

Working withtables vi-draft1
Working withtables vi-draft1Working withtables vi-draft1
Working withtables vi-draft1
Vu Hung Nguyen
 
Working withtext vi-draft1
Working withtext vi-draft1Working withtext vi-draft1
Working withtext vi-draft1
Vu Hung Nguyen
 
Sharing fileswithmso users_vi-draft1
Sharing fileswithmso users_vi-draft1Sharing fileswithmso users_vi-draft1
Sharing fileswithmso users_vi-draft1
Vu Hung Nguyen
 
Sfd2012 Hanoi Nguyễn Vũ Hưng - Information Management with Redmine
Sfd2012 Hanoi Nguyễn Vũ Hưng - Information Management with RedmineSfd2012 Hanoi Nguyễn Vũ Hưng - Information Management with Redmine
Sfd2012 Hanoi Nguyễn Vũ Hưng - Information Management with Redmine
Vu Hung Nguyen
 
Sistemas de información
Sistemas de informaciónSistemas de información
Sistemas de información
Amado Aguilar
 

Destaque (17)

Nguyen Vu Hung: Giới thiệu OpenOffice.org Tiếng Việt tại Đại Học Sư Phạm
Nguyen Vu Hung: Giới thiệu OpenOffice.org Tiếng Việt tại Đại Học Sư PhạmNguyen Vu Hung: Giới thiệu OpenOffice.org Tiếng Việt tại Đại Học Sư Phạm
Nguyen Vu Hung: Giới thiệu OpenOffice.org Tiếng Việt tại Đại Học Sư Phạm
 
Các loại nghề Công nghệ Thông tin - Học gì lương cao
Các loại nghề Công nghệ Thông tin - Học gì lương caoCác loại nghề Công nghệ Thông tin - Học gì lương cao
Các loại nghề Công nghệ Thông tin - Học gì lương cao
 
Kỹ năng soạn thảo tiếng Việt
Kỹ năng soạn thảo tiếng ViệtKỹ năng soạn thảo tiếng Việt
Kỹ năng soạn thảo tiếng Việt
 
Vuhung xDay4 Định hướng nghề nghiệp cho người làm nghề CNTT
Vuhung xDay4 Định hướng nghề nghiệp cho người làm nghề CNTTVuhung xDay4 Định hướng nghề nghiệp cho người làm nghề CNTT
Vuhung xDay4 Định hướng nghề nghiệp cho người làm nghề CNTT
 
69 câu hỏi phỏng vấn kỹ sư Công nghệ Thông tin
69 câu hỏi phỏng vấn kỹ  sư Công nghệ Thông tin69 câu hỏi phỏng vấn kỹ  sư Công nghệ Thông tin
69 câu hỏi phỏng vấn kỹ sư Công nghệ Thông tin
 
Mindmap and Plan Planning
Mindmap and Plan PlanningMindmap and Plan Planning
Mindmap and Plan Planning
 
Working withtables vi-draft1
Working withtables vi-draft1Working withtables vi-draft1
Working withtables vi-draft1
 
Working withtext vi-draft1
Working withtext vi-draft1Working withtext vi-draft1
Working withtext vi-draft1
 
Sharing fileswithmso users_vi-draft1
Sharing fileswithmso users_vi-draft1Sharing fileswithmso users_vi-draft1
Sharing fileswithmso users_vi-draft1
 
06-2011-TT-BTTTT Quy định về lập và quản lý chi phí đầu tư ứng dụng công nghệ...
06-2011-TT-BTTTT Quy định về lập và quản lý chi phí đầu tư ứng dụng công nghệ...06-2011-TT-BTTTT Quy định về lập và quản lý chi phí đầu tư ứng dụng công nghệ...
06-2011-TT-BTTTT Quy định về lập và quản lý chi phí đầu tư ứng dụng công nghệ...
 
06-2011-TT-BTTTT Phụ lục số 2 PHƯƠNG PHÁP LẬP DỰ TOÁN ỨNG DỤNG CÔNG NGHỆ THÔN...
06-2011-TT-BTTTT Phụ lục số 2 PHƯƠNG PHÁP LẬP DỰ TOÁN ỨNG DỤNG CÔNG NGHỆ THÔN...06-2011-TT-BTTTT Phụ lục số 2 PHƯƠNG PHÁP LẬP DỰ TOÁN ỨNG DỤNG CÔNG NGHỆ THÔN...
06-2011-TT-BTTTT Phụ lục số 2 PHƯƠNG PHÁP LẬP DỰ TOÁN ỨNG DỤNG CÔNG NGHỆ THÔN...
 
Sfd2012 Hanoi Nguyễn Vũ Hưng - Information Management with Redmine
Sfd2012 Hanoi Nguyễn Vũ Hưng - Information Management with RedmineSfd2012 Hanoi Nguyễn Vũ Hưng - Information Management with Redmine
Sfd2012 Hanoi Nguyễn Vũ Hưng - Information Management with Redmine
 
VẤN ĐỀ BẢO VỆ AN TOÀN AN NINH DỮ LIỆU TRONG MẠNG LAN VÀ KẾT NỐI INTERNET TẠI ...
VẤN ĐỀ BẢO VỆ AN TOÀN AN NINH DỮ LIỆU TRONG MẠNG LAN VÀ KẾT NỐI INTERNET TẠI ...VẤN ĐỀ BẢO VỆ AN TOÀN AN NINH DỮ LIỆU TRONG MẠNG LAN VÀ KẾT NỐI INTERNET TẠI ...
VẤN ĐỀ BẢO VỆ AN TOÀN AN NINH DỮ LIỆU TRONG MẠNG LAN VÀ KẾT NỐI INTERNET TẠI ...
 
Capc historic
Capc historicCapc historic
Capc historic
 
Postales de filtros
Postales de filtrosPostales de filtros
Postales de filtros
 
Pepa y el tssaaf
Pepa y el tssaafPepa y el tssaaf
Pepa y el tssaaf
 
Sistemas de información
Sistemas de informaciónSistemas de información
Sistemas de información
 

Semelhante a Lamp Introduction 20100419

開放原始碼 Ch1.2 intro - oss - apahce foundry (ver 2.0)
開放原始碼 Ch1.2   intro - oss - apahce foundry (ver 2.0)開放原始碼 Ch1.2   intro - oss - apahce foundry (ver 2.0)
開放原始碼 Ch1.2 intro - oss - apahce foundry (ver 2.0)
My own sweet home!
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
Igor Anishchenko
 
06.m3 cms set-upwebserver
06.m3 cms set-upwebserver06.m3 cms set-upwebserver
06.m3 cms set-upwebserver
tarensi
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptx
SaziaRahman
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opm
isnull
 

Semelhante a Lamp Introduction 20100419 (20)

開放原始碼 Ch1.2 intro - oss - apahce foundry (ver 2.0)
開放原始碼 Ch1.2   intro - oss - apahce foundry (ver 2.0)開放原始碼 Ch1.2   intro - oss - apahce foundry (ver 2.0)
開放原始碼 Ch1.2 intro - oss - apahce foundry (ver 2.0)
 
Midwest PHP - Scaling Magento
Midwest PHP - Scaling MagentoMidwest PHP - Scaling Magento
Midwest PHP - Scaling Magento
 
Docker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHP
 
Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017
 
Tips and Tricks for the Advanced Mule Developer with Tesla and Twitter
Tips and Tricks for the Advanced Mule Developer with Tesla and Twitter Tips and Tricks for the Advanced Mule Developer with Tesla and Twitter
Tips and Tricks for the Advanced Mule Developer with Tesla and Twitter
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
 
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
 
06.m3 cms set-upwebserver
06.m3 cms set-upwebserver06.m3 cms set-upwebserver
06.m3 cms set-upwebserver
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptx
 
Linux basics (part 2)
Linux basics (part 2)Linux basics (part 2)
Linux basics (part 2)
 
Build Your Own PaaS, Just like Red Hat's OpenShift from LinuxCon 2013 New Orl...
Build Your Own PaaS, Just like Red Hat's OpenShift from LinuxCon 2013 New Orl...Build Your Own PaaS, Just like Red Hat's OpenShift from LinuxCon 2013 New Orl...
Build Your Own PaaS, Just like Red Hat's OpenShift from LinuxCon 2013 New Orl...
 
Hi! Ho! Hi! Ho! SQL Server on Linux We Go!
Hi! Ho! Hi! Ho! SQL Server on Linux We Go!Hi! Ho! Hi! Ho! SQL Server on Linux We Go!
Hi! Ho! Hi! Ho! SQL Server on Linux We Go!
 
Mini-Training: NancyFX
Mini-Training: NancyFXMini-Training: NancyFX
Mini-Training: NancyFX
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opm
 
Lamp
LampLamp
Lamp
 
Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdf
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 

Mais de Vu Hung Nguyen

Basic & Advanced Scrum Framework
Basic & Advanced Scrum FrameworkBasic & Advanced Scrum Framework
Basic & Advanced Scrum Framework
Vu Hung Nguyen
 
Anti patterns in it project management
Anti patterns in it project managementAnti patterns in it project management
Anti patterns in it project management
Vu Hung Nguyen
 

Mais de Vu Hung Nguyen (20)

Co ban horenso - Tai lieu training noi bo
Co ban horenso - Tai lieu training noi boCo ban horenso - Tai lieu training noi bo
Co ban horenso - Tai lieu training noi bo
 
Funix techtalk: Tự học hiệu quả thời 4.0
Funix techtalk: Tự học hiệu quả thời 4.0Funix techtalk: Tự học hiệu quả thời 4.0
Funix techtalk: Tự học hiệu quả thời 4.0
 
Học cờ cùng con - Nguyễn Vỹ Kỳ Anh [U8]
Học cờ cùng con - Nguyễn Vỹ Kỳ Anh [U8]Học cờ cùng con - Nguyễn Vỹ Kỳ Anh [U8]
Học cờ cùng con - Nguyễn Vỹ Kỳ Anh [U8]
 
Japanese for it bridge engineers
Japanese for it bridge engineersJapanese for it bridge engineers
Japanese for it bridge engineers
 
Basic IT Project Management Terminologies
Basic IT Project Management TerminologiesBasic IT Project Management Terminologies
Basic IT Project Management Terminologies
 
2018 Học cờ cùng con - Nguyễn Vũ Kỳ Anh [U7]
2018 Học cờ cùng con - Nguyễn Vũ Kỳ Anh [U7]2018 Học cờ cùng con - Nguyễn Vũ Kỳ Anh [U7]
2018 Học cờ cùng con - Nguyễn Vũ Kỳ Anh [U7]
 
Làm việc hiệu quả với sếp Nhật (2017)
Làm việc hiệu quả với sếp Nhật (2017)Làm việc hiệu quả với sếp Nhật (2017)
Làm việc hiệu quả với sếp Nhật (2017)
 
Problem Solving Skills (for IT Engineers)
Problem Solving Skills (for IT Engineers)Problem Solving Skills (for IT Engineers)
Problem Solving Skills (for IT Engineers)
 
Using Shader in cocos2d-x
Using Shader in cocos2d-xUsing Shader in cocos2d-x
Using Shader in cocos2d-x
 
Pham Anh Tu - TK Framework
Pham Anh Tu - TK FrameworkPham Anh Tu - TK Framework
Pham Anh Tu - TK Framework
 
My idol: Magnus Carlsen vs. Ky Anh 2G1 NGS Newton
My idol: Magnus Carlsen vs. Ky Anh 2G1 NGS NewtonMy idol: Magnus Carlsen vs. Ky Anh 2G1 NGS Newton
My idol: Magnus Carlsen vs. Ky Anh 2G1 NGS Newton
 
Basic advanced scrum framework
Basic advanced scrum frameworkBasic advanced scrum framework
Basic advanced scrum framework
 
FPT Univ. Talkshow IT khong chi la lap trinh
FPT Univ. Talkshow IT khong chi la lap trinhFPT Univ. Talkshow IT khong chi la lap trinh
FPT Univ. Talkshow IT khong chi la lap trinh
 
Basic & Advanced Scrum Framework
Basic & Advanced Scrum FrameworkBasic & Advanced Scrum Framework
Basic & Advanced Scrum Framework
 
Agile Vietnam Conference 2016: Recap
Agile Vietnam Conference 2016: RecapAgile Vietnam Conference 2016: Recap
Agile Vietnam Conference 2016: Recap
 
IT Public Speaking Guidelines
IT Public Speaking GuidelinesIT Public Speaking Guidelines
IT Public Speaking Guidelines
 
Kanban: Cơ bản và Nâng cao
Kanban: Cơ bản và Nâng caoKanban: Cơ bản và Nâng cao
Kanban: Cơ bản và Nâng cao
 
Học cờ vua cùng con Nguyễn Vũ Kỳ Anh (U6)
Học cờ vua cùng con Nguyễn Vũ Kỳ Anh (U6)Học cờ vua cùng con Nguyễn Vũ Kỳ Anh (U6)
Học cờ vua cùng con Nguyễn Vũ Kỳ Anh (U6)
 
Fuji Technology Workshop: Learning Skills
Fuji Technology Workshop: Learning SkillsFuji Technology Workshop: Learning Skills
Fuji Technology Workshop: Learning Skills
 
Anti patterns in it project management
Anti patterns in it project managementAnti patterns in it project management
Anti patterns in it project management
 

Lamp Introduction 20100419

  • 1. Introduction to LAMP Cory Aitchison Software Engineer Novell Inc. caitchison@novell.com March 24, 2006
  • 2. Session Overview • Introduction to LAMP • Installation on OES Linux • Optimization • Some available applications • Migration • Creating Lamp Applications 2 © Novell Inc, Confidential & Proprietary
  • 4. What is LAMP • LAMP is a framework for developing and web applications rapidly • LAMP stands for – Linux – Apache – MySQL – PHP (or Perl or Python) • Each one of these components of the LAMP stack is interchangable 4 © Novell Inc, Confidential & Proprietary
  • 5. Stack Model Apache mod_php PHP MySQL Linux/OES Hardware 5 © Novell Inc, Confidential & Proprietary
  • 6. Stack Model – MySQL You can use any database in place of MySQL: • Oracle* • PostgreSQL • Access • DB/2* MySQL is generally preferred for the following reasons: • Ease of use • Good documentation • Open Source • 4.0.18 6 © Novell Inc, Confidential & Proprietary
  • 7. Stack Model - PHP When people talk about LAMP the language generally referenced is PHP. Although, it is possible to use any web ready language at this point in the stack. • OES Version 4.3.4 • Excellent documentation at http://www.php.net • A lot of support in the open source community • (http://hotscripts.com) • Tight integration with Apache through mod_php • You must take care of security concerns 7 © Novell Inc, Confidential & Proprietary
  • 8. Stack Model - Apache Again here you could use any webserver, however, apache is perhaps the best and most widely used webserver available • Highly configurable • Very flexible • Large market share • OES Version 2.0.49 8 © Novell Inc, Confidential & Proprietary
  • 10. OES Linux Installation • During install ensure that required packages have been selected – apache2-prefork – mysql – php4 – apache2-mod-php4 – php4-mysql – php4-session – php4-sockets – php4-zlib 10 © Novell Inc, Confidential & Proprietary
  • 11. OES Linux Installation • Some additional configuration is helpful. • Create the file /etc/apache2/httpd.conf.local • Add the line: DirectoryIndex index.html index.php • Edit the file /etc/sysconfig/apache2 • Add /etc/apache2/httpd.conf.local to the APACHE_CONG_INCLUDE_FILES line 11 © Novell Inc, Confidential & Proprietary
  • 12. Errata • Most services run in user space. • Kernel is isolated from processes • Development can be done on server • Can be used as a desktop • Admin skills are similar for desktop and server • Easy to configure 12 © Novell Inc, Confidential & Proprietary
  • 14. Apache • Most popular web server on the planet • Highly configurable • can be clustered • open source • many modules and management applications available • http://httpd.apache.org/ 14 © Novell Inc, Confidential & Proprietary
  • 15. Popular Apache Modules • mod_rewrite • mod_php • prefork • mod_auth • mod_cgi • optimization modules in following slides 15 © Novell Inc, Confidential & Proprietary
  • 16. Apache Optimization • Mod_Mem_Cache – Memory based storage manager (Experimental) – CacheEnable – Enables memory or disk based caching – MCacheSize - maximum amount of memory to be used by the cache (in Kbytes) – MCacheMaxObjectCount - maximum number of objects to be cached – MCacheMinObjectSize - minimum size of a document (in bytes) – MCacheMaxObjectSize – maximum allowable size of a document (in bytes) – http://httpd.apache.org/docs-2.0/mod/mod_mem_cache.html 16 © Novell Inc, Confidential & Proprietary
  • 17. Apache Optimization • Mod_Disk_Cache – Disk based storage manager (Experimental) – CacheEnable – CacheSize – CacheMinFileSize – CacheMaxFileSize – http://httpd.apache.org/docs-2.0/mod/mod_disk_cache.html 17 © Novell Inc, Confidential & Proprietary
  • 18. Apache Optimization • Load Balancing with Mod_Proxy – Most effect in environments where there is a lot of dynamic content in a distributed environment – Disable forward proxy with “ProxyRequests Off” – Redirect requests to the specific backend servers with “ProxyPass” – Allow redirection headers to be fixed up with “ProxyPassReverse” – Use in conjunction with mod_mem_cache – http://httpd.apache.org/docs-2.0/mod/mod_proxy.html • Logging – LogLevel Directive (ie LogLevel error) 18 © Novell Inc, Confidential & Proprietary
  • 19. Apache Configuration • The configuration for apache is handled in many different files on SLES and therefore on OES. The main ones are • /etc/apache/httpd.conf • /etc/apache/httpd.conf.local • /etc/apache/conf.d/* • /etc/sysconfig/apache2 19 © Novell Inc, Confidential & Proprietary
  • 20. Apache Configuration • /etc/apache/httpd.conf • Don't edit this file. It is owned by the apache package and will be over written if you install an update. • /etc/apache/httpd.conf.local • This is where you should make changes to you server as it is parsed after /etc/apache/httpd.conf 20 © Novell Inc, Confidential & Proprietary
  • 21. Apache Configuration • /etc/apache/conf.d/* • All conf files in this directory are parsed. This is the best place to put specific module configuration (ala jk.conf) • • /etc/sysconfig/apache2 • You can tell apache which modules to load here, as well as what other conf files to parse. • • Apache has a LOT of options. Far to many to discuss here. 21 © Novell Inc, Confidential & Proprietary
  • 22. MySQL
  • 23. MySQL • Popular database • a lot of traffic in news groups • open source • excellent management tools – phpMyAdmin • clusterable • easy to optimize 23 © Novell Inc, Confidential & Proprietary
  • 24. MySQL Optimization My.INI Variable Default >512 MB >1 GB key_buffer_size 16M 128 M 256M table_cache 64 128 256 sort_buffer_size 2M 4M 8M myisam_sort_buffer_size 8M 32M 64M read_buffer_size 128K 1M 2M 24 © Novell Inc, Confidential & Proprietary
  • 25. MySQL Optimization • Use Indexes!!! - unique if possible • NOT NULL – especially with indexed columns • Fixed length fields • Use binary logging. • Use OPTIMIZE to defragment table files • Use ANALYZE to store key distributions • Use default values • Do not SELECT * • Use EXPLAIN to see how queries are performed • –log-slow-queries 25 © Novell Inc, Confidential & Proprietary
  • 26. PHP
  • 27. PHP • Very easy to use • Powerful mysql integration • Simple HTML integration • Tied tightly to Apache • Easy application deployment 27 © Novell Inc, Confidential & Proprietary
  • 28. Scripting Optimization • The default setting are good but you can make some changes (for example logging, memory usage, how long a script can run, . . .) • In general let MySQL do the work for you. If you write good queries and have optimized your tables you will be in good shape. 28 © Novell Inc, Confidential & Proprietary
  • 29. PHP Pages It is remarkably easy to combine php and html and have Apache render the pages for you correctly. You embed php into a page by surrounding your code with a scriptlet tag. In the case of php you use: <?php . . . ?> 29 © Novell Inc, Confidential & Proprietary
  • 30. PHP Pages So our first php program could look something like this: <?php echo “Hello World”; ?> As you may be able to guess this code would render Hello World in a browser. 30 © Novell Inc, Confidential & Proprietary
  • 31. PHP Pages If we wanted to make this page compliant to the XHTML spec it would look something like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head><title>NDK Self Service</title></head> <body> <?php echo “<div>Hello World</div>”; ?> </body> </html> 31 © Novell Inc, Confidential & Proprietary
  • 32. PHP Pages We can do most anything inside those <?php . . . ?> tags that any programming language can: •conditional logic •loops •variables •objects •arrays •parameter passing (via gets and posts) •and the list goes on and on 32 © Novell Inc, Confidential & Proprietary
  • 33. PHP Pages We can do most anything inside those <?php . . . ?> tags that any programming language can: •conditional logic •loops •variables •objects •arrays •parameter passing (via gets and posts) •and the list goes on and on 33 © Novell Inc, Confidential & Proprietary
  • 34. PHP – MySQL Functions • mysql_affected_rows • mysql_fetch_field • mysql_info • mysql_change_user • mysql_fetch_lengths • mysql_insert_id • mysql_client_encoding • mysql_fetch_object • mysql_list_dbs • mysql_close • mysql_fetch_row • mysql_list_processes • mysql_connect • mysql_field_flags • mysql_num_fields • mysql_create_db • mysql_field_len • mysql_num_rows • mysql_data_seek • mysql_field_name • mysql_pconnect • mysql_db_name • mysql_field_seek • mysql_ping • mysql_db_query • mysql_field_table • mysql_query • mysql_drop_db • mysql_field_type • mysql_real_escape_string • mysql_errno • mysql_free_result • mysql_result • mysql_error • mysql_get_client_info • mysql_select_db • mysql_escape_string mysql_get_host_info • • mysql_stat • mysql_fetch_array mysql_get_proto_info • • mysql_thread_id • mysql_fetch_assoc mysql_get_server_info • • mysql_unbuffered_query 34 © Novell Inc, Confidential & Proprietary
  • 35. PHP – Common MySQL Functions • resource mysql_connect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]] ) • int mysql_errno ( [resource link_identifier] ) • string mysql_error ( [resource link_identifier] ) • array mysql_fetch_array ( resource result [, int result_type] ) • resource mysql_query ( string query [, resource link_identifier] ) • bool mysql_select_db ( string database_name [, resource link_identifier] ) 35 © Novell Inc, Confidential & Proprietary
  • 36. PHP – DB Query Example <?php //getting the return var is not strictly necessary $conn = mysql_connect('localhost', 'admin', 'novell'); mysql_select_db('address_book', $conn); $sql = 'SELECT name, address, email ' . ' FROM address_book '; $rs = mysql_query($sql, $conn); foreach (list($name, $address, $email) = mysql_fetch_row($rs)) { echo ... } ?> 36 © Novell Inc, Confidential & Proprietary
  • 37. PHP – HTTP Parameter Passing • HTTP parameters are accessible via “superglobal” variables • Use on of the following – $_GET['<parameter name>'] – $_POST['<parameter name>'] – $_REQUEST['<parameter name>'] • It is better security to access your variables with $_GET or $_POST (and only once at that). 37 © Novell Inc, Confidential & Proprietary
  • 38. Other Useful Functions • phpinfo() This function display all sorts of useful information regarding your php setup, and is a great tool for debugging. • var_dump() Allows you to see the contents and type of your var. 38 © Novell Inc, Confidential & Proprietary
  • 39. Deploying a LAMP Application
  • 40. Deploying a LAMP Application • One of the nicest things about LAMP is how easy the applications are to deploy. • If apache is set up correctly it is a simple matter of copying your files into the directory that you want your application to reside. • You do not need to restart anything or deploy anything, just save and copy. 40 © Novell Inc, Confidential & Proprietary
  • 42. Applications • phpMyAdmin (http://www.phpmyadmin.net) • xoops (http://www.xoops.org) • Most everything at http://www.hotscripts.com/ should work. 42 © Novell Inc, Confidential & Proprietary
  • 43. Migration Generally there are no migration issues. Some things you may want to look for in migrating a LAMP application are: Embedded path problems System calls 43 © Novell Inc, Confidential & Proprietary
  • 44. References • http://www.mysql.com • http://www.php.net • http://www.apache.org 44 © Novell Inc, Confidential & Proprietary
  • 45.
  • 46. Unpublished Work of Novell, Inc. All Rights Reserved. This work is an unpublished work and contains confidential, proprietary, and trade secret information of Novell, Inc. Access to this work is restricted to Novell employees who have a need to know to perform tasks within the scope of their assignments. No part of this work may be practiced, performed, copied, distributed, revised, modified, translated, abridged, condensed, expanded, collected, or adapted without the prior written consent of Novell, Inc. Any use or exploitation of this work without authorization could subject the perpetrator to criminal and civil liability. General Disclaimer This document is not to be construed as a promise by any participating company to develop, deliver, or market a product. Novell, Inc., makes no representations or warranties with respect to the contents of this document, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. Further, Novell, Inc., reserves the right to revise this document and to make changes to its content, at any time, without obligation to notify any person or entity of such revisions or changes. All Novell marks referenced in this presentation are trademarks or registered trademarks of Novell, Inc. in the United States and other countries. All third-party trademarks are the property of their respective owners.