How to recompile apache 2.0.x?

7 posts / 0 new
Last post
#1 Wed, 12/21/2005 - 00:40
AdamHolt

How to recompile apache 2.0.x?

I want to run virtualmin, and need to recompile apache on a suse 9.3 pro server to make the doc root /home

Can someone tell me how to do this, or point me where it might be written down on the web in step by step instructions.

Thanks,

Tue, 12/27/2005 - 04:20
Joe
Joe's picture

Hey Adam,

It's pretty easy, but does require a few devel packages to be installed on your machine--setting up an RPM build environment is way beyond the scope of this post, but you can do builds as root (not good practice for packages you don't trust, but you'll be editing a SUSE provided package, so it won't be a serious risk) without much trouble. You'll, at least, need the rpm-build, make, and gcc packages. Probably others, but you'll see what they are when you try to build (if the SRPM includes the appropriate BuildPrereqs).

Anyway, go to your favorite SUSE mirror. Download the latest apache2 src.rpm file for your version of SUSE. Probably this (but always check for newer versions):

wget http://mirrors.kernel.org/suse/i386/update/9.3/rpm/src/apache2-2.0.53-9....

Now, install it:

rpm -ivh apache2-2.0.53-9.9.src.rpm

This will put all of the sources and spec file into a directory tree in your RPM build directory (if running it as root, it will be /usr/src/packages). Go to the SPECS directory, and edit the apache2.spec file with your favorite text editor. I like vim, as it has nice syntax highlighting for spec files (and everything else). But emacs is good too. If you're not familiar with the boss UNIX text editors, you can still get by with pico or nano (nano is becoming the more commonly available, as it is a pico clone that <i>isn't</i> tied to pine).

Fine the line that reads &quot;--with-suexec-docroot=foo&quot;, and change it to read &quot;--with-suexec-docroot=/home&quot;. (&quot;foo&quot; will actually be a variable...I don't recall the name of it at the moment. But you can just replace it with the string &quot;/home&quot;.

While you're in there, change the Release to be one higher, so you can &quot;upgrade&quot; your current apache package without hassle. You'll find the Release: field at almost the very top of the file. I like to append one or two letters to the end of the release so that I'll recognize the package as one of mine later on when I'm wondering if I have a fixed version of the package or not! So, my build of this package has &quot;Release: 9.10.vm&quot;

Save it.

Now rebuild it with the command:

rpmbuild -ba apache2.spec

And upgrade to it using the freshen command (this'll upgrade only the apache2 packages you already have):

rpm -Fvh /usr/src/packages/RPMS/i586/*

This assumes you only have the freshly built packages in that directory. If you've already got packages there, you'll need to be more specific about this command, as it could be a bit hazardous to randomly freshen a bunch of packages (probably not particularly so, but one never knows--if I did this in my RPMs dir, I'm certain something bad would happen, as I have a couple hundred packages there...some of which have strange versions and epochs).

Holler if you get stumped anywhere.

--

Check out the forum guidelines!

Wed, 12/13/2006 - 18:27 (Reply to #2)
MikeF

Hello Joe,

I have build new rpm as you instructed above, but when called upgrade with freshen command I got only this:

$:/usr/src # rpm -Fvh /usr/src/packages/RPMS/i586/*
Preparing... ########################################### [[100%]]
1:apache2-example-pages ########################################### [[ 50%]]
2:apache2-doc ########################################### [[100%]]

I also checked:
/usr/sbin # suexec2 -V

and I still got the old doc_root instead of /home.

-D AP_DOC_ROOT=&quot;/srv/www/htdocs&quot;
-D AP_GID_MIN=96
-D AP_HTTPD_USER=&quot;wwwrun&quot;
-D AP_LOG_EXEC=&quot;/var/log/apache2/suexec.log&quot;
-D AP_SAFE_PATH=&quot;/usr/local/bin:/usr/bin:/bin&quot;
-D AP_UID_MIN=96
-D AP_USERDIR_SUFFIX=&quot;public_html&quot;

What's missing?

Thank you,

Mike

Wed, 12/13/2006 - 19:58 (Reply to #3)
Joe
Joe's picture

Hey Mike,

I dunno. Did you remember to bump the revision in the new package, and get the latest version for your OS? If rpm thinks it's an older version it won't &quot;freshen&quot; it. That's what this looks like (the docs often trail the actual packages, since the version dependencies for them aren't as tightly coupled).

--

Check out the forum guidelines!

Thu, 12/14/2006 - 03:44
MikeF

This is the version of Apache2 currently running on the system (before any update)

Server version: Apache/2.0.50
Server built: Aug 30 2006 13:17:05

This is the one I downloaded:

apache2-2.0.50-7.3.src.rpm

This is what apache2.spec says after I edited it yesterday:

Version: 2.0.50
Release: 7.3.vm

How do I actually check that it is the newer RPM I've got?

/Mike

Thu, 12/14/2006 - 07:53
MikeF

This is what I get from Yast:

apache2 - The Apache web server (version 2.0)
Version: 2.0.50-7.3 Installed: 2.0.50-7.17
License: Apache
Package Group: Productivity/Networking/Web/Servers

Thu, 12/14/2006 - 15:34 (Reply to #6)
Joe
Joe's picture

Hey Mike,

You can find this stuff out a bit more quickly than navigating yast, by using rpm directly:

rpm -q apache2

But, you've got an old version that you started from. You'll want to track down the latest update version (2.0.50-7.17) in SRPM format, modify it as directed above, and then try it again. 7.3&lt;7.17 (seems like strange counting, I know...but 17&gt;3, and the dot is a separator, not a decimal place).

--

Check out the forum guidelines!