God will not give you a burden that you can t handle. If you ever find yourself in a mess which seems impossible to resolve, take it as a complement. God thinks you can do it. Reply
Its all about giving smart interviews !!!! Thats when others say...dman! he got Lucky !!!
Apache HTTP Server Version 2.0 - http://httpd.apache.org/docs/2.0/
The name 'Apache' was chosen from respect for the Native American Indian tribe of Apache (Indé), well-known for their superior skills in warfare strategy and their inexhaustible endurance. Secondarily, and more popularly (though incorrectly) accepted, it's a considered cute name which stuck. Apache is "A PAtCHy server". It was based on some existing code and a series of "patch files".
When Apache starts, it binds to some port and address on the local machine and waits for incoming requests. By default, it listens to all addresses on the machine. However, it needs to be told to listen on specific ports, or to listen on only selected addresses, or a combination. This is often combined with the Virtual Host feature which determines how Apache responds to different IP addresses, hostnames and ports.
Apache on Windows - Multithreaded, just 2 processes, parent and child. Child process services the reqests at once using multithreading
Apache on UNIX - Multi-processing, parent process and several child processes for each request.
/conf directory under /Apache dir contains all the configuration files
Re-installing apache - just stop already running Apache server. Install new version. If files already exist in the /conf dir, new ones are renamed to say httpd.conf.default. Manually update the httpd.conf file. Except htdocs\index.html wont be overwritten or a .default wont be created. Thats why its safe to install apache over apache.
Common and Important Directives:
ServerName - ServerName gives the name and port that the server uses to identify itself. This can often be determined automatically, but we recommend you specify it explicitly to prevent problems during startup. If this is not set to valid DNS name for your host, server-generated redirections will not work. See also the UseCanonicalName directive.
If your host doesn't have a registered DNS name, enter its IP address here. You will have to access it by its address anyway, and this will make redirections work in a sensible way.
MaxRequestsPerChild - contorls how many requests a process will server before existing. Unlike UNIX, the process servers all requests at once (as its multi-threaded), and not one at a time, so if this value is specified it must be a big one. Default is 0, this indicates the process (child) will never exist.
Setting MaxRequestsPerChild to a non-zero limit has two beneficial effects:
* it limits the amount of memory that process can consume by (accidental) memory leakage;
* by giving processes a finite lifetime, it helps reduce the number of processes when the server load reduce
If non-zero value is specified, when the child process reaches that value, it exisits and is re-swamped. This time it reads the config file again and if its not saved or changed can lead to weird behaviours.
ThreadsPerChild - this indicates the server the max number of connections it should use and is the max number of connections it can handle at ones. (as there are just two processes on Windows, parent and child and child is multi-threaded). Default value is 50.
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 "C:/Program Files/Apache Group/Apache2/htdocs"
Running Apache in console window:
>apache -f "config file path"
>apache -n "server name" (use config file of an already installed apache server)
>apache (in this case, the default config file /conf/httpd.conf is used. (this condif file contains different directives like MaxRequestsPerChild, ThreadsPerChild, ServerRoot etc.
When Apache is installed using Binary, a registry entry is created that tells the ServerRoot:
HKEY_LOCAL_MACHINE\Software\Apache Group\Apache\1.3.13\ServerRoot
It also looks for ServerRoot in httpd.conf file, and if both are present uses the .conf one. So if Apache dir is copied somewhere else, make sure to change the config file and all should work just fine, I hope.
Stop running server:
>press Control-C
>apache -k shutdown
>apache -k stop
>apache -k -restart (finishes the already running transactions first)
All gracefully shutdown with 1.3.13 and above versions.
Apache - Configuration Files TEST option:
>apache -t
Any changes made to config files can be tested while the server is still running (makes sure that the syntax is good). Once this is done, use
>apache -k restart (ongoing transactions are not interrupted), new requests read the new config files.
Configure Apache for Virtual Hosts:
LISTEN directive – this tells the Apache server on what addresses and ports it has to listen on, it does not implement Virtual hosts. But for Virtual Hosts to work, the Listen directive must mention the addresses and ports to be used. If no Virtual Hosts are specified, the Server acts the same for all the addresses and ports specified using the Listen directive. Your machine can have more than one IP addresses, if it has more than One Network Interfaces. If this is the case, mention all the IPs and Port pairs.
Virtual Hosts can be either Name-based or IP-based. IP-based virtual hosts require a different IP each. Name-based virtual hosts can share the same IP. Just configure your DNS Server and than configure your apache server accordingly. Also, this eliminates the demand for scarce IP addresses. Name-based IP addresses should be preferred over IP-based IP addresses. For name-based virtual hosts to work, the HTTP header from the client should contain the host name. HTTP 1.1 supports this and HTTP 1.0 has patch available for this one.
Name-based virtual hosts:
NameVirtualHost – should point to all the IP address and port pairs to be used for name-based virtual hosts. A “*” can be used to specify all IPs. If only ports difference, in case of a separate one for SSL use as:
NameVirtualHost *:80
VirtualHost – should point to the IP:port pair as per the NameVirtualHost directive. This directive should atleast contain ServerName and DocumentRoot directives.
For example, suppose that you are serving the domain www.mydomain.com and you wish to add the virtual host www.myotherdomain.com, which points at the same IP address. Then you simply add the following to httpd.conf:
NameVirtualHost *:80
<VirtualHost *:80> ServerName www.mydomain.com ServerAlias mydomain.com *.mydomain.com DocumentRoot /www/mydomain.com </VirtualHost>
<VirtualHost *:80> ServerName www.myotherdomain.com DocumentRoot /www/myotherdomain.com </VirtualHost>
Many servers want to be accessible by more than one name. This is possible with the ServerAlias directive, placed inside the <VirtualHost> section. For example in the first <VirtualHost> block above, the ServerAlias directive indicates that the listed names are other names which people can use to see that same web site:
ServerAlias mydomain.com *.mydomain.com
then requests for all hosts in the mydomain.com domain will be served by the www.mydomain.com virtual host. The wildcard characters * and ? can be used to match names. Of course, you can't just make up names and place them in ServerName or ServerAlias. You must first have your DNS server properly configured to map those names to an IP address associated with your server.
‘Main Server Configuration’ section in httpd.conf contains all the default directives and all these directives can be part of the VirtualHost directive, if used, to act differently depending upon the IP/Port the Client is making a connection too.
VirtualHost – Helps to run more than one websites on the same machine. It can either be IP based or name-based and this is completely invisible to the client.
<VirtualHost> and </VirtualHost> are used to enclose a group of directives that will apply only to a particular virtual host. Any directive that is allowed in a virtual host context may be used. When the server receives a request for a document on a particular virtual host, it uses the configuration directives enclosed in the <VirtualHost> section.
<VirtualHost _default_:*> DocumentRoot /www/default </VirtualHost>
This prevents from request going to the main server.
<VirtualHost 192.168.1.1 172.20.30.40> two or more ips can serve or point to the same ServerName
Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries.
Virtual hosts get the priority from top to bottom. So if the ServerName does not match with any, first is chosen by default.
Authentication and Authorization:
If you plan to use .htaccess files, you will need to have a server configuration that permits putting authentication directives in these files. This is done with the AllowOverride directive, which specifies which directives, if any, may be put in per-directory configuration files.
Since we're talking here about authentication, you will need an AllowOverride directive like the following:
AllowOverride AuthConfig
You'll need to create a password file. This file should be placed somewhere not accessible from the web. This is so that folks cannot download the password file. For example, if your documents are served out of /usr/local/apache/htdocs you might want to put the password file(s) in /usr/local/apache/passwd.
To create the file, use the htpasswd utility that came with Apache. This will be located in the bin directory of wherever you installed Apache. To create the file, type:
htpasswd -c /usr/local/apache/passwd/passwords admin
Next, you'll need to configure the server to request a password and tell the server which users are allowed access. You can do this either by editing the httpd.conf file or using an .htaccess file. For example, if you wish to protect the directory /usr/local/apache/htdocs/secret, you can use the following directives, either placed in the file /usr/local/apache/htdocs/secret/.htaccess, or placed in httpd.conf inside a <Directory /usr/local/apache/apache/htdocs/secret> section.
AuthType Basic AuthName "Restricted Files" AuthUserFile /usr/local/apache/passwd/passwords Require user rbowen
OR
Require valid-user
OR
AuthGroupFile /usr/local/apache/passwd/groups Require group GroupName
Groups file contains:
GroupName: rbowen dpitts sungo rshersey
Using Order will let you be sure that you are actually restricting things to the group that you want to let in, by combining a Deny and an Allow directive:
Order deny,allow Deny from all Allow from dev.example.com
Listing just the Allow directive would not do what you want, because it will let folks from that host in, in addition to letting everyone in. What you want is to let only those folks in.
StringBuffer in places where the string buffer was being used by a single thread (as is generally the case). Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations.