6

Hi I've installed suexec using on ubuntu 12.04:

apt-get install apache2 apache2-suexec libapache2-mod-fcgid php5-cgi

However when I run the following command:

sudo /usr/lib/apache2/suexec -V

I get the following info:

 -D AP_DOC_ROOT="/var/www"
 -D AP_GID_MIN=100
 -D AP_HTTPD_USER="www-data"
 -D AP_LOG_EXEC="/var/log/apache2/suexec.log"
 -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
 -D AP_UID_MIN=100
 -D AP_USERDIR_SUFFIX="public_html"

I'm utilizing "/home/user/public_html" to serve users content on the web not "/var/www" How can I change the root directory to "/home"?

Oudin
  • 331
  • 2
  • 5
  • 10

4 Answers4

16

Or you can

apt-get install apache2-suexec-custom

after install go to

cd /etc/apache2/suexec

edit the file vi www-data

You can see the first 2 lines, make the changes: replace /var/www with /home

esc 
:wq

after, restart apache

/etc/init.d/apache2 restart
Scott Pack
  • 14,717
  • 10
  • 51
  • 83
Carl Parsons
  • 161
  • 1
  • 2
  • 2
    Make sure to also **remove** apache2-suexec and apache2-suexec-pristine or this won't work. – Mike Jun 22 '14 at 00:00
5

You're using ubuntu. Therefore recompile is pretty simple.

Add source repository to your /etc/apt/sources.list . For 12.04 run

echo "deb-src http://de.archive.ubuntu.com/ubuntu/ precise main"|sudo tee -a /etc/apt/sources.list

change de.archive.ubuntu.com to whatever country you're in. After that update your repository.

apt-get update

Change dir and download sources:

mkdir ~/apache_new  ; cd ~/apache_new
apt-get source apache2
apt-get build-dep apache2

It will download and extract apache source and install all dependencies therefore you'll be able to build apache. But you'll need to fix AP_DOC_ROOT. So cd to dir with apache source and change dir path in --with-suexec-docroot option in debian/rules file. So now you'll need to build package. You can make it with

debuild -us -uc

That's it. Now yyou have apache deb-package with fixed path. Just install it with sudo dpkg -i. But watch on updates. Update will wipe out all your efforts. So run aptitude hold apache2 to forbid updates and don't forget to recompile it each time manually (or write script fpr that).

Good luck.

rush
  • 1,961
  • 2
  • 15
  • 22
1

I'm utilizing "/home/user/public_html" to serve users content on the web not "/var/www" How can I change the root directory to "/home"?

actually you can use mod_userdir

in this case suexec will spawn scripts from owner of /home/user - in this example "user"

so you don't need to define SuexecUserGroup in apache config

UPD: just enable userdir module

and add to main vhost config

UserDir /home/*/public_html

and

<Directory /home/*/public_html/ >
      AllowOverride All
      Options +ExecCGI
      AddHandler cgi-script .cgi .pl  .py .rb
</Directory>
A M
  • 158
  • 8
0

You need to recompile it from suexec.c, ideally you could install virtualmin, so it will do it automatically via install.sh and also it will create accounts, domains etc.

Andrew Smith
  • 1,123
  • 13
  • 23