| View previous topic :: View next topic |
| Author |
Message |
nomego n00b

Joined: 08 Jul 2003 Posts: 5 Location: Sweden
|
Posted: Thu Jul 10, 2003 8:54 am Post subject: Apache 1.3 to 2.0 migration guide (v. 0.2) |
|
|
Due to some requests in #gentoo on freenode (IRC) I've decided to put a guide for people that wants to migrate to Apache 2.0 from 1.3 without having any downtime. In the following text, Apache 1.3 will be referred to as apache, and Apache 2.0 as apache2.
This is not an advanced guide, but it might help with some of the gotchas.
These were the things that had to work after the migration:- mod_php
- mod_dav
- mod_ssl
- vhosts
- mod_php as handler for .xml
I didn't need to emerge mod_dav or mod_ssl, update me if one should need to.
Update: mod_perl is still in beta-stage for apache2. If you're using mod_perl, you should probably stick with apache for now.
- Emerge apache2.
Gotcha! Emerging apache2 will overwrite any index.html/index.html.[lang] in /home/httpd/htdocs. Be sure to make a backup of your website(s)!
| Code: | | # emerge /usr/portage/net-www/apache/apache-2.<version>.ebuild |
Add "apache2" to your USE flags in /etc/make.conf
Emerge mod_php
This will emerge mod_php against apxs2, rendering mod_php usable for apache2, but useless against apache.
Gotcha! mod_php for apache will be replaced by a mod_php for apache2, so if you restart apache after mod_php has been re-emerged with the "apache2" USE flag, you will have downtime. As long as apache is running in memory, the "old" mod_php will be active, so replacing it does not affect it until a restart of the apache service.
Run etc-update
It's necessary to update the php.ini file, at least I had a lot of changes to be made. (Correct me if I'm wrong.)
Edit /etc/apache2/conf/apache2.conf
In this configuration file, edit the "Listen" directive so that it doesn't use an occupied port. My apache was running on port 80 (as most do..) so I changed it to 808.
| Code: | # sed -e 's/^Listen 80$/Listen 808/g' < /etc/apache2/conf/apache2.conf > /etc/apache2/conf/apache2.new
# mv /etc/apache2/conf/apache2.new /etc/apache2/conf/apache2.conf |
(Optional) Edit /etc/apache2/conf/modules.d/70_mod_php.conf
This is where libphp4.so is loaded, and where you specify what type of files mod_php should be the handler of. I added .xml to the list. (Remove the "\" and the end of the first line and the newline from the following code if you want to use it.)
| Code: | # sed -e 's/<IfModule mod_mime.c>/\0\n\tAddType application\/x-httpd-php .xml/g' < /etc/apache2/conf/modules.d/70_mod_php.conf \
> /etc/apache2/conf/modules.d/70_mod_php.conf.new
# mv /etc/apache2/conf/modules.d/70_mod_php.conf.new /etc/apache2/conf/modules.d/70_mod_php.conf.new |
(Optional) Copy your vhost configuration
| Code: | | # cp /etc/apache/conf/vhosts/Vhosts.conf /etc/apache2/conf/vhosts/vhosts.conf |
Tell apache2 to use PHP and/or DAV and/or SSL
To do this, we must edit the /etc/conf.d/apache2 file. Make sure the variable "APACHE2_OPTS" contains all the modules you need.
Example: APACHE2_OPTS="-D PHP4 -D SSL -D DAV"
| Code: | # sed -e 's/.*APACHE2_OPTS.*/APACHE2_OPTS="-D PHP4 -D SSL -D DAV"/g' < /etc/conf.d/apache2 > /etc/conf.d/apache2.new
# mv /etc/conf.d/apache2.new /etc/conf.d/apache2 |
Verify configuration syntax
When copying the Vhosts configuration from apache, som directives may be deprecated, and some little typo may have sneaked into one or more of the files, so ensure that your configuration is OK.
| Code: | # apache2ctl -t
Syntax OK |
Give it a try!
Now we're ready to try the new apache2!
Since we changed the port (Listen directive) in /etc/apache2/conf/apache2.conf, we can now try apache2 alongside of apache. Let's try starting it and browsing to a non-existing directory. | Code: | # /etc/init.d/apache2 start
* Starting apache2... [ok]
# lynx -dump http://localhost:80/server-status
You don't have permission to access /server-status on this server.
_________________________________________________________________
Apache/2.0.46 (Gentoo/Linux) mod_ssl/2.0.46 OpenSSL/0.9.6i DAV/2
PHP/4.3.2 Server at texi.yes.nu Port 808
|
The last two lines tells us that mod_ssl, DAV and PHP4 are working correctly! YES!
Now try all your vhosts, PHP sites, etc.
Replacing apache for real
Yepp, let's do it. First we have to change the Listen directive.
| Code: | # sed -e 's/^Listen 808$/Listen 80/g' < /etc/apache2/conf/apache2.conf > /etc/apache2/conf/apache2.new
# mv /etc/apache2/conf/apache2.new /etc/apache2/conf/apache2.conf
# /etc/init.d/apache stop ; /etc/init.d/apache2 restart |
Making the change last
As we all Gentooers know, right now, a reboot would not result in a functioning webserver.
| Code: | # rc-update del apache default
# rc-update add apache2 default |
Update: For those of you that wants to clean up a bit, pruning the apache package shouldn't cause any problems with shared files. I pruned my apache, and first of all, all dirs are different. (/usr/include/apache2, /usr/lib/apache2, and so on.) Secondly, since portage is such an ultimate companion, it checks the modification time on the files to be removed, thus /home/httpd/htdocs files installed by apache2 won't be removed either.
That should be all! Please post any comments/corretions!
Last edited by nomego on Thu Jul 10, 2003 8:14 pm; edited 3 times in total |
|
| Back to top |
|
 |
neilhwatson l33t


Joined: 06 Feb 2003 Posts: 719 Location: Canada
|
Posted: Thu Jul 10, 2003 12:23 pm Post subject: |
|
|
Thank you, that is useful.
Caveat: Anyone who is about to ask about mod_perl should be aware that mod_perl for apache2 is still in beta (1.99_10 when last I checked). If you need to use mod_perl I suggest you stay with apache 1.3.xx for now. _________________ The true guru is a teacher.
Neil Watson |
|
| Back to top |
|
 |
cgansen n00b

Joined: 02 Dec 2002 Posts: 29
|
Posted: Thu Jul 10, 2003 5:27 pm Post subject: |
|
|
thanks for the guide -- I"ve been meaning to do this for quite some time.
any idea as to what the ramifications are of unmerging apache 1.3.x after succesfully getting apache2 up and running? any shared files/configs that might be a problem?
thanks,
--chris |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|