Web Hosting Apache
Hosting Apache
Web Hosting Apache - Web Hosting Apache Provide reliable, high-performance web hosting with the built-in Apache web server
Why Apache?
--------------------------------------------------------------------------------
In the words of apache.org, "Apache has been the most popular web server
on the Internet since April of 1996." The June, 2002 netcraft.com survey
found that 64% of the Internet's active websites used Apache. (The second
runner-up was Microsoft IIS, which powered 25% of the Internet's
websites.)Comment | Top
Apache Configuration Files
--------------------------------------------------------------------------------
The primary Apache configuration files are found in your /www/conf
directory. Of the files in this directory, vhosts.conf is the most
relevant to your needs. This is the file which Apache uses to figure out
which virtual host goes where, the location of its log files, and several
other configurations.Comment | Top
Editing Apache Configuration Files
--------------------------------------------------------------------------------
After You Edit: Always Restart
Apache's efficiency is partly due to how it behaves with regards to its
configuration files. Rather than checking its configuration files every
time a visitor sends an HTTP request, Apache reads its configurations each
time it is restarted, and caches the information until it is restarted
again.This also means that every time you make a change to your Apache
configurations, your changes will not take effect until you restart
Apache. You can restart Apache either from your web admin suite, or from
the command line by giving the command: apachectl restart
As a side benefit, when you restart Apache from the command line it will
tell you if your configurations are correct. For example, if you have
accidentally put a typo in your vhosts.conf file, Apache will catch this
error and refuse to restart until the problem has been fixed.Apache
features some of the best error reporting available in any software
currently running today. As a rule, its error messages are user-friendly,
and given in "plain English." For example, when Apache refuses to restart
because it has encountered a configuration problem, it will return the
error: configuration broken, ignoring restart
It will then helpfully add the suggestion: (run 'apachectl configtest' for
details)
Remember that Apache is running with cached configurations. If Apache
refuses to restart because it has found an error, this means that it is
keeping your websites operational until you can fix the problem. This is a
robust safety feature which probably saves as many websites as seatbelts
save lives.Comment | Top
--------------------------------------------------------------------------------
Apache Will Not Restart! Now What?
In a best-case scenario, you will have made only a single change before
restarting Apache. In this case, it will be simple for you to go back and
redo (or undo) the change you have made. For this reason, we recommend
that if you have several changes to make, you save your work and restart
Apache frequently.If you have made several changes, it may be difficult to
determine which change is causing the problem. In this case, your best
course of action is to follow Apache's own advice and run the command:
apachectl configtest
Apache will usually tell you exactly where the problem lies, and will
offer suggestions for fixing it. For example, I added a rogue letter "m"
to my vhosts.conf file, then ran "apachectl configtest". Here is Apache's
response: Syntax error on line 5 of /usr/local/www/conf/vhosts.conf:Invalid
command 'mDocumentRoot', perhaps mis-spelled or definedby a module not
included in the server configuration
As you can see, Apache begins by giving you the line number and absolute
path to the file which contains the error (line 5, /usr/local/www/conf/vhosts.conf).
It then offers its best guess ("perhaps mis-spelled") and follows up with
the modest suggestion that perhaps this is a valid configuration for a
module that it's simply not familiar with.Comment | Top
--------------------------------------------------------------------------------
The vhosts.conf File
Every time you add a virtual host with the "vaddvhost" command, your
server will update the vhosts.conf file. If you know HTML, then you will
find the syntax of this file familiar. It uses angle brackets to open and
close command sections, just as HTML uses angle brackets to open and close
tags.We'll begin by looking at a sample vhosts.conf entry for the domain "mydomain.com".
DocumentRoot /usr/local/www/vhosts/mydomain.com/htdocsServerName
mydomain.comServerAlias www.mydomain.comServerAdmin webmaster@mydomain.comLogFormat
COMBINEDErrorLog /usr/local/www/vhosts/mydomain.com/logs/error_logTransferLog
/usr/local/www/vhosts/mydomain.com/logs/access_logHostNameLookups
offOptions AllAllowOverride AllOrder allow,denyAllow from allScriptAlias /cgi-bin/
/usr/local/www/vhosts/mydomain.com/cgi-bin/AllowOverride NoneOptions
NoneOrder allow,denyAllow from all
As you can see, the entry for this domain is bracketed by the and tags.
Between these tags is all the information Apache needs to work with this
domain. From top to bottom: ~ DocumentRoot: Defines the location of the
domain's web files.
~ ServerName: This virtual host's domain name.
~ ServerAlias: This aliases the "www" version of your domain name to the
same place, which means that visitors can use either www.mydomain.com or
http://mydomain.com to view your website.
~ ServerAdmin: This is the email address of the website administrator. It
will appear in some of the default Apache error pages, incase of server
error.
~ LogFormat:This tells Apache to combine the log files. We recommend using
combined log file format, both because it saves on diskspace, and because
most stats programs can get better information from combined log files
than they can from un-combined log files.
~ ErrorLog and TransferLog: Determine the location of this domain's log
files.
~ HostNameLookups: By default, HostNameLookups will be turned off. If you
switch HostNameLookups on, you will be able to see domain names instead of
IP addresses in your website's stats reports. However, turning on
HostNameLookups will significantly increase your server's workload, which
will slow down your website's response time. Unless it's absolutely
critical that your stats reports show domain names rather than IP
addresses, we strongly suggest that you leave HostNameLookups off.
~ : These tags define options for this domain's htdocs directory. Using
the tags in your vhosts.conf file replaces the need to create .htaccess
files, which then end up scattered throughout your virtual host's web
directories. We recommend using sections in your vhosts.conf file, for
ease of convenience and support.
~ ScriptAlias: This defines the location of this domain's cgi-bin (where
executable scripts are usually kept). Note that the next section uses the
tag to allow the execution of scripts in the cgi-bin directory.
Comment | Top
--------------------------------------------------------------------------------
Removing a Virtual Host
The simplest way to remove a virtual host is to use the web admin suite,
or to use the command: rmvhost
This command will prompt you with questions about how you want the virtual
host to be removed. You will have the option to leave the virtual host's
directory files on your server, or have your server delete them.If you
want to temporarily remove a virtual host for some reason, the easiest way
to accomplish this is to comment out its entry in the vhosts.conf file.
Apache will ignore any line which starts out with a pound sign. You can
see how this works at the very top of your vhosts.conf file, which begins
with the line: # Virtual host configuration
If you want to find
our more information about Web Hosting Apache please follow this link:
Web Hosting Apache: Best You Can Get
|