Web Technology - Introduction to Web Servers (Jntu-Anantapur)
G.PULLAIAH COLLEGE OF ENGINEERING & TECHNOLOGY KURNOOL.SUB: WEB TECHNOLOGIES (R09)UNIT-1Lecture notes: Introduction to web servers: What is web? A collection of cross-linked "websites" which uses URI. The consistent use of URIs to represent resources. HTTP, HTML, and everything built around them(web) Which provides to invoke the data across universally over the net What is server? A server is a computer or device on a network that manages network resources. Most servers are dedicated. This means that they perform only one task rather than multiple tasks on multiprocessing operating systems, however, a single computer can execute several programs at once What is web server? A Web server is a program that generates and transmits responses to client requests for Web resources. Handling a client request consists of several key steps: Parsing the request message Checking that the request is authorized Associating the URL in the request with a file name Constructing the response message Transmitting the response message to the requesting client The server can generate the response message in a variety of ways: The server simply retrieves the file associated with the URL and returns the contents to the client. The server may invoke a script that communicates with other servers or a back-end database to construct the response message. Web Site versus Web Server? Web site and Web server are different: A Web site consists of a collection of Web pages associated with a particular hostname. A Web server is a program to satisfy client requests for Web resources. Types Of Web Servers: 1. Apache Web Server
Apache Web Server:Introduction: Apache Web server is the most commonly used http server today. About 80% of all websites and Intranets use Apache web server to deliver their content to requesting Browsers. Server side programming languages such as PHP, Perl, Python, Java and many others The name "Apache" derives from the word "patchy" that the Apache developers used to describe early versions of their software. The Apache Web server provides a full range of Web server features, including CGI, SSL, and virtual domains. Apache also supports plug-in modules for extensibility. Apache is reliable, free, and relatively easy to configure. Apache is free software distributed by the Apache Software Foundation. The Apache Software Foundation promotes various free and open source advanced Web technologies. It can be downloaded and used completely free of cost. The first version of Apache web server, based on the NCSA httpd Web server, was developed in 1995. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. The Internet's Request / Response Way Of WorkingHere's the Internet's Request / Response paradigm works. Whenever a Browser makes an http request such as:http://www.google.com/index.html
Download Apache Web Server:The latest stable build of Apache http server can be downloaded from URLhttp://httpd.apache.org/download.cgi Downloading the Apache web serverOpen a browser window and enter http://www.google.com in the address bar and hit GO. Installing the Apache web serverI recommend to run the Apache HTTP server as a service. This way it is always running and you don't need to start it manually. If you consider manually start and stop because of security issues, then reconsider and use a firewall, preferable one running on an external device like a router. The next step allows you to select the install type of the Apache web server. The default (Typical program features) is probably right for your situation, so press Next. Next, you can select the destination folder of the installation. Unless you prefer to use a different folder for some or all of the software you install, I recommend to use the default setting: C:\Program Files\Apache Group\ Finally, after clicking on the Next button you can start the actual installation by pressing the Install button. A few windows pop up and go automatically, and then a Windows Security Alert window appears asking if you want to keep blocking this (Apache HTTP server) program. Windows Security Alert for the Apache HTTP server. The download process of the Apache Web Server setup file is successfully finished. Testing the Apache HTTP server installationIn order to test your Apache web server installation, open a browser and enter http://localhost/ into the address bar (unless you used a different value then localhost in the Apache server information step). The Test Page for Apache installation should be displayed into your browser. Part of the Apache HTTP server test page in Mozilla Firefox Understanding the Apache server folder structureThe bin folderThe bin folder contains amongst other files the server executable: Apache.exe and a program to control the Apache HTTP server when ran as service: ApacheMonitor.exe. Also contained in this folder are htpasswd.exe and htdigest.exe for making parts of your site(s) restricted. The cgi-bin folderThe cgi-bin folder has one CGI program written in Perl, printenv.pl, which you can use to test if your Perl installation is working in combination with the Apache HTTP server. If you get a "500 Internal Server Error" when you enter The conf folderThis folder holds the configuration files used by the Apache web server. Of each file used by the server there is a copy which has .default in its name, e.g.
Some of the other settings are omitted since they will be overridden by the name-based virtual hosting set up discussed below. htdocsThis folder contains the default HTML page you see when you visit http://localhost/ with your web browser. Don't start adding your HTML documents and related files to this folder, but read on. manualThis folder contains the Apache HTTP server documentation, available as http://localhost/manual/. Note that this folder shows up under the document root thanks to the AliasMatch directive in the httpd.conf server configuration file (line 491). logsThis folder contains (amongst others) the access.log and error.log files. If anything goes wrong, for example the notorious 500 Internal Server Error, make sure that you check the error.log file. With virtual hosting you can give each site its own log file (discussed below), so be sure to check the right file(s). Setting up virtual HostingTo make the configuration of virtual hosts as easy as possible I decided to store the configuration settings into a separate file instead of adding those settings to the Apache server configuration file httpd.conf. Login to the computer with Administrator rights, and create an empty file named Note: in an earlier version of this article I stored the virtual hosts file inside a folder with limted user rights which implied that this file has the same rights. Since this file is interpreted by the Apache web server this is a security risk if this limited user account is compromised. Adding the domains to the hosts fileFor each website you want to have running locally you have to think up a domain name with great care. I use the same domain name as the real site with lc. added to the front (hence a subdomain) since I am very sure that this subdomain isn't used on the Internet in my case. Add each domain name to the hosts file used by Windows XP, which is located in the C:\WINDOWS\system32\drivers\etc folder for a default installation. An example configuration might be (comments on top not included for brevity):
Note that everything after the # character is regarded as a comment. You can use this to add useful comments. The IP address, 127.0.0.1, means "this computer" (localhost). If you want to use the web server in a local network, you have to use an IP address that can be contacted by other computers in the network. Also, you either have to modify all hosts files on each and every computer, or set up a name server. Including the virtual-hosts.conf fileAdd the following line to the end of the httpd.conf file in the C:\Program Files\Apache Group\Apache2\conf folder in order to include the virtual-hosts.conf file and make it part of the configuration of the web server:
Since the ServerRoot in the default install is set to the folder that contains the conf folder we can use the short relative notation as given above. Note: where filenames are specified, you must use forward slashes instead of backslashes (e.g. Stopping and starting ApacheAfter changes have been made to the httpd.conf file and/or the virtual-hosts file, Apache has to be restarted. If you are logged in with Administrator rights the easiest way to do this is by using the Apache monitor which is started when you log in and available via the system tray. Click the right mouse (context menu) button on the red feather icon in the system tray and select the Open Apache Monitor menu entry. You can restart the Apache HTTP server with a single mouse click on the Restart button. The Apache service monitor. Note that during installation of the Apache web server a short cut to the Apache service monitor is created in the Startup folder of "All Users" (i.e. C:\Documents and Settings\All Users\Start Menu\Programs\Startup) which is quite useless. Users with limited access rights are not able to control the Apache service but will get the Apache monitor running in their system tray anyway. You might want to move the short cut to the Startup folder of a user with Administrator rights. Another way to restart Apache is by entering in a command prompt window
Creating virtual hosts on Apache 2.2This tutorial is intended for use only in a local testing environment on Windows. For a production server, please refer to the official documentation on the Apache site. ü Apache 2.2 adopts a modular approach to its main configuration file, ü The other change is that Apache 2.2 imposes stricter permissions than previous series, so you need to add an extra command to the virtual hosts definition to prevent getting the following message when accessing a virtual host:
Because of the permissions issue, I recommend creating a top-level folder to hold all virtual hosts in your local development environment. The following instructions assume that all virtual hosts are located in a folder called NOTE: Security restrictions on Windows Vista and Windows 7 prevent you from saving edits to the files referred to in these instructions, even if you are logged in as an administrator. To get around this restriction, open Notepad or your script editor from the Start menu by right-clicking the program name and selecting "Run as Administrator" from the context menu. Then open the relevant files by using File > Open inside the program you have just launched. By default, Notepad shows only files with a 1. Create a subfolder inside 2. Open
3. On a separate line, enter
4. Add any further virtual hosts, each one on a separate line and pointing to the same IP address ( 5. Open
7. Remove the # from the second line so the section now looks like this:
9. Save 10. Open Note: In XAMPP, all lines are commented out. You must remove the hash mark from the beginning of the line that contains the following directive:
11. Position your cursor in the blank space shown on line 15 in the preceding screenshot, and insert the following four lines of code:
This sets the correct permissions for the folder that contains the sites you want to treat as virtual hosts. If you chose a location other than As long as all your virtual hosts are in subfolders of this top-level folder, this directive sets the correct permissions for all of them. However, if they are in different top-level folders, create a separate 15. The code shown on lines 27 through 42 in the preceding screenshot shows examples of how to define virtual hosts (in XAMPP, they're commented out). It shows all the commands that can be used, but only ü When you enable virtual hosting, Apache disables the main server root, so the first definition needs to reproduce the original server root. You then add each new virtual host within a pair of
16. Save 17. If you still have difficulty accessing your virtual hosts, make sure that you have added To create a virtual directory on a machine running Apache Web server software: Note: The Apache Web server uses the term alias instead of virtual directory. 1. Locate the conf/httpd.conf file in the Apache install directory. 2. Add an entry near the end of the file that looks like this. Be careful that it is not in the middle of some other entry: Alias /site_name "C:\pathname_to_site\your_site_directory" <Directory "C:\pathname_to_site\your_site_directory"> Options Indexes FollowSymLinks MultiViews ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> 3. In the entry added in step 2, replace site_name with the alias for your site and replace C:\pathname_to_site\your_site_directory with the actual file path name to your site's root directory. If the server is running on Linux, the format of the path name would be a UNIX path name rather than the Windows-style pathname shown in the example. 4. Restart the Apache server to have the change take effect. Wamp server:Setting Up a WAMP Serverü A WAMP Server is a Windows Machine that has Apache, MySQL, and PHP on it (WAMP – Windows, Apache, MySQL, PHP) To install these before you would have to get the installs and binaries and configure them yourself and set everything up which can be a tedious task as well as very time consuming. ü Now, thanks to sourceforge, you can get this functionality by simply installing an application. Once you are finished with this tutorial you will be able to follow our web-based tutorials without having a domain name and/or server. Let's get started. First we need to download our software from wampserver.com. Once on that site look for the above box to appear and click on Download WAMP Server 2.0 Save the file somewhere that you will be able to get to once it is finished completing. It is approximately 20 Megabytes, so depending on your connection; it may take a few minutes. You should now see this icon wherever you chose to save the file. Double-click on it to start the installation. Select to run the file if you are prompted to do so. You will be prompted to not install this version over WAMP5 1.x. Click yes to continue with the installation. This first install window simply welcomes you to the installer for this application. Click next to continue. This window contains the GNU GENERAL PUBLIC LICENSE that will allow you to use this software. Once you review this click the I Accepts radial button and click next to continue. This box let's you pick where you would like to install all of the files. You can change this if you like but if you do, bear in mind that you should put it in a folder that does not contain any spaces as some browsers/servers have issues handling spaces in file names. This is also where your web files will be stored under a directory called 'www'. If you are unsure, leave this default. This window will allow you to create the desktop icon and the quick launch icon to start the server by the click of a button. This window just reviews all installation options. Verify the settings are correct and click next to start installing the application. This is installing the software. You will get the above prompt to configure FireFox as your default browser for the WAMP Server if you would like, otherwise it will use Internet Explorer. This window will allow you to configure your server to forward any e-mail that your php creates to a proper server and e-mail account so that they will go to the right person once you are using it. If you don't know these values or have the ability to use them, just leave them default. This is the completion window. You have the ability to launch the server automatically after closing this window if you would like. Click Finish to start the application. Once the server is running, you will see the above icon and the taskbar for the WAMP Server. INSTALLING, CONFIGURING, AND DEVELOPING WITH XAMPPAbout XAMPP and Installation Requirements XAMPP is a small and light Apache distribution containing the most common web development technologies in a single package. Its contents, small size, and portability make it the ideal tool for students developing and testing applications in PHP and MySQL. XAMPP is available as a free download in two specific packages: full and lite. While the full package download provides a wide array of development tools, this article will focus on using XAMPP Lite which contains the necessary technologies that meet the Ontario Skills Competition standards. As the name implies, the light version is a small package containing Apache HTTP Server, PHP, MySQL, phpMyAdmin, Openssl, and SQLite. For more details on the packaging and versions
Obtaining and Installing XAMPPAs previously mentioned, XAMPP is a free package available for download and use for various web development tasks. All XAMPP packages and add-ons are distributed through the Apache Friends website at the address: http://www.apachefriends.org/. Once on the website, navigate and find the Windows version of XAMPP Lite and download the self-extracting ZIP archive. After downloading the archive, run and extract its contents into the root path of a hard disk or USB drive. For example, the extract path for a local Windows installation would simply be C:\. If extracted properly you will notice a new xampplite directory in the root of your installation disk. In order to test that everything has been installed correctly, first start the Apache HTTP Server by navigating to the xampplite directory and run the apache_start.bat batch file. |
No comments:
Post a Comment