Web Server

From Apis Networks Wiki

(Redirected from Apache)
Jump to: navigation, search

Contents

Overview

Where do I upload my Web site files?

See following question.

What is a document root and what is the location?

A document root is the location on the server from which the Web server serves its pages for a particular domain. Your main domain has the document root of /var/www/html/. This value is unchangeable. Subdomains created via Add User in the esprit have the document root /home/user/public_html/. Subdomains created via Add Subdomain are dependent upon what value you picked.

A directory in the browser such as http://apisnetworks.com/images/ would correspond to /var/www/html/images/ on the server. The main user has a special directory called mainwebsite_html/ in its home directory. mainwebsite_html/ is simply a reference to /var/www/html/.

How to preview your domain

See the article under DNS titled "Accessing your domain before changing DNS".

What Apache version do the servers run?

At this time the servers are running 2.2.4


Security

Securing directory access

Directory access may be managed through the Protect Directories section of apnscp esprit, but scope is limited to the document root.

1. Create a file called .htaccess in the directory that you would like to restrict access.

Example: Say you want to protect the directory /var/www/html/private/. Create a file called .htaccess in that directory. We will use this example throughout the step-by-step tutorial.
2. Edit the .htaccess file and include these lines:
.htaccess
 
 AuthUserFile /home/virtual/siteNN/fst/var/www/.htpasswd
 AuthName My Realm
 AuthType Basic
 require user auth-user

3. Replace NN with the Site ID, which is listed in the Overview section of the Dashboard. .htpasswd may be located anywhere, but /var/www or another Web-inaccessible location is recommended for security. For auth-user pick a user-name for accessing the private directory you want protected

Note: Apache operates in the global root context; thus a path in the form of /home/virtual/siteNN/ is required in order for Apache to find the .htpasswd file.

4. Next, create a .htpasswd file. The .htpasswd may be auto-generated from the command line with the htpasswd command:

/usr/sbin/htpasswd /var/www/.htpasswd auth-user

Where auth-user is an arbitrary user to authenticate as. If all of the steps have been followed correctly, then the Web server will challenge you for authentication before permitting access to a specific section of your site.

Serving Pages

Display directory contents

If you would like for the Web server to generate a listing of all contents in a given directory, then create a file named .htaccess with the following line: Options +Indexes

You will also need to remove all directory index files (e.g. index.html, index.php, index.htm, index.*) from the target directory. The directory index files will always take precedence over the Indexes directive.

Redirect On typos

mod_speling may be used to correct typos in URLs. Spelling rules only allow one character translation (i.e. character capitalization, transposition, or omission) and ignores extensions such as .html. To enable spellchecking, add the following line to your .htaccess file:
CheckSpelling On

Specifying directory index order

An index page is the page a Web server pulls up for a given directory if a filename is not specified. For example, http://apisnetworks.com/ will scan the document root sequentially looking for the first file match. If found, that page will be displayed. By default, the directory index order of precedence is (in decreasing priority): index.html, index.php, index.shtml, index.htm, index.cgi, index.php4, index.pl, and finally index.jsp. Going from left to right in the list, the first file found will serve as the directory index.

To specify home.html as the index page such that when a user accesses http://apisnetworks.com/ it would be the same as accessing http://apisnetworks.com/home.html, add the following line to your .htaccess file:
DirectoryIndex home.html
Note: directory indexes apply recursively to all sub-directories. If the previous example is applied to the document root, then likewise it applies to /var/www/html/anotherdir/. In order to reset the directory index list specify a new DirectoryIndex directive under anotherdir/ such as
DirectoryIndex index.html index.php index.htm
.

Problems

Garbage HTML Output/Scripts Appear as Download-only

Random, unintelligible gibberish can appear in place of your Web page if you doubly compress output. All output sent from the server is compressed via mod_deflate. Some scripts, such as older versions of Joomla, do not inform the Web server that output has already been compressed and thus Apache's output filter once again compresses the output. The end result is either junk characters or worse, negotiation as an application/octet-stream that may only be downloaded.

You may either turn off gzip encoding through the application or through Apache. To turn off gzip encoding within the application, contact the vendor or consult the help files. To turn off gzip encoding from within Apache on all files with the suffix .php add the following to the .htaccess file:
RemoveOutputFilter php

"This site is temporarily unavailable. Please try again later." error message

"This site is temporarily unavailable. Please try again later." is a generic placeholder page to indicate the domain has been suspended for a billing delinquency or service violation. Please contact support@apisnetworks.com to unsuspend your site. Please be sure to include your subscription number and domain name in the e-mail.


Site Traffic

Can I generate Web site statistics?

There are three different ways of seeing visitor statistics:

  1. Visit the Urchin 5 link in the control panel to setup Urchin 5 reporting for your domain. Due to licensing restrictions we must restrict the number of free profiles per account. Additional profiles may be added at $1/month, but require direct credit card payment instead of PayPal to manage.
  2. Google acquired Urchin in 2005 and subsequent versions since 2005 have been freely available under the name Google Analytics. If you use Google AdWords or AdSense, then Google Analytics is a better option for its integration into both services. Registration is free and requires a tiny slice of JavaScript code to be inserted into each of your pages.
  3. Webalizer and AWStats are both free reporting programs accessible by all accounts. There are no costs associated with using either program.


Viewing log files

Raw log files may be accessed under /var/log/httpd/. If you host multiple domains, then finer control may be possible with Granular Logging in the control panel.

Subdomains

Creating global subdomains

Subdomains are directly manageable as symbolic links under /var/subdomain/ where each subdomain refers to the subdomain underneath /var/subdomain/. For example, the document root for http://guide.apisnetworks.com/ refers to /var/subdomain/guide/html. By default domains created from within the control panel will bind to all domains shared on an account. A subdomain named guide will work against the main domain apisnetworks.com and its child domain apnscp.com.

Creating local subdomains

Subdomains may be bound locally to a shared domain on the account by specifying the full hostname as the subdomain directory. To create a subdomain for guide.apnscp.com to another location than guide.apisnetworks.com create a directory named /var/subdomain/guide.apnscp.com/. Within the directory make a relative symbolic link named html to the document root. Local subdomains have precedence over global subdomains. The following example overrides the global subdomain guide with a local definition valid for http://www.guide.apnscp.com/ and http://guide.apisnetworks.com/.
cd /var/subdomain/
mkdir guide.apnscp.com
cd guide.apnscp.com
ln -s ../../../var/www/guide.apisnetworks.com/ html
 

Problems

Subdomain Placeholder Page

All subdomains created include a basic placeholder page called index.html. Because index.html precedence over all other index pages it will always be displayed when the subdomain is accessed without a filename. Remove the index.html file under /var/subdomain/subdomain/html/ to let the server use another index page.

Rewrite rules don't work with subdomains

If a seemingly simple rewrite rule does not work with a subdomain, then chances are you forgot RewriteBase / at the beginning of the rules following RewriteEngine On. This is especially true if you plan on using the .htaccess file supplied with Rails on a subdomain.

Preventing subdomain fall-thru to the document root

Subdomains that are unmapped in /var/subdomain/ automatically map to your document root, /var/www/html/. To prevent this behavior create a .htaccess file with the following rules, assuming mydomain.com is your primary domain name.

.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com [NC]
RewriteRule .* - [R=404,L]

See Also

Personal tools