Skip to main content

recompile apache from src.rpm to change suexec docroot to /home

Posted in

You may need to do this as a solution to a virtualmin error on standard redhat systems install:
"The Suexec command on your system is configured to only run scripts under /var/www, but the Virtualmin base directory is /home. CGI and PHP scripts run as domain owners will not be executed."

This example will be based on Centos 5.2 64bit and http 2.2.3 ... in most redhat based systems you should be able to do pretty much the same steps to get this going.

First, you need the src.rpm ... get it from a repo. in my case i got it like this:

wget http://mirror.centos.org/centos/5.3/os/SRPMS/httpd-2.2.3-22.el5.centos.s...

then you have to unpack the src.rpm

rpm -Uvh httpd-2.2.3-22.el5.centos.src.rpm

in my case it complained about a missing path so i had to do:

mkdir /usr/src/redhat

and ran again:

rpm -Uvh httpd-2.2.3-22.el5.centos.src.rpm

this time it worked.

After this operation, you will find the source code stuff in ll /usr/src/redhat/SOURCES/ . you're not really interested on that. what you need is to modify the spec file which is located in /usr/src/redhat/SPECS/

so:

vi /usr/src/redhat/SPECS/httpd.spec

and then change the line
%define contentdir /var/www
to
%define contentdir /home

after that you just need to rebuild the package with:

rpmbuild -bb /usr/src/redhat/SPECS/httpd.spec

in my case it complained of some missing packages. I didn't have rpmbuild so first I did:

yum install rpm-build

and then some httpd recompile related packages were missing:

yum install zlib-devel libselinux-devel pcre-devel openssl-devel distcache-devel autoconf xmlto

you might need different packages so pay attention to what it will require and install accordingly

and then rebuild again:

rpmbuild -bb /usr/src/redhat/SPECS/httpd.spec

and install the generated RPMS:

rpm -Uvh /usr/src/redhat/RPMS/x86_64/httpd-2.2.3-22.x86_64.rpm /usr/src/redhat/RPMS/x86_64/httpd-devel-2.2.3-22.x86_64.rpm /usr/src/redhat/RPMS/x86_64/httpd-manual-2.2.3-22.x86_64.rpm /usr/src/redhat/RPMS/x86_64/mod_ssl-2.2.3-22.x86_64.rpm

when i tried to start apache it played it's last card against me and complained about a missing folder that was set as DocumentRoot.
so you can either change that in /etc/httpd/conf/httpd.conf if you know what you're doing, or you can simply make sure that /var/www/html exists

i had to create that one:

mkdir /var/home/html

and I won :)

This helped a lot, thank

This helped a lot, thank you!

hey it work, just a few fixed

hey it work, just a few fixed for me;

vi ll /usr/src/redhat/SPECS/httpd.spec should be vi /usr/src/redhat/SPECS/httpd.spec

and mkdir /var/home/html should be mkdir /var/www/html

The error about missing

The error about missing "/usr/src/redhat" path is because you have not installed rpm-build package!!! Creating the path for your self was not reasonable thing to do.

Please change your post to include that instead of mkdir command proper command is :
yum install rpm-build

Kind regards,
Ljubomir Ljubojevic
PL Computers

Hi add this to /etc/fstab and

Hi add this to /etc/fstab and you get around of lots of problems..
Don't foreget to copy the contens of /var/www before you mount the harddrive.

/home/www /var/www none bind,usrquota,acl 0 0

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
11 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

If you need more help on the topic feel free to add a comment or create a new post on the Forum