U    Upgrade Apache 1.3 to apache2.0 in Debian


     upgrade from Apache 1.3 to Apache 2.0 on Debian Sarge, and it's not as difficult as you might think.
The first step in upgrading is to read the release announcement and the file CHANGES in the source distribution to find any changes that may affect your site. When changing between major releases (for example, from 1.3 to 2.0 or from 2.0 to 2.2), there will likely be major differences in the compile-time and run-time configuration that will require manual adjustments. All modules will also need to be upgraded to accomodate changes in the module API.

     Despite some differences in the configurations of the two versions of Apache, the upgrade can be a surprisingly smooth process if you plan well. This assumes that you already have Apache 1.3 installed on Debian Sarge, have root access to the server, and have one or more sites configured as virtual hosts in your /etc/apache/httpd.conf file.


    The first step is to install the Debian packages for Apache 2.

     Run from your command prompt


     then you run below command

     # apt-get install apache2 apache2-common

     This will install the Apache server and support packages. If you receive a "Couldn't find package apache2" error, or similar, check your package resource list (/etc/apt/sources.list) to make sure that your list of package archives is correct.

     If you want to install PHP support for your apache server you need to install the libapache2-mod-php4 package for this

    #apt-get install libapache2-mod-php4

    If you want to install mod_python support for your apache server you need to install the libapache2-mod-python package for this

    #apt-get install libapache2-mod-python

Now Apache 2 is installed, but you can't start it in the default configuration because it's using the same port as Apache 1.3. If you try, you should receive a message that says a service is already running on port 80. Since Apache is already running on port 80, apt, Debian's package installer, will disable Apache 2 by default by setting NO_START=1 in the configuration file /etc/default/apache2. To change this, edit /etc/apache2/ports.conf to change the port that Apache 2 will monitor for requests. Change Listen 80 to Listen 8081, or whatever port you want to use for testing purposes, as long as it doesn't conflict with another service. Then you can change the NO_START entry in /etc/default/apache2 to 0, and run /etc/init.d/apache2 start to start your shiny new Apache 2 Web server.

     Configuring Virtual hosts

     The next step is to configure your virtual hosts. The configuration file layout is different between Apache 1.3 and Apache 2.0 on Debian. While Apache 1.3 typically has all of its virtual hosts information in the /etc/apache/httpd.conf file, Apache 2.0 is set up to look for virtual host configurations in the /etc/apache2/sites-enabled directory.

     Say, for instance, that your /etc/apache/httpd.conf virtual hosts section looks like this:

     # Named VirtualHosts
NameVirtualHost *
<VirtualHost *>
DocumentRoot /home/www/htdocs

<VirtualHost *>
DocumentRoot /home/www/htdocsl/
CustomLog /var/log/apache2/logs/

     This could translate in Apache 2 into one or more separate configuration files under /etc/apache2/sites-enabled. While you can keep all of your virtual host entries in one configuration file, it's usually best to split them into separate configuration files for each host.

     With Apache 1.3, the first entry of your VirtualHosts section serves as your "default" site -- in other words, if someone comes to a site that's not configured in your VirtualHosts section correctly, but is specified in public DNS as your server's IP address, he will be sent to the default Web site.

    With Apache 2.0, the default site is instead the first file (in alphabetical order) in the /etc/apache2/sites-enabled directory. After initial installation, there will be a symlink from 000-default in this directory to /etc/apache2/sites-available/default. As you can see from this, Apache 2.0 offers another level of abstraction in virtual hosts by recommending putting the actual files in /etc/apache2/sites-available and then symlinking from there to /etc/apache2/sites-enabled.

    You can see the following example in apache2. It makes it much easier to manage when there are a large number of virtual hosts on a server. In the example above, you would create two files, /etc/apache2/sites-available/default and etc/apache2/sites-available/ The /etc/apache2/sites-available/default file would look like this:

     NameVirtualHost *
<VirtualHost *>
DocumentRoot /home/www/htdocs

     And the /etc/apache2/sites-available/ would look like this:

     <VirtualHost *>
DocumentRoot /home/www/htdocsl/
CustomLog /var/log/apache2/logs/

     Creating Symlinks

     Create symlinks to the files in the /etc/apache2/sites-enabled directory with the ln -s or a2ensite


     Using ln -s

     ln -s /etc/apache2/sites-available/ /etc/apache2/sites-enabled/

     Using a2ensite

     a2ensite /etc/apache2/sites-available/ /etc/apache2/sites-enabled/

If you want to enable any modules you can use a2enmod command

     Example:- If you want to load rewrite module for your apache use the following

     #a2enmod rewrite

     Now that you have the virtual hosts configured, it's time to test. To start Apache 2, type /etc/init.d/apache2 start. Fire up a browser and head to Obviously, this will only work assuming you have a correct virtual host entry for a hostname which has DNS pointing to your server rather than Alternatively, you can add an entry in the /etc/hosts file on the machine that you're browsing from to fool it into thinking it should be going to the IP address of your server.

     If Apache 2 didn't start correctly, you may see errors when running /etc/init.d/apache2 start, and you will need to resolve some issues before you can proceed. Check the /var/log/apache2/error.log for details on any problems.

     If your sites are running PHP with PostgreSQL or MySQL database backends, as well as a Zope/Plone instance that's being served from Apache using mod_rewrite. As a result,you need to install the libapache2-mod-php4 and libapache2-mod-proxy-html packages. In addition,you need to copy my existing php.ini file (/etc/php4/apache/php.ini) to /etc/php4/apache2/php.ini to make sure all your PHP settings were preserved. You also need to create symlinks from /etc/apache2/mods-available/proxy.load and rewrite.load to the /etc/apache2/mods-enabled directory. Once again, Apache 2 is modularizing its configuration layout.

     Your final step to resolve Apache 2 startup issues was to symlink /etc/apache/logs to /etc/apache2/logs, as that was my log file directory.

     you're now ready to migrate to Apache 2.0 Stop Apache 2 if it's running by using the command /etc/init.d/apache2 stop, and change the /etc/apache2/ports.conf to use port 80. Stop Apache 1.3 with /etc/init.d/apache stop, and then fire up Apache 2 with /etc/init.d/apache2 start.

     The final steps include making sure Apache 2 will start when the server is rebooted, and making sure Apache 1.3 won't. There are a few ways to remove Apache 1.3 from the services that start on boot. One is to remove the symlinks for Apache in the /etc/rc*.d directories. Another is to use the sysv-rc-conf run-level configuration editor. This is not installed on Debian systems by default, but can be installed using apt-get install sysv-rc-conf.

You may also want to verify that a start link (like "S91apache2") is in the /etc/rc2.d directory and symlinked to /etc/init.d/apache2. This will ensure Apache 2 is started on reboot, and should have been configured when the package was installed.

       Important Points need to check


       When you upgrade Apache you have to install libapache2-mod-php4 (well you don't have to but I suggest you do). The first problem is with register_globals which is set to on in the default php.ini for Apache 1.3 but off in the default php.ini for Apache 2. If your website makes use of $DOCUMENT_ROOT then this little difference will render your site useless until you change it to on. There are good reasons to have register_globals set to off, and you should modify your site to work with it set to off, but the lack of consistency will likely catch you out.

 Many to Many SAPI Upgrade

      The second big problem is with the fact that when you install Apache 2 after Apache 1.3 it doesn't automatically update the php.ini files so that the related packages can be used with Apache 2. The result is that database access doesn't work and you get nasty error messages like this:

Fatal error: Call to undefined function: pg_connect() in
/usr/share/phpbb2/site/db/postgres7.php on line 79

    The solution to this is to reconfigure the php4-pgsql and php4-mysql packages with:

dpkg-reconfigure php4-pgsql php4-mysql