Upgrading from Woody to Sarge: Part 4 - Apache2

Posted by Steve on Wed 2 Mar 2005 at 12:44

One of the other major software upgrades available to you after upgrading to Sarge is Apache2. This is the reworked version of the world's most popular webserver.

Much like the reworking of exim4 which we covered briefly already there are several different packages you can choose when it comes to installing apache2.

The different packages refer to the different ways that the apache server can now be setup to run, the so-called "mutli-processing-modules". As these must be chosen at compile time there are different packages available for the different choices.

By default when you install the apache2 package you will be given the package apache2-mpm-worker, other packages are available:

apache2-mpm-worker

The worker MPM provides a threaded implementation for Apache2. It is considerably faster than the traditional model, and is the recommended MPM.

apache2-mpm-prefork

This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries.

apache2-mpm-perchild

Perchild is the grown up, mac daddy version of suexec for apache2. Rather than execute a cgi script as a given user, perchild forks a process for each vhost, then su's to the correct user/group for that vhost.

THIS MPM IS NOT CURRENTLY EXPECTED TO WORK CORRECTLY.

In the general case you can be happy to stick to the default of apache2-mpm-worker which you'll receive if you install it with just:

apt-get install apache2

If you install the Apache2 package whilst you have the original Apache package installed and running your new installation of Apache2 will be disabled, and not started. This is to avoid breaking any site(s) you already have.

A good way of setting up your new Apache2 is to enable it and start it running on a non-standard port, such as 81. This way you can configure the server and get it working correctly before removing the older apache package.

To enable Apache2 you must edit the file /etc/default/apache2 this file looks like this:

# 0 = start on boot; 1 = don't start on boot
NO_START=1

(So simply change the 1 to 0 and the server will attempt to start at boot time).

Once you've done this you either need to stop your original Apache server and start the new one, or modify the new server to run on a different port. This is as simple as changing the configuration file /etc/apache2/ports.conf:

Listen 80

change this port number to anything you like, then start the new server with:

/etc/init.d/apache2 start

Once you have the server running you'll be ready to start making changes, to mirror your older Apache setup for example. The way that the server is configured is now significantly changed.

All the configuration files are located inside /etc/apache2, instead of the previous location /etc/apache. Logfiles will by default end up inside /var/log/apache2.

If you look at the directory structure you will see the following directories:

root@mystery:/etc/apache2# ls -l
total 42
-rw-r--r--  1 root root 12482 2004-11-10 12:00 apache2.conf
drwxr-xr-x  2 root root  1024 2004-11-10 12:00 conf.d
-rw-r--r--  1 root root   748 2005-02-25 08:27 envvars
-rw-r--r--  1 root root   268 2005-01-20 11:36 httpd.conf
-rw-r--r--  1 root root 12441 2004-11-10 12:00 magic
drwxr-xr-x  2 root root  3072 2005-02-28 10:13 mods-available
drwxr-xr-x  2 root root  1024 2005-03-02 11:49 mods-enabled
-rw-r--r--  1 root root    21 2005-03-02 11:50 ports.conf
-rw-r--r--  1 root root  2266 2004-11-10 12:00 README
drwxr-xr-x  2 root root  1024 2005-03-02 11:54 sites-available
drwxr-xr-x  2 root root  1024 2005-03-02 12:21 sites-enabled
drwxr-xr-x  2 root root  1024 2005-03-02 12:20 ssl

The directories (in bold above) will need some explaining as they are new in this package. The basic scheme is simple to understand once you know what everthing is, and why it's there.

The conf.d is an empty directory, but anything placed inside there will be read and included in your Apache2 package. It is designed so that other packages such as webmail packages, for example, can just drop little snippets in there when they are installed and be ready to run out of the box.

The mod-available, and mod-enabled directories are both concerned with Apache extension modules. The first directory contains information relating to each of the modules which apache installs by default. Each module has two files:

blah.load   - A "LoadModule" statement.
blah.conf   - Configuration options for this module.

To enable a particular module you must create symbolic links between the two files and the directory "mod-enabled". Or to put it another way every file inside the mods-enabled directory is included when Apache starts.

The sites-available, and sites-enabled directories both work in a similar way to the modules directories we've just mentioned. The sites-available directory contains a single configuration file for each virtual host that your server supports. The sites-enabled has symbolic links to those hosts which you wish to be enabled.

Rather than dealing with the symbolic links manually, though, there are some new commands:

a2enmod    - Apache2 Enable Module
a2dismod   - Apache2 Disable Module
a2ensite   - Apache2 Enable Site
a2dissite  - Apache2 Disable Site

You can run one of these without arguments to see which modules/sites you can enable/disable, or give it an argument for the module or site you wish to have changed.

So, for example, to load a new module, mod_rewrite you could run "a2enmod rewrite", this gives the following output:

root@mystery:/etc/apache2# a2enmod rewrite
Module rewrite installed; run /etc/init.d/apache2 force-reload to enable.

Enabling SSL for Apache2

To enable the SSL support built into Apache2 you will need to do three things:

  • Load the SSL Module
  • Setup a certificate
  • Setup your virtual host(s) to use SSL

The first is relatively simple, you can either fiddle with the symbolic links yourself, or you can simply run:

a2enmod ssl

This will setup the SSL module to be loaded by Apache, if it's not already configured.

To create your certificate you must simply execute the apache2-ssl-certificate command, and answer the different questions. Once this has finished you'll find the generated files inside the directory /etc/apache2/ssl.

Finally to cause your virtual host to use the SSL setup you should add the following to it:

# This host uses SSL
SSLEngine on

# Get the SSL details from here:
SSLCertificateFile /etc/apache2/ssl/apache.pem

You will also need to add the following to /etc/apache2/ports.conf to cause it to listen on the SSL port, 443:

Listen 443

Once this has been done you can restart the server with the following command and attempt to connect via an SSL enabled client:

/etc/init.d/apache2 restart

 

 


Posted by Anonymous (130.233.xx.xx) on Wed 15 Jun 2005 at 09:01
"(So simply change the 0 to 1 and the server will attempt to start at boot time)."

If you change NO_START to 1 then /etc/init.d/apache2 start will complain:

"Not starting apache2 - edit /etc/default/apache2 and change NO_START to be 0."

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Wed 15 Jun 2005 at 09:03
[ View Steve's Scratchpad | View Weblogs ]

D'oh - that's obviously the wrong way round - I'll update the text now.

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by Anonymous (85.74.xx.xx) on Mon 25 Jul 2005 at 15:17
i had to add the line
SSLCertificateKeyFile /path/to/may/key/file

[ Parent | Reply to this comment ]

Posted by Anonymous (68.226.xx.xx) on Thu 4 Aug 2005 at 02:44
I did these things and it works as advertised, thanks for the help. One issue I am having though is that my site is now accessible only via SSL. Is there a simple way to make it accessible via https and http simultaneously?

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 4 Aug 2005 at 02:46
[ View Steve's Scratchpad | View Weblogs ]

Sure, just add both ports to the ports.conf file:

Listen 80
Listen 443

Then use two seperate virtual hosts, one with SSL enabled, and one without it. They can be identical in all other respects.

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by Anonymous (198.60.xx.xx) on Mon 12 Sep 2005 at 21:59
I am using apache2 also, I am still kind new to linux and I just installed Sarge with Apache2. I am trying to run a webserver in this machine, however, I was under de impression that somewhere in the apache2.conf file I could put the ip address of my machine or my domain name, but I don't see that option. Where do I need to put that entry? Please Help.
Is there some paper about the configuration for apache2.conf in the internet? remember I am still new to this. Thanks again.

Fernando

[ Parent | Reply to this comment ]

Posted by Anonymous (213.162.xx.xx) on Wed 14 Sep 2005 at 12:41
Hello,

If I am not wrong, you don(t have to modify apache2.conf.
If youy want to specify a particular IP address for Apache to listen youy can edit ports.conf and add Listen x.x.x.x:80 where x.x.x.x is your IP address.

You can define your domain name in a virtualhost with directive ServerName.

See documentation at httpd.apache.org for more info about configuring apache (the article has described the Debian particular things to do).

Hope it helps

[ Parent | Reply to this comment ]

Posted by Anonymous (198.60.xx.xx) on Sun 18 Sep 2005 at 08:21
I was wrong... my network card was getting a dhcp ip address from my router, I made the change and everything is fine now.
Thanks for your help.

[ Parent | Reply to this comment ]

Posted by suspended user gg234 (195.14.xx.xx) on Thu 6 Oct 2005 at 13:13
if you include how to change the root document directory that would help many people

[ Parent | Reply to this comment ]

Posted by griztown (208.20.xx.xx) on Wed 2 Nov 2005 at 22:38
The question I have in regards to using Apache2 on Debian is how to enable using index.php as my default in the root directory. Here's my problem. I have two sites on my server. I enabled the second site by copying the default file and renaming it and changing all relevant info inside then adding it using a2ensite. In the root directory of the second site I have an index.php file which I want to use. If I type in www.secondsite.com/index.php it works fine but if I type in www.secondsite.com it brings up an open window and asks me what to do. What am I doing wrong here? I have a line DirectoryIndex index.html index.php in my conf file. I don't understand why it isn't working.

I've searched around on how to use this new configuration technique and there hasn't been anything on how to actually create the file that you symbolically link using a2ensite. My recommendation would be to do away with this directory technique and go back to the original way.

Thanks, any help is appreciated.

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 3 Nov 2005 at 11:47
[ View Steve's Scratchpad | View Weblogs ]

That sounds strange, DirectoryIndex is certainly the thing that should set this up for you.

Probably a good idea to post your file contents here if you can, as otherwise tracking it down would be tricky.

Steve
--

[ Parent | Reply to this comment ]

Posted by griztown (208.20.xx.xx) on Thu 3 Nov 2005 at 17:08
Okay, so which specific files should I post? For now I'll post apache.conf and the two files under sites-available.

APACHE.CONF
# Based upon the NCSA server configuration files originally by Rob McCool.
# Changed extensively for the Debian package by Daniel Stone
# and also by Thom May .

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE! If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation
# (available at );
# you will save yourself a lot of trouble.

ServerRoot "/etc/apache2"

# The LockFile directive sets the path to the lockfile used when Apache
# is compiled with either USE_FCNTL_SERIALIZED_ACCEPT or
# USE_FLOCK_SERIALIZED_ACCEPT. This directive should normally be left at
# its default value. The main reason for changing it is if the logs
# directory is NFS mounted, since the lockfile MUST BE STORED ON A LOCAL
# DISK. The PID of the main server process is automatically appended to
# the filename.

LockFile /var/lock/apache2/accept.lock

# PidFile: The file in which the server should record its process
# identification number when it starts.

PidFile /var/run/apache2.pid

# Timeout: The number of seconds before receives and sends time out.

Timeout 300

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.

KeepAlive On

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.

KeepAliveTimeout 15

##
## Server-Pool Size Regulation (MPM specific)
##

# prefork MPM
# StartServers ......... number of server processes to start
# MinSpareServers ...... minimum number of server processes which are kept spare
# MaxSpareServers ...... maximum number of server processes which are kept spare
# MaxClients ........... maximum number of server processes allowed to start
# MaxRequestsPerChild .. maximum number of requests a server process serves

StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 20
MaxRequestsPerChild 0


# pthread MPM
# StartServers ......... initial number of server processes to start
# MaxClients ........... maximum number of server processes allowed to start
# MinSpareThreads ...... minimum number of worker threads which are kept spare
# MaxSpareThreads ...... maximum number of worker threads which are kept spare
# ThreadsPerChild ...... constant number of worker threads in each server process
# MaxRequestsPerChild .. maximum number of requests a server process serves

StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0


# perchild MPM
# NumServers ........... constant number of server processes
# StartThreads ......... initial number of worker threads in each server process
# MinSpareThreads ...... minimum number of worker threads which are kept spare
# MaxSpareThreads ...... maximum number of worker threads which are kept spare
# MaxThreadsPerChild ... maximum number of worker threads in each server process
# MaxRequestsPerChild .. maximum number of connections per server process (then it dies)

NumServers 5
StartThreads 5
MinSpareThreads 5
MaxSpareThreads 10
MaxThreadsPerChild 20
MaxRequestsPerChild 0
AcceptMutex fcntl


User www-data
Group www-data

# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent


# Global error log.
ErrorLog /var/log/apache2/error.log

# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

# Include all the user configurations:
Include /etc/apache2/httpd.conf

# Include ports listing
Include /etc/apache2/ports.conf

# Include generic snippets of statements
Include /etc/apache2/conf.d/[^.#]*

#Let's have some Icons, shall we?
Alias /icons/ "/usr/share/apache2/icons/"

Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all


# Set up the default error docs.
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# Putting this all together, we can Internationalize error responses.
#
# We use Alias to redirect any /error/HTTP_.html.var response to
# our collection of by-error message multi-language collections. We use
# includes to substitute the appropriate text.
#
# You can modify the messages' appearance without changing any of the
# default HTTP_.html.var files by adding the line;
#
# Alias /error/include/ "/your/include/path/"
#
# which allows you to create your own set of files by starting with the
# /usr/local/apache2/error/include/ files and
# copying them to /your/include/path/, even on a per-VirtualHost basis.
#



Alias /error/ "/usr/share/apache2/error/"


AllowOverride None
Options IncludesNoExec
AddOutputFilter Includes html
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en es de fr
ForceLanguagePriority Prefer Fallback


ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
ErrorDocument 410 /error/HTTP_GONE.html.var
ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
ErrorDocument 415 /error/HTTP_SERVICE_UNAVAILABLE.html.var
ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var




DirectoryIndex index.html index.php

# UserDir is now a module
#UserDir public_html
#UserDir disabled root

#
# AllowOverride FileInfo AuthConfig Limit
# Options Indexes SymLinksIfOwnerMatch IncludesNoExec
#

AccessFileName .htaccess


Order allow,deny
Deny from all


UseCanonicalName Off

TypesConfig /etc/mime.types
DefaultType text/plain

HostnameLookups Off

IndexOptions FancyIndexing VersionSort

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

# This really should be .jpg.

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^


# This is from Matty J's patch. Anyone want to make the icons?
#AddIcon /icons/dirsymlink.jpg ^^SYMDIR^^
#AddIcon /icons/symlink.jpg ^^SYMLINK^^

DefaultIcon /icons/unknown.gif

ReadmeName README.html
HeaderName HEADER.html

IndexIgnore .??* *~ *# HEADER* RCS CVS *,t

AddEncoding x-compress Z
AddEncoding x-gzip gz tgz

AddLanguage da .dk
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .et
AddLanguage fr .fr
AddLanguage de .de
AddLanguage el .el
AddLanguage it .it
AddLanguage ja .ja
AddLanguage pl .po
AddLanguage ko .ko
AddLanguage pt .pt
AddLanguage no .no
AddLanguage pt-br .pt-br
AddLanguage ltz .ltz
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .se
AddLanguage cz .cz
AddLanguage ru .ru
AddLanguage tw .tw
AddLanguage zh-tw .tw

LanguagePriority en da nl et fr de el it ja ko no pl pt pt-br ltz ca es sv tw


#AddDefaultCharset ISO-8859-1

AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3 .iso8859-3 .latin3
AddCharset ISO-8859-4 .iso8859-4 .latin4
AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru
AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb
AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk
AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb
AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5 .Big5 .big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866
AddCharset KOI8-r .koi8-r .koi8-ru
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8 .utf8

AddCharset GB2312 .gb2312 .gb
AddCharset utf-7 .utf7
AddCharset utf-8 .utf8
AddCharset big5 .big5 .b5
AddCharset EUC-TW .euc-tw
AddCharset EUC-JP .euc-jp
AddCharset EUC-KR .euc-kr
AddCharset shift_jis .sjis

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddHandler php-script php
AddType application/x-tar .tgz

# To use CGI scripts outside /cgi-bin/:
#
#AddHandler cgi-script .cgi

# To use server-parsed HTML files
#

SetOutputFilter INCLUDES


# If you wish to use server-parsed imagemap files, use
#
#AddHandler imap-file map

BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

#
# The following directive disables redirects on non-GET requests for
# a directory that does not include the trailing slash. This fixes a
# problem with Microsoft WebFolders which does not appropriately handle
# redirects for folders with DAV methods.
#

BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully

# Allow server status reports, with the URL of http://servername/server-status
# Change the ".your_domain.com" to match your domain to enable.
#
#
# SetHandler server-status
# Order deny,allow
# Deny from all
# Allow from .your_domain.com
#

# Allow remote server configuration reports, with the URL of
# http://servername/server-info (requires that mod_info.c be loaded).
# Change the ".your_domain.com" to match your domain to enable.
#
#
# SetHandler server-info
# Order deny,allow
# Deny from all
# Allow from .your_domain.com
#

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/[^.#]*



Under sites-available:
DEFAULT
NameVirtualHost *

ServerName www.katieandted.com
ServerAlias katieandted.com *.katieandted.com

ServerAdmin webmaster@localhost

DocumentRoot /home/tbrenner/web/docs/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# RedirectMatch ^/$ /apache2-default/


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128


AllowOverride Options FileInfo



The other site file: PALEO
NameVirtualHost *

ServerName www.paleojudge.com
ServerAlias paleojudge.com *.paleojudge.com

ServerAdmin root@localhost

DirectoryIndex index.html index.php
DocumentRoot /home/tbrenner/web/paleo/www/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# RedirectMatch ^/$ /apache2-default/


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /var/log/apache2/paleo-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/paleo-access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128


AllowOverride Options FileInfo




Thanks for the help!

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 3 Nov 2005 at 17:16
[ View Steve's Scratchpad | View Weblogs ]

The problem is that the second site, www.paleojudge.com, is sending the index as 'Content-type: application/x-trash'. That's the content type set for files ending in "~", "bak", "old", or "sik".

What does the output of this command show? :

ls -l  /home/tbrenner/web/paleo/www/

(No need to post the massive apache2.conf file - only the two site files)

Finally what do you see in the error logs?

Steve
--

[ Parent | Reply to this comment ]

Posted by griztown (208.20.xx.xx) on Thu 3 Nov 2005 at 17:29
Here's the output:

total 88
drwxr-xr-x 12 www-data tbrenner 4096 2005-11-03 10:20 .
drwxr-xr-x 3 tbrenner tbrenner 4096 2005-04-11 22:08 ..
drwxr-xr-x 7 www-data tbrenner 4096 2005-10-13 18:57 albums
drwxr-xr-x 2 www-data tbrenner 4096 2005-01-02 22:33 archives
drwxr-xr-x 14 www-data tbrenner 4096 2005-01-03 10:14 blog
-rw-r--r-- 1 www-data tbrenner 971 2004-11-29 19:34 footer.inc
drwxr-xr-x 21 www-data tbrenner 4096 2005-10-13 18:53 gallery
-rw-r--r-- 1 www-data tbrenner 1367 2004-12-03 07:19 #header.inc#
-rw-r--r-- 1 www-data tbrenner 1362 2004-11-29 19:34 header.inc
drwxr-xr-x 3 www-data tbrenner 4096 2004-10-14 10:31 images
-rw-r--r-- 1 www-data tbrenner 506 2005-04-18 15:52 index.html.old
-rw-r--r-- 1 root root 505 2005-10-13 20:32 index.html.tmp
-rwxr-xr-x 1 www-data www-data 1059 2005-10-17 10:02 index.php
-rw-r--r-- 1 www-data tbrenner 1059 2005-10-17 09:58 index.php.old
-rw-r--r-- 1 root root 0 2005-11-03 10:20 lsla
drwxr-xr-x 7 www-data tbrenner 4096 2005-01-03 06:44 mt
drwxr-xr-x 4 www-data tbrenner 4096 2004-12-31 11:20 mt-static
drwxr-xr-x 2 www-data tbrenner 4096 2004-10-13 06:27 sultana
drwxr-xr-x 2 www-data tbrenner 4096 2005-01-02 21:57 test
-rw-r--r-- 1 root root 1059 2005-10-17 10:01 test1.php
-rw-r--r-- 1 www-data tbrenner 3554 2005-01-02 16:15 test.html
-rw-r--r-- 1 root root 177 2005-10-17 10:01 test.php
drwxr-xr-x 2 www-data tbrenner 4096 2004-10-14 06:28 vienna

So I do have index.html.old and index.php.old. I renamed those files and now it seems to work. Amazing!

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 3 Nov 2005 at 17:30
[ View Steve's Scratchpad | View Weblogs ]

Cool, glad I could help.

I'm not 100% sure why you're being sent the .old versions of those files - as that certainly doesn't happen with my Apache2 setup.

I'm sure it's something relating to content-negotiation, as I hinted in my other comment, but I'm not sure precisely what it is.

Still looks like you're sorted for the moment.....

Steve
--

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 3 Nov 2005 at 17:25
[ View Steve's Scratchpad | View Weblogs ]

Update:

When I request the index page:

telnet www.paleojudge.com 80
Trying 64.81.88.31...
Connected to www.katieandted.com.
Escape character is '^]'.
GET / HTTP/1.0
Host: www.paleojudge.com

The response I get back includes this:

Content-Location: index.html.old
Vary: negotiate
TCN: choice
Last-Modified: Mon, 18 Apr 2005 22:52:53 GMT
ETag: "18d01d-1fa-da1f5b40"
Accept-Ranges: bytes
Content-Type: application/x-trash

The two bolded lines are causing the problem. Remove MultiViews and I think the problem will go away.

Steve
--

[ Parent | Reply to this comment ]

Posted by griztown (208.20.xx.xx) on Thu 3 Nov 2005 at 17:31
Thanks Steve, I really appreciate the help. I've been banging my head against a wall on this problem for weeks now.

[ Parent | Reply to this comment ]

Posted by Anonymous (69.3.xx.xx) on Wed 23 Nov 2005 at 16:36
I've got the same issue. I've removed all the Multiviews...

Any ideas?

[ Parent | Reply to this comment ]

Posted by Anonymous (24.46.xx.xx) on Thu 19 Jan 2006 at 19:55
Newbie is trying for debian step by step...

I do have index.html in /var/www/, but it opens index file in /var/www/apache2-default/index.html.

How can I solve this problem?

Thank you in advance!

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 19 Jan 2006 at 20:08
[ View Steve's Scratchpad | View Weblogs ]

Remove the rewriting rules from /etc/apache2/sites-enabled/default - or similar file.

Steve

[ Parent | Reply to this comment ]

Posted by Anonymous (24.46.xx.xx) on Thu 19 Jan 2006 at 20:21
wow...
Steve, you are so fast. Thank you.



[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 19 Jan 2006 at 20:22
[ View Steve's Scratchpad | View Weblogs ]

You got lucky - I'm just on my way to sleep but checked my mail first.

Had it been a harder question to answer I'd have left it until tomorrow, or next week ;)

Steve

[ Parent | Reply to this comment ]

Posted by mrki (82.208.xx.xx) on Fri 24 Mar 2006 at 09:40
I am running apache2 with mpm_prefork_module and I would like an upgrade to mpm_worker_module (core upgrading) to increase speed for sites running over this server. I am not sure which upgrade tool to use apt or dpkg? 6 sites are ruining as well vhcs2 (Control Panel Software). So, do I have to make backups of /var/www and /etc/apache2 directory's to keep my config settings (modules, virtual hosts...) or will this upgrade only affects the binary files without changing my config files and virtual hosts?

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Sat 25 Mar 2006 at 16:25
[ View Steve's Scratchpad | View Weblogs ]

The configuration files should be fine.

But making a backup wouldn't cause any harm ..

Steve

[ Parent | Reply to this comment ]

Posted by yanger (66.84.xx.xx) on Wed 12 Apr 2006 at 15:22
did apt-get install apache2 php4 mysql-server-5.0 ...

checked to make sure php4 was in the mods-enabled, and looking at phps files work wonders (colorized, etc) but when clicking on php documents, they just blip and the browser asks if I want to download or not... not sure how to fix...

[ Parent | Reply to this comment ]

Posted by Steve (212.20.xx.xx) on Wed 12 Apr 2006 at 15:24
[ View Steve's Scratchpad | View Weblogs ]

You'll want libapache2-mod-php4 rather than php4. But otherwise it should be all you need.

Just verify it is enabled:

a2enmod php4

Then make sure you restart Apache:

/etc/init.d/apache2 restart

Steve

[ Parent | Reply to this comment ]

Posted by endecotp (86.6.xx.xx) on Fri 6 Jul 2007 at 23:24
[ View Weblogs ]
Since this article was written, apache2-ssl-certificate has gone. See this bug:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=398520

or this comment:

http://www.debian-administration.org/articles/349#comment_50

for alternatives.

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

What do you use for configuration management?








( 472 votes ~ 5 comments )

 

 

Related Links