Koozali.org: home of the SME Server

Enabling PEAR in an ibay

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Enabling PEAR in an ibay
« on: July 29, 2005, 11:29:11 PM »
I managed to get PEAR up and running in an ibay (already prepared for PHP support in the server-admin module on a SME 6.01 box) and just want to let you know how I did it, maybe some one else can profit from it. Comments are welcome!

Jonathan

Adding PEAR support to an ibay

Note: replace the text and the point brackets with the correct values


- copy template 95AddType00PHP2ibays from /etc/e-smith/templates/etc/httpd/conf/httpd.conf/95AddType00PHP2ibays to /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf

- enter the following lines under the basedir insertions statements:

Code: [Select]
my $safe_mode_iclude_dir = db_get_prop(\%accounts, $key, 'PHPSafeModeIncludeDir');
if (safe_mode_iclude_dir)
{
$OUT .=
"    phph_admin_value safe_mode_include_dir $safe_mode_include_dir\n";
}


- save the script

- issue the following command to see the current setting of the PHPBaseDir and write it down (you will need it in the next step)

Code: [Select]
/sbin/e-smith/db accounts getprop <ibayname> PHPBaseDir

- issue the following commands on the command line to add the PEAR directory to the basedir statement

Code: [Select]
/sbin/e-smith/db accounts setprop <ibayname> PHPBaseDir <old PHPBaseDir>:</path/to/pear>
/sbin/e-smith/db accounts setprop <ibayname> PHPSafeModeIncludeDir </path/to/pear>
/sbin/e-smith/signal-event ibay-modify <ibayname>


- expand the httpd.conf template to include the newly added values

Code: [Select]
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

- restart the httpd deamon

Code: [Select]
/etc/e-smith/events/actions/restart-httpd-graceful

Removing PEAR support from an ibay

- issue the following command to see the current setting of the PHPBaseDir and write it down (you will need it in the next step)

Code: [Select]
/sbin/e-smith/db accounts getprop <ibayname> PHPBaseDir

- issue the following commands on the command line to add the PEAR directory to the basedir statement

Code: [Select]
/sbin/e-smith/db accounts delprop <ibayname> PHPSafeModeIncludeDir
/sbin/e-smith/db accounts delprop <ibayname> PHPBaseDir
/sbin/e-smith/db accounts setprop <ibayname> PHPBaseDir <old PHPBaseDir without the /path/to/pear>
/sbin/e-smith/signal-event ibay-modify <ibayname>


- expand the httpd.conf template to update the changes

Code: [Select]
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

- restart the httpd deamon

Code: [Select]
/etc/e-smith/events/actions/restart-httpd-graceful
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

batosai

Re: Enabling PEAR in an ibay
« Reply #1 on: February 25, 2006, 11:05:18 PM »
Quote from: "cactus"

- copy template 95AddType00PHP2ibays from /etc/e-smith/templates/etc/httpd/conf/httpd.conf/95AddType00PHP2ibays to /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf

- enter the following lines under the basedir insertions statements:

Code: [Select]
my $safe_mode_iclude_dir = db_get_prop(\%accounts, $key, 'PHPSafeModeIncludeDir');
if (safe_mode_iclude_dir)
{
$OUT .=
"    phph_admin_value safe_mode_include_dir $safe_mode_include_dir\n";
}


- save the script


A few errors in that part :
- a missing 'n' in iNclude
- a missing '$' at the beginning of the variable name
- an 'h' that has nothing to do here

That gives us :
Code: [Select]

 my $safe_mode_include_dir = db_get_prop(\%accounts, $key, 'PHPSafeModeIncludeDir');
                if ($safe_mode_include_dir)
                {
                    $OUT .= "    php_admin_value safe_mode_include_dir $safe_mode_include_dir\n";
                }


Anyway, thanks alot for that howto, it's been very usefull for me.

Offline jfarschman

  • *
  • 406
  • +0/-0
Enabling PEAR in an ibay
« Reply #2 on: April 24, 2006, 09:38:38 PM »
Hi,

  I'm working with SME7RC1 and I'm butchering the httpd.conf template. Not sure how, but I get an error message when expanding the template.  If anybody has any ideas, I'd appreciate it.

[root@monkey ~]# expand-template /etc/httpd/conf/httpd.conf
ERROR in /etc/e-smith/templates-custom//etc/httpd/conf/httpd.conf/95AddType00PHP2ibays: Program fragment delivered error <<Bad name after PHPSafeModeIncludeDir' at /etc/e-smith/templates-custom//etc/httpd/conf/httpd.conf/95AddType00PHP2ibays line 20.>> at template line 1
ERROR: Template processing failed for //etc/httpd/conf/httpd.conf: 1 fragment generated errors
 at /sbin/e-smith/expand-template line 45

Line #20 looks like this:

my $safe_mode_include_dir = db_get_prop(\%accounts, $key, PHPSafeModeIncludeDir');

The 95AddType00PHP2ibays file looks like this.

Code: [Select]

{
    my $status = $php{status} || 'disabled';
    if ($status eq 'enabled')
    {
        use esmith::AccountsDB;
        my $adb = esmith::AccountsDB->open_ro();
        foreach my $ibay ($adb->ibays)
        {
            local $dynamicContent = $ibay->prop('CgiBin') || 'disabled';
            if ($dynamicContent eq 'enabled')
            {
                $OUT .= "\n<Directory /home/e-smith/files/ibays/" . $ibay->key . "/html>\n";
                $OUT .= "    AddType application/x-httpd-php .php .php3 .phtml\n";
                $OUT .= "    AddType application/x-httpd-php-source .phps\n";

                # Set the sandbox within which PHP is confined to play
                my $basedir = $ibay->prop('PHPBaseDir')
                    || ("/home/e-smith/files/ibays/" . $ibay->key . "/");

                my $safe_mode_include_dir = db_get_prop(\%accounts, $key, PHPSafeModeIncludeDir');
                if ($safe_mode_include_dir)
                {
                    $OUT .= "    php_admin_value safe_mode_include_dir $safe_mode_include_dir\n";
                }

                $OUT .= "    php_admin_value open_basedir $basedir\n";
                $OUT .= "</Directory>\n";
            }
        }
    }
}
Jay Farschman
ICQ - 60448985
jay@hitechsavvy.com

batosai

Enabling PEAR in an ibay
« Reply #3 on: April 29, 2006, 11:10:22 AM »
It's because of a missing quote in my post ('PHPSafeModeIncludeDir'), sorry.

I just edited my post to correct that.

Offline jfarschman

  • *
  • 406
  • +0/-0
Enabling PEAR in an ibay
« Reply #4 on: April 30, 2006, 11:21:20 PM »
Oh...

  That was pretty obvious.  I should have caught that.  Thanks.
Jay Farschman
ICQ - 60448985
jay@hitechsavvy.com

912-targa

PEAR in an ibay on SME 6.0.1
« Reply #5 on: June 01, 2006, 04:26:20 PM »
Hallo,

on my SME 6.0.1 I need to enable PEAR in an ibay for egroupware.

I follwoed the script until:

/sbin/e-smith/db accounts getprop <ibayname> PHPBaseDir

Here I used /sbin/e-smith/db accounts getprop egroupware PHPBaseDir but I get no replay.

What's going wrong?

Offline jfarschman

  • *
  • 406
  • +0/-0
Enabling PEAR in an ibay
« Reply #6 on: June 01, 2006, 04:56:51 PM »
912,

  Okay... you made a  custom template 95AddType00PHP2ibays and then did a command something like this:

Code: [Select]

db accounts setprop egroupware PHPBaseDir /home/e-smith/files/ibays/egroupware:/usr/share/pear
db accounts setprop egroupware PHPSafeModeIncludeDir /usr/share/pear


Right?  And you also expanded the templates?

# Expand the templates
signal-event ibay-modify egroupware
expand-template /etc/httpd/conf/httpd.conf
expand-template /etc/php.ini
service httpd-e-smith restart

Right?  What do you get when you look at phpinfo?
Jay Farschman
ICQ - 60448985
jay@hitechsavvy.com

Offline Jáder

  • *
  • 1,099
  • +0/-0
    • LinuxFacil
Enabling PEAR in an ibay
« Reply #7 on: June 01, 2006, 05:01:32 PM »
Try

/sbin/e-smith/db accounts show egroupware

This will show all egroupware settings.

good luck

Jáder
...