Académique Documents
Professionnel Documents
Culture Documents
Linux-Apache-MySQL-PHP
LAMP
LAMP stands for Linux-Apache-MySQLPHP. Instead of PHP, Perl and Python are also used. This is a free and lightweight alternative to WISA, Windows-IIS-SQL Server-ASP (and now, ASP.Net).
Linux
Free as in Freedom
Richard Stallman started the GNU Project and spearheaded the free software movement. Stallman says free represents end users liberties, not the price of software. He has charged for his own software (for making copies and for services), but always allowed his clients to distribute copies as well. But: One cant charge much in a free market economy when people can make copies freely.
Freedoms
Stallman lists these freedoms (http://www.gnu.org):
0. To run the program for any purpose. 1. To study how the program works, and to adapt it to your needs. 2. To redistribute copies to help your neighbor. 3. To improve the program, and release your improvements so that the whole community benefits.
Note: 1 & 3 require access to source code. Free Software Foundation (FSF) was founded to support the GNU Project.
GNU/Linux
GNU Project GNU Operating System GNU (GNUs Not Unix) was to replace UNIX. Microkernel vs. Monolithic kernel.
Mach microkernel was to complete the GNU OS. In 1992 Andrew Tanenbaum said Linux is Obsolete because Linux has a monolithic kernel. Microkernel is more secure, not as efficient. Today, monolithic kernels are still going strong.
Linux could not have happened without GNU. Stallman requested that GNU/Linux be used.
Unix Commands
A Unix command handles one simple task (eg. ls lists directory contents). Options are passed as command line arguments (as in ls -lF */*.txt, ls --color). Complex tasks are composed of many simple tasks. Commands work together using pipes. Pipes redirect a program's output to another program as input.
Apache
Security
IIS until IIS 6.0 had serious security issues. Those who migrated to Apache have not come back to IIS, even though IIS 6.0 is much more secure:
http://blogs.msdn.com/michael_howard/archive/2004/ 10/15/242966.aspx
Or is it? Maybe some bugs are not reported? IIS 6.0 is complex:
http://blogs.zdnet.com/threatchaos/?p=311
Apache 2 Configuration
Apache 2 configuration: /etc/apache2/*:
apache2.conf general config file httpd.conf not used in Apache 2 sites-available/ default, and other sites (Apache
2 can serve multiple sites with their own IP addresses with one executable)
Modules
Most tasks in Apache are handled by modules. Some popular Apache modules:
PHP mod_ssl (SSL: Secure Sockets Layer) OpenSSL FrontPage perl
MySQL
MySQL
MySQL is a popular, scalable, free, open-source database management system (DBMS). It runs on Windows, Linux, and many other operating systems. MySQL AB, the Swedish company that owns the codebase offers services, extra tools, and licensed versions. MySQL AB states that MySQL is used in 11 million installations in the world. We will use phpMyAdmin to access MySQL through Apache.
PHP
PHP is popular, simple and lightweight server-side scripting language used to create dynamic web pages. History:
1995: PHP 2, Personal Home Page Tools 1997: PHP 3, PHP: Hypertext Processor 2000: PHP 4 2004: PHP 5
Server-Side Scripting
On the server, PHP code produces HTML. Client only receives HTML. Client can't view the original PHP code. Compare with HTML:
<b>This is readable on the page</b> <!-- This is visible if you view source --> <?php // PHP source is not visible ?>
Edit-Reload-Test
Quick edit-test cycle: Edit the PHP file on the server (localhost if same machine) and reload the page on the client. The compilation step is not explicit, and the effects of your changes can be quickly discovered. PHP is easy to learn, and quite simple. The next few pages show some sample PHP programs.
info.php
This is always the first PHP file created. A single PHP function creates a very large HTML page detailing everything PHP knows about its execution environment. The file contents are simply:
<?php phpinfo(); ?>
helloworld.php
<html> <head> <title>PHP: Hello World</title> </head> <body> <h1>PHP Says:</h1> <?php echo "Hello World!" ?> </body> </html>
helloform.php
This is a page that uses a form. The page processes its own form. Code structure:
html header PHP processing of user parameter form that allows user to enter his/her name. end of body and html
$user = stripslashes($_GET['user']);
<!-- Normally, you'll use method="POST" --> <form method="GET" action="helloform.php"> Your Name: <input type="text" name="user" size="40"> <input type="submit" name="submit" value="OK"> </form> </body> </html>
colorbox.php
Loops are often used to create html lists and tables with dynamic content. This example uses nested loops to create a colorful table dynamically. Note that the outer loop spans two php code sections, with an HTML section inbetween:
<?php for($red...) { ?> <tr> <?php ... } ?>