Apache

21
APACHE HTTP SERVER

Transcript of Apache

Page 1: Apache

APACHE HTTP SERVER

Page 2: Apache

Apache helps in the keen growth of the world wide web.The majority of web servers using Apache run a Unix-like operating system.As of February 2010[update] Apache served over 54.46% of all websites and over 66% of the million busiest

INTRODUCTION:

Page 3: Apache

Features

Apache supports a variety of features, many implemented as compiled modules which extend the core functionality. These can range from server-side programming language support to authentication schemes. Some common language interfaces support Perl, Python, Tcl, and PHP

Page 4: Apache

PERFORMANCE

Although the main design goal of Apache is not to be the "fastest" web server, Apache does have performance comparable to other "high-performance" web servers

Page 5: Apache

MAIN USE

Apache is primarily used to serve both static content and dynamic Web pages on the World Wide Web. Many web applications are designed expecting the environment and features that Apache provides

Page 6: Apache

Step 1: We need to have the xampp for linux inorder the run applications

so(as per step 1) ,download the xampp for linux with any favourable version on to the computer

INSTALLING APACHE IN LINUX:

Page 7: Apache

Step 2: After the successful downloading,we need to extract the 'tar' file on to the system,select a path and just extract them using the following commands

gunzip -d httpd-2_0_NN.tar.gz tar xvf httpd-2_0_NN.tar

*NN -refers to the current xampp version

Page 8: Apache

CONFIGURATION

Page 9: Apache

Inorder to configure the ,we need to locate the xampp folder to which it is extracted. After the location of these file we can find the configure file in the 'etc' folder as “httpd.config”,inside which we can find the configuration file

“configuration file main Apache HTTP server configuration . It contains theconfiguration directives that give the server its instructions”

Page 10: Apache

ServerRoot: The top of the directory tree under which the server's

configuration, error, and log files are kept

ServerRoot "/opt/lampp"

Listen: Allows you to bind Apache to specific IP addresses and/or ports, instead of the default.

Listen 12.34.56.78:80

Inside which we can fine the various server details,they are:

Page 11: Apache

User/Group: The name (or #number) of the user/group to run httpd as it is usually good practice to create a dedicated user and group for running httpd, as with most system services.

User nobodyGroup nogroup

ServerAdmin: Your address, where problems with the server should be e-mailed. This address appears on some server-generated pages, such as error documents.

e.g. [email protected]

Page 12: Apache

ServerName gives the name and port that the server uses to identify itself.This can often be determined automatically, but we recommend you specifyit explicitly to prevent problems during startup.If your host doesn't have a registered DNS name, enter its IP address in it.

ServerName www.example.com:80ServerName localhost

DocumentRoot: The directory out of which you will serve your documents. By default, all requests are taken from this directory, but symbolic links and aliases may be used to point to other locations.

DocumentRoot "/opt/lampp/htdocs"

Page 13: Apache

Each directory to which Apache has access can be configured with respect to which services and features are allowed and/or disabled in that directory (and its subdirectories). First, we configure the "default" to be a very restrictive set of features.

<Directory /> Options FollowSymLinks AllowOverride None #XAMPP #Order deny,allow #Deny from all</Directory>

Page 14: Apache

DirectoryIndex sets the file that Apache will serve if a directory is requested.<IfModule dir_module> #DirectoryIndex index.html # XAMPP DirectoryIndex index.html index.html.var index.php index.php3 index.php4</IfModule>-------------------------------------------------------------------------------The following lines prevent .htaccess and .htpasswd files from being viewed by Web clients. <FilesMatch "^\.ht"> Order allow,deny Deny from all</FilesMatch>

Page 15: Apache

ErrorLog: The location of the error log file.# If you do not specify an ErrorLog directive within a <VirtualHost># container, error messages relating to that virtual host will be# logged here. If you *do* define an error logfile for a <VirtualHost># container, that host's errors will be logged there and not here.#ErrorLog logs/error_log

Redirect: Allows you to tell clients about documents that used to exist in your server's namespace, but do not anymore. The client will make a new request for the document at its new location. Example: Redirect permanent /foo http://www.example.com/bar

Page 16: Apache

Alias: Maps web paths into filesystem paths and is used to access content that does not live under the DocumentRoot. Example: Alias /webpath /full/filesystem/path

ScriptAlias: This controls which directories contain server scripts.ScriptAliases are essentially the same as Aliases, except thatdocuments in the target directory are treated as applications and run by the server when requested rather than as documents sent to the client. The same rules about trailing "/" apply to ScriptAliasdirectives as to Alias. ScriptAlias /cgi-bin/ "/opt/lampp/cgi-bin/"

Page 17: Apache

Supplemental configuration:The configuration files in the etc/extra/ directory can be included to add extra features or to modify the default configuration of the server, or you may simply copy their contents here and change as necessary.

Server-pool management (MPM specific)Include etc/extra/httpd-mpm.conf

Language settingsInclude etc/extra/httpd-language

User home directories#Include etc/extra/httpd-userdir.conf

Page 18: Apache

Real-time info on requests and configurationInclude etc/extra/httpd-info.conf

Virtual hostsInclude etc/extra/httpd-vhosts.conf

Local access to the Apache HTTP Server ManualInclude etc/extra/httpd-manual.conf

Distributed authoring and versioning (WebDAV)Include etc/extra/httpd-dav.conf

Various default settingsInclude etc/extra/httpd-default.conf

Page 19: Apache

Managing one site on a Web server can be tough enough, and the job is even harder if you have to host multiple client sites on a badly configured setup. If you're running Apache, you can make things easier by setting up virtual hosts, which let you control multiple domains on one IP address, allowing you to specify URLs like http://clientsdomain.com/file_name.html instead of http://yoursite.com/hosted/clients_directory/file_name.html, and letting you forgo setting up domain forwarding with a /srv/www/htdocs/hosted/clients_directory file.

If Apache is installed correctly, you can set up virtual hosting easily by editing Apache configuration files. The main .conf files in /etc/apache2 include httpd.conf, error.conf, server-tuning.conf, and a bunch more. These files are set for read-only access for normal users; you must gain root access with the sudo or su command to change them.

Edit /etc/apache2/httpd.conf and find this line:

Include /etc/apache2/vhosts.d/*.confReplace it with a line that specifies a .conf file we will create and call vhost.conf:

Include /etc/apache2/vhosts.d/vhost.conf

SETTING VIRTUAL HOSTING

Page 20: Apache

When you've made the change, save the file. Now, again as root, create the vhost.conf by renaming the vhost.template file in /vhosts.d/:

mv vhost.template vhost.conf

Now edit the file to set it to allow multiple name-based Web sites on a single IP address. First add in the virtual host directive with NamevirtualHost *. The asterisk is a wild card character that allows any address to be set. Under that directive you can add your first virtual host:

Page 21: Apache

NamevirtualHost *<VirtualHost *>ServerAdmin [email protected] /srv/www/htdocs/directory_of_your_choice/ServerAlias yourdomain.com *.yourdomain.com<virtualHost>

The first part is the opening tag for the defined virutal host block. ServerAdmin lets you display the administrator email address when an error such as a 404 occurs. DocumentRoot is the root directory for the defined site; for example, sites I have hosted in the past all had accounts set up within /srv/www/htdocs/hosted/sitename/. Next is the ServerAlias or ServerName, which controls what names people can use to see and access a site. You could set this to a directory within the main NameVirtualHost or the domain of the site so the server can display the content associated with the domain name. The reason for the two ServerAlias entries above is that servers are often called from more than one ServerName, so you set up a ServerAlias with more than one address listed. The wild card allows for any domain request with anything in front of .yourdomain.com.