Open Source Software for the Web

Document Sample
Open Source Software for the Web Powered By Docstoc
					Open Source Software for
       the Web
     Modified 4/12/2005
Goals for Lesson
 Learn about the open source movement
 Learn about Apache web server initiative
 Learn about the origins of the Linux movement
 Learn history of Perl scripting language
 Study other modern web content creation and management
    MySQL Relational Database
 Learn about the synergistic effect from all this high quality
 and free software
Open Source
 Embodies the philosophy that “[computer] code should be
 free” and not restricted by law
 A reaction to closed and proprietary “shrink wrapped”
 With shrink wrapped software it becomes impossible to
 know how to fix a problem if you cannot inspect the
 original source code to determine the error
    If you have the code you can add features or fix bugs that become
    If you own the code you have options if a company goes out of
    business. You are not tied down to a particular vendor
Open Source Origins
 Started by Richard Stallman in 1984
 Stallman formed the Free Software Foundation
 Guiding principles:
   You have the freedom to run a program for any purpose
   You have the freedom to modify a program to suit your
   You have the freedom to redistribute copies of software
   you write, either for free or for a fee
   You have the freedom to distribute modified versions
   of software to the world, so the larger community can
GNU Movement
 GNU means “GNU is Not Unix”
 Stallman’s goal was to write a version of the UNIX
 operating system that was free and could be easily ported
 to various platforms
    UNIX was the dominant operating system at the time
 Started by working on the tools one would use to create an
 operating system
 First project was an open-source version of EMACS: a
 UNIX text editor
 Created a “copyleft” license: anyone could copy, modify,
 run or distribute the software but modified versions must
 be free
Free Software Foundation
 Manages GNU software movement
 Nonprofit organization
 Accepts donations
 Makes some money selling the code on media (CD-ROM
 etc.) and providing printed copies of documentation
 GNU C compiler was its first major accomplishment. It
 allowed other software to be written. Most open source
 software is written in C using GNU C.
    Example: Apache web server is largely implemented in GNU C.
Observations about Open Source
 Leverages the value of a much larger community
 of people
   Hundreds or thousands of people can inspect and
   improve the source code
 Often results in an increase in the quality of the
   Code is improved and optimized
 Increases the likelihood that the code will perform
 features relevant to a larger community
Observations about Open Source
 Typically open source code is used widely and is
 not narrow in focus
 Usually software companies will make a profit by
 building unique functionality on top of an open
 source architecture
   Example: Oracle 10g Application Server embeds the
   open source Apache Web Server
 All work is done on a volunteer basis
    Everyone gains with a quality finished product
Apache Web Server
 An “open source” web server
 Commands about 2/3 of the web server
 market (and holding steady)
 Evolved from the httpd (HTTP daemon)
 web server originally created by the
 National Center for Supercomputing
 Applications (NCSA)
   NCSA created the original Mosaic browser
Apache Web Server
 When NCSA work on httpd stalled, 8 core
 contributors to the project decided to enhance the
 software on their own
   NCSA is a non-profit organization so there were no
   copyright issues involved
 Since Apache extended the popular httpd web
 server with newer features it was instantly popular
   Most companies were not agile enough to create web
   server software at that time
Apache Web Server
 A meritocracy: the more work you do on the
 project, the more your input counts
 Group founders set the rules
 Only “active members” can change the rules
   To become an active member you must be voted in and
   heavily contribute to the project
 Software development is done using collaborative
 tools in a UNIX environment
 New releases are quickly ported over to dozens of
 different operating systems
Apache Web Server
 All work is done by volunteers
 Apache is free and open source software
 By keeping the software free it can be used by
 everyone and is egalitarian
   Rich and poor have equal access
   No group is discriminated against
   Apache web server is by far the best web server
   Microsoft IIS is second most popular, but has a history
   of major security problems
 Designed to be an “open source” version of Unix
 for the Intel 386 and subsequent processors
   In fact it is easily ported to lots of other processors.
   Linux can even run on mainframe computers.
 Basic idea: open source + stability of UNIX OS +
 low cost of Intel processors = one very high
 quality and cost free operating system for Intel
 based computers
   Hoping to be a “Microsoft Buster”
   Has not (yet) won the “desktop” OS war
   Seems to be winning the server war. Linux has the
   highest number of “new installs” on recently purchased
 Created by Linus Torvalds
   Student at University of Helsinki in Finland
 In 1991 he set out to create a Unix Kernel for the
 Intel processor that followed Open Source
   This was before the World Wide Web took off
   Used email to publicize his ideas to the computing
   Immediately got back a lot of support from around the
   Key license difference with GNU: the source code
   must remain free but it can be compiled and packaged
   by other vendors for money
Why use Linux?
 It is free
    Thousands of applications exist with equivalents for most
    Windows applications. Most of these applications are free
 It is stable
    Arguably it is the most stable operating system in production use
    Typically it can stay up for years at a time with no problems
    Can be upgraded without bringing down the machine.
 It is extremely powerful
    Its power grows every day with more contributions and more
    It inherits a stable UNIX legacy
 Ideal for hosting Apache Web Server
Linux + Apache
 The combination of Linux + Apache is a
 compelling base for managing a web site
   Linux is extremely stable and scalable
    • Won’t flake out under high loads
    • Free!
   Apache is a de-facto standard for web servers
    • Continuously upgraded
    • Free!
 For web hosting companies operating on small
 margins the combination is a “no brainer”
     Extending Apache + Linux
        Fairly simple            “Anyone who can read a book can
Programming interface   create web services” scripting language programmers

Various ways
 to make the              Perl          PHP        MySQL         Python
web dynamic

    Ubiquity                          Apache Web Server

     Stability                     Linux Operating System

    Open Source for the Web: It’s mostly free and very robust!
 One of the oldest of scripting languages
   Created by Larry Wall in 1987
 Essentially joins together a lot of text processing
 capabilities available in various UNIX utilities
 into one scripting language
 Open source software
 A scripting language: no compilation necessary
   You get ugly error messages when you try to run a Perl
   program and your syntax is wrong
   You go fix and retest
   Consequently need to do extensive testing before
Perl Uses
 One of the earliest tools for creating dynamic web content
    While not designed for the web, it was widely available, handy and
    well known, so it was used
 Great for file or text manipulation
    Excellent pattern matching capabilities
 Good for doing “quick and dirty” programs
 Database access is possible, but not its primary focus
 One of the best “glue” languages out there
    Glue languages join together operating systems and a variety of
    other programming languages and system utilities
 An “all-in-one Swiss army knife” for software
 Software usually has a .pl extension
Perl History
 Really begins with Version 3.0 in 1989
 Version 4.0 in 1991 is still widely used
 Version 5.000 released in 1994 is the most
 current version
 5.8.5 was last release
 5.004 (June 1997) or above is a generally
 needed to run most prewritten Perl software
Perl Pros and Cons
   Most web servers support it or can support it easily
    • It often comes bundled and automatically installed with the
      server operating system
   Continuously updated
   Open source and free
   Long legacy
   Extensive software available, much of it free
    • See:
      (over 4100 scripts available)
Perl Pros and Cons
   Somewhat slow because it is interpreted and not
   A separate process is spawned each time it is called,
   potentially bogging down a server if Perl is used
    • ModPerl is a CGI extension which can make Perl run quicker
      and allows for multithreading, but must be written for ModPerl
   Difficult for more modern uses including integrating
   with relational databases, Java and XML
    • Python or PHP is a better solution for those starting from
PHP = Personal Home Page
   Acronym doesn’t make much sense!
A scripting language designed for the web
Designed similar to Active Server Pages
   You embed PHP commands into your web pages
Commands are preprocessed by the PHP processor and
appropriate HTML is sent to the web server
Lots of free or low cost software:
   lists over 8500 programs
   PostNuke is an excellent example of top quality PHP software:
   free portal software!
Why use PHP?
 Allows for embedding dynamic code inside
 Unlike ASP it is cross platform
   ASP generally works only in Microsoft web servers
 It is much more powerful than ASP
 It is elegant and easy to use for most programmers
 It follows many C programming language
 constructs, so it is easy to pick up
 It is “object based” so it is very powerful and
 offers modular features
                          Start of PHP Code Indentifier
PHP Example
   if ($title <> "")
     echo("Thank you for your donation!");
</title>             End of PHP Code Identifier
PHP Architecture

                Allow for plug in
               for other interfaces

  PHP Process Flow
                                                Raw .php source
  HTML is substituted for PHP code

                     HTML                   Pre-
                                          processor        .php
          Internet                                        source
Browser                     Server

                            Request for .php file
PHP Pros and Cons
   Embed right into HTML (save with .php extension)
   No compilation required
   Very, very fast and scalable
    • Does not slow down appreciably under high server load
   Gets the “interface with a web page” job done quickly
   and simply
   Difficult to maintain, since it is embedded inside of a
   markup language like HTML
 A second generation “glue” language
   What Perl would be if it could be completely rewritten
   Ideal for both simple tasks or for writing large
   Retains many of the advanced object oriented features
   in advanced languages like Java
 Can be “scripted” (interpreted) or compiled for
 performance purposes
 Open source software = high quality + free
 Created by Guido van Rossum
   Manages most of the core code and is the
   “ultimate arbiter”
 Designed to be a language that offered a
 uniform interfaces to external software
 Named after Monty Python, of course!
 Called the “Instant Hacking” language
Sample Python Code
# Calculate the area:
if shape == 1:
    height = input("Please enter the height: ")
    width = input("Please enter the width: ")
    area = height*width
    print "The area is", area
    radius = input("Please enter the radius: ")
    area = 3.14*(radius**2)
    print "The area is", area
Python Observations
 Very available, but you may need to ask
 your webmaster to install it
 Getting increasing attention
 Simpler to use than Perl and more powerful
 Not designed to be embedded into HTML,
 like PHP and ASP
 Python applications very limited
   Typically you write your own
MySQL is an open source relational database of
industrial strength quality
Compares favorably with databases such as
Oracle, DB2 and SQL Server
  Missing some features of their advanced features
  Fine for most businesses
Integrates well with PHP, Perl and other scripting
Works well with Linux and Apache
Typically bundled as an option by a web service
While the code is open source, the code is owned and
controlled by the MySQL AB Company.
Using it is free except for certain classes of business users
You have the option of purchasing technical support from
MySQL AB or “going to the source” code and figuring it
ANSI compliant relational database
Tends to be scalable and offer very fast response
Other open source databases are available
   Postgres and Berkley DB are often used
   MySQL has the most market share, so you see it most often
PHPMyAdmin and MySQL
 PHPMyAdmin is a PHP script you can install
 It provides an easy front end interface to managing
 MySQL Relational Databases
   Often provided in your web host’s control panel
 Allow manipulation of tables, columns and rows
 using a web browser
 Provides web based import and export capabilities
 Often provided by the Web Service Provider
Apache + Linux + PHP +
 This combination of software is now in vogue
 All open source
 All very low cost
 All accessible to those with average programming
 Combination creates rich, database driven, high
 quality but very low cost interactive web sites