170 likes | 410 Views
What is a server?. Many types of server – File server – file: networked file space. FTP server – ftp: remote file space, often read-only. Web server – http: web pages and more. Mail server – mail: email system. News server – news: newsgroups messages, used to be huge. Web Servers.
E N D
What is a server? Many types of server – • File server – file: networked file space. • FTP server – ftp: remote file space, often read-only. • Web server – http: web pages and more. • Mail server – mail: email system. • News server – news: newsgroups messages, used to be huge.
Web Servers • Web servers used to be very simple: • Accept requests for information, • Respond with static HTML pages and graphics. • Servers can be “asked” to run “service” programs • Originally called Common Gateway Interface (CGI) applications, now largely superseded by • FastCGI, SimpleCGI • Apache plugins, • Netscape NSAPI or Microsoft ISAPI
Servers: IIS, Apache • Internet Information Server (24.5%, Mar 2010) • Commercial server for Windows • Came with XP Pro on the install CD as an extra • Also available with Vista and Windows 7 • Apache (54.5%, Feb 2010) • Free, open-source software • Widely used, Linux/Unix/Mac/Windows support • Easy to use on a stand-alone PC
Why “CGI”? • Common - all server platforms use this standard. • Gateway - controlled access to the server’s processing resources. • Interface - client-server resource connector function. • CGI - a method that allows data to be executed or interpreted instead of just delivered and displayed. • NB The modern replacements are much more efficient than the original CGI, yet still compatible.
HTML vs. CGI • “http://www.fcet.staffs.ac.uk/nas1/homepage.htm” • This reference asks the server (fcet) to look in the (shortcut to the) nas1 directory... • ... and find a file called “homepage.htm”. • The simple server knows that .htm and .html files are HTML • It sends the files, without further processing, to the browser. • More complex servers can do much more.
HTML vs. CGI • http://fred.co.uk/scripts/debug.php • This reference asks the server (fred, a commercial server in the uk) to look in the (shortcut to the) scripts directory... • ... and find a file called “debug.php” • The server knows that a .php file is a page with embedded script and must be run by the Web server software in a special way • Output from the script is sent to the browser
CGI+ languages • Web server programming can be accomplished using many suitable languages. • Popular ones are; • Modern: PHP (.php), VBScript or JScript (in ASP, .asp), ASP.NET (.aspx) • Java Server Pages (.jsp) • Old CGI: perl (.pl), C, C++, any “normal” programming language (.exe)
PHP • PHP means “PHP Hypertext Pre-processor” (sic). • Originally it was known as “Personal Home Pages” but that is poor for marketing as a business solution! • It was also called “perl Hypertext Pre-processor” but PHP is no longer just a web-version of perl. • The PHP language is a mixture of C, perl and others. • PHP is supported on many platforms (Mac, PC, Linux…).
What’s it for? • A plain HTML document that the Web server delivers is static, which means it doesn't change. • A CGI program, on the other hand, is executed in real-time, so that it can output dynamic information. • CGI allows someone visiting your Web site to run a program on your machine that performs a specified task – maybe updating a weather report or grabbing a digital photo. • E-Commerce, blogs, web services, discussion areas… many use PHP.
PHP – print all server variables • <?php • phpinfo(32); • ?> • This looks suspiciously simple! • PHPinfo() is a built in function that reports all sorts of information • The “32” tells the function to show us the values of the server variables
Raw CGI data - encoding • Information is sent from a form to a script in a very odd format. • If field “name” has the value “G Singh”... • and “job” has the value “principal lecturer”... • the script will receive the string“name=G%20Singh&job=principal%20lecturer”. • But PHP splits this up for you and makes it easy to use, so you don’t usually worry about it.
Summary • There are different types of server • We have discussed the reasons for needing CGI+ • … and contrasted plain HTML with dynamically created content • We have noted the wide range of CGI+ languages in use on the Internet • … and looked at a specific language, PHP • We have briefly considered standard URL-encoded parameters
References (Checked: Aug 2010) • Common Gateway Interface(http://en.wikipedia.org/wiki/Common_Gateway_Interface) • Apache HTTP Server(http://en.wikipedia.org/wiki/Apache_HTTP_Server) • The Apache HTTP Server Project(http://httpd.apache.org/ABOUT_APACHE.html) • MS Internet Information Services(http://en.wikipedia.org/wiki/Internet_Information_Services) • The Official Microsoft IIS Site(http://www.iis.net/overview)
References (Checked: Aug 2010) • PHP(http://en.wikipedia.org/wiki/Php) • PHP: Hypertext Preprocessor(http://www.php.net/) • MySQL, the world's most popular open source database(http://www.mysql.com/?bydis_dis_index=1)