Koozali.org: home of the SME Server

php5 for user web space

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
php5 for user web space
« on: March 29, 2009, 08:10:15 PM »
can someone help to merge
this two pieces of code...

the template
94UserWebPhp

Code: [Select]
{
    use esmith::AccountsDB;

    $OUT = "";
    my $accounts = esmith::AccountsDB->open;
    my @users = $accounts->users;

    foreach my $user (@users)
    {
        $OUT .= "\n<Directory /home/e-smith/files/users/".$user->key;
        $OUT .= "/home/public_html>\n";

        $OUT .= " AddType application/x-httpd-php";
        $OUT .= " .php .php3 .phtml\n";
        $OUT .= " AddType application/x-httpd-php-source .phps\n";

        # Set the sandbox within which PHP is confined to play
        my $tmppath = "/home/e-smith/files/users/";
        $tmppath .= $user->key . "/";
        my $basedir = $user->prop('PHPBaseDir') || ($tmppath);
        $OUT .= " php_admin_value open_basedir $basedir\n";
        $OUT .= "</Directory>\n";
    }
}

from the rpm http://www.pialasse.com/RPMS/smeserver-user-webspace-0.1-5.SME7.noarch.rpm
and the code from the howto http://wiki.contribs.org/PHP5
that enable php5 using cgi.
Code: [Select]
<Directory /opt/[myapp]>
       AddHandler php5-cgi .php
       Action php5-cgi /php5-cgi/php-cgi
</Directory>

Offline lancelott2

  • *
  • 73
  • +0/-0
  • Ich bin Lancelott2
    • Meine private Homepage
Re: php5 for user web space
« Reply #1 on: March 30, 2009, 06:21:14 AM »
Hello,

what are u planing to do?

Greetings

Lance
---------------------------------------------------------------------
Auch ich lerne noch ständig dazu!
---------------------------------------------------------------------

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #2 on: March 31, 2009, 11:57:08 AM »
enable php5 for user space that already work with php.
some new plugin for wordpress works only with php5.

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: php5 for user web space
« Reply #3 on: March 31, 2009, 12:14:59 PM »
Try installing the Wordpress contrib, and then following the instructions to enable PHP5 for /opt/wordpress.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: php5 for user web space
« Reply #4 on: March 31, 2009, 12:16:36 PM »
David

as far as I can understand, OP has enabled the user web space contrib.. so he wish to activate php5 per user basis..

my 2c
Ciao
Stefano

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #5 on: March 31, 2009, 12:18:52 PM »
exactly

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #6 on: March 31, 2009, 12:23:53 PM »
to explayn more
the php5 contrib that whe can read on the wiki can enable php5
using a cgi in ibays and /opt/yourweb
i think that exist a way to merge the code of this contrib with the template
that posted. this template enable the user to host web pages in the home/public_html..

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: php5 for user web space
« Reply #7 on: March 31, 2009, 12:24:36 PM »
My mistake.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: php5 for user web space
« Reply #8 on: March 31, 2009, 12:46:47 PM »
ok.. let's try

NOTE this is a workaround, not tested..

1) copy 94UserWebPhp fragment to the same folder in /etc/e-smith/templates-custom tree (you have to create the sub tree manually) and cd to the same dir
2) let's say that you want to give php5 to user john
edit the fragment in this way:

Code: [Select]
{
    use esmith::AccountsDB;

    $OUT = "";
    my $accounts = esmith::AccountsDB->open;
    my @users = $accounts->users;

    foreach my $user (@users)
    {
        $OUT .= " <Directory /home/e-smith/files/users/".$user->key;
        $OUT .= "/home/public_html> ";

        $OUT .= " AddType application/x-httpd-php";
        $OUT .= " .php .php3 .phtml ";
        $OUT .= " AddType application/x-httpd-php-source .phps ";

        if ($user == 'john') {
                 $OUT .= "AddHandler php5-cgi .php ";
                 $OUT .= "Action php5-cgi /php5-cgi/php-cgi ";
        }

        # Set the sandbox within which PHP is confined to play
        my $tmppath = "/home/e-smith/files/users/";
        $tmppath .= $user->key . "/";
        my $basedir = $user->prop('PHPBaseDir') || ($tmppath);
        $OUT .= " php_admin_value open_basedir $basedir ";
        $OUT .= "</Directory> ";
    }
}

3) save the fragment with Ctrl-X, Y (if you are working with pico)
4) signal-event user-modify john

should do the trick

please raise a NFR to ask that this feature is added to the contrib (maybe David, the mantainer, is interested :wink: )

let us know

Ciao
Stefano
« Last Edit: March 31, 2009, 12:48:48 PM by Stefano a.k.a. nenonano »

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: php5 for user web space
« Reply #9 on: March 31, 2009, 01:30:38 PM »
Happy to write the code, but it will need to go in the userspace contrib, which would then depend on PHP5.

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #10 on: March 31, 2009, 10:35:59 PM »
david any suggest??

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: php5 for user web space
« Reply #11 on: March 31, 2009, 10:41:42 PM »
david any suggest??

did you try the solution I gave  you?

Stefano

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #12 on: March 31, 2009, 10:49:45 PM »
if i understud you changed the code only to modify one account.
so is not what i need..

###se sei italiano possiamo parlare su msn###

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: php5 for user web space
« Reply #13 on: March 31, 2009, 11:02:04 PM »
if i understud you changed the code only to modify one account.
so is not what i need..

mine was an example.. did you try it? if it works for a single account, we can modify for many..

Quote
###se sei italiano possiamo parlare su msn###

si, sono italiano ma msn ora non posso...

Stefano

p.s. passa anche sul forum in italiano, grazie

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #14 on: March 31, 2009, 11:05:29 PM »
i will try this code tomorrow morning.
i tried in a similar way yesterday but i get apache error..

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: php5 for user web space
« Reply #15 on: March 31, 2009, 11:11:35 PM »
ok

let us know if it works.. if not, post the error message you'll find in /var/log/httpd/error_log file, thank you

Ciao
Stefano

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #16 on: April 16, 2009, 01:09:28 PM »
get back to this trouble...
i tried the code suggested from stefano.
i applied the settings restarted http service
and tested if php5 is avayable on the user pages..
no error but php is version ..

i'm not sure but sims that the modified version das't apply the new text to http.conf
i modified by hand the configuration and this work
but i can immagin that every time i do one upgrade the bad configuration come back.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: php5 for user web space
« Reply #17 on: April 16, 2009, 08:36:44 PM »
no error but php is version ..

version? :-)

Quote
i modified by hand the configuration and this work

well.. then, please, post here:

- the fragment of your working httpd.conf
- the same fragment from the not-working httpd.conf (i.e. the one generated from template)

so we can see the difference and modify the code..

Quote
but i can immagin that every time i do one upgrade the bad configuration come back.

of course.. it's the way SME works

Ciao
Stefano

p.s. I didn't see you on italian forum..

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #18 on: April 16, 2009, 11:47:29 PM »
OOOPpsss.
i wrongly applied the settings with your changes.
i did this now and after
Code: [Select]
signal-event post-upgrade
signal-event reboot
i get erroron reboot from apache:
i tried to find the error in the log like you said but nothing here...
tomorrow i try the same and i i copy the error that in can see on the screen
during the boot and the wrong lines on httpd.conf ..

now the reponse to your latest post.

user web space code from the rpm


Code: [Select]
---8<-------
#-------------------------------------------------------
# Alias to enable /user aswell as /~user access
#-------------------------------------------------------
Alias /redteo /home/e-smith/files/users/redteo/home/public_html
Alias /user1 /home/e-smith/files/users/user1/home/public_html
Alias /user2 /home/e-smith/files/users/user2/home/public_html
Alias /user3 /home/e-smith/files/users/user3/home/public_html
Alias /user4 /home/e-smith/files/users/user4/home/public_html

#-------------------------------------------------------
#Generic user dir access directive
#-------------------------------------------------------
<Directory /home/e-smith/files/users/*/home/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    </Limit>
    <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
        Order deny,allow
        Deny from all
    </Limit>
</Directory>

----8<------
cutted part
----8<------

<Directory /home/e-smith/files/users/redteo/home/public_html>
 AddType application/x-httpd-php .php .php3 .phtml
 AddType application/x-httpd-php-source .phps
 php_admin_value open_basedir /home/e-smith/files/users/redteo/
</Directory>

<Directory /home/e-smith/files/users/userXX/home/public_html>
 AddType application/x-httpd-php .php .php3 .phtml
 AddType application/x-httpd-php-source .phps
 php_admin_value open_basedir /home/e-smith/files/users/userXX/
</Directory>

----8<-----
cutted part
----8<-----

i changed the part
Code: [Select]
AddType application/x-httpd-php .php .php3 .phtml
 AddType application/x-httpd-php-source .phps
with thist code:
Code: [Select]
AddHandler php5-cgi .php
 Action php5-cgi /php5-cgi/php-cgi

i have also to check if the part relative to the basedir is working...
sorry i not have so much time..

stefano i have to put the focus also on the thing that i have more users not one :-/
i think , i try to  suggest that the best way is to change the code of the user space template to enable the code for all the users..

p.s: i will write on italian forum for my next topic .

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #19 on: April 18, 2009, 12:14:42 AM »
now the errors on the boot screen:

Code: [Select]
Syntax error on line 1876 of /etc/httpd/conf/httpd.conf:
/etc/httpd/conf/httpd.conf:1876: <Directory> was not closed

here the template :

Code: [Select]
{
    use esmith::AccountsDB;

    $OUT = "";
    my $accounts = esmith::AccountsDB->open;
    my @users = $accounts->users;

    foreach my $user (@users)
    {
        $OUT .= " <Directory /home/e-smith/files/users/".$user->key;
        $OUT .= "/home/public_html> ";

        $OUT .= " AddType application/x-httpd-php";
        $OUT .= " .php .php3 .phtml ";
        $OUT .= " AddType application/x-httpd-php-source .phps ";

        if ($user == 'redteo') {
                 $OUT .= "AddHandler php5-cgi .php ";
                 $OUT .= "Action php5-cgi /php5-cgi/php-cgi ";
        }

        # Set the sandbox within which PHP is confined to play
        my $tmppath = "/home/e-smith/files/users/";
        $tmppath .= $user->key . "/";
        my $basedir = $user->prop('PHPBaseDir') || ($tmppath);
        $OUT .= " php_admin_value open_basedir $basedir ";
        $OUT .= "</Directory> ";
    }
}

the wrong line is the following:

Code: [Select]
<Directory /home/e-smith/files/users/bagstime.av/home/public_html>  AddType application/x-httpd-php .php .php3 .phtml  AddType application/x-httpd-php-source .phps  php_admin_value open_basedir /home/e-smith/files/users/bagstime.av/ </Directory>  <Directory /home/e-smith/files/users/fernanda/home/public_html>  AddType application/x-httpd-php .php .php3 .phtml  AddType application/x-httpd-php-source .phps  php_admin_value open_basedir /home/e-smith/files/users/fernanda/ </Directory>  <Directory /home/e-smith/files/users/paolo/home/public_html>  AddType application/x-httpd-php .php .php3 .phtml  AddType application/x-httpd-php-source .phps  php_admin_value open_basedir /home/e-smith/files/users/paolo/ </Directory>  <Directory /home/e-smith/files/users/redteo/home/public_html>  AddType application/x-httpd-php .php .php3 .phtml  AddType application/x-httpd-php-source .phps  php_admin_value open_basedir /home/e-smith/files/users/redteo/ </Directory>  <Directory /home/e-smith/files/users/trancoso/home/public_html>  AddType application/x-httpd-php .php .php3 .phtml  AddType application/x-httpd-php-source .phps  php_admin_value open_basedir /home/e-smith/files/users/trancoso/home/public_html:/tmp </Directory>
 

this is one line!! i i not covered the users ;-)

my new step is to change the userweb template like this:

Code: [Select]
{
    use esmith::AccountsDB;

    $OUT = "";
    my $accounts = esmith::AccountsDB->open;
    my @users = $accounts->users;

    foreach my $user (@users)
    {
        $OUT .= "\n<Directory /home/e-smith/files/users/".$user->key;
        $OUT .= "/home/public_html>\n";

        $OUT .= " AddHandler php5-cgi .php\n";
        $OUT .= " Action php5-cgi /php5-cgi/php-cgi\n";

        # Set the sandbox within which PHP is confined to play
        my $tmppath = "/home/e-smith/files/users/";
        $tmppath .= $user->key . "/";
        my $basedir = $user->prop('PHPBaseDir') || ($tmppath);
        $OUT .= " php_admin_value open_basedir $basedir\n";
        $OUT .= "</Directory>\n";
    }

after the post-upgrade
all work good, all the users have they web pages with php5, but i'm not prepared to see if the base dir is well configured..

i think the natral way of evolution is to change the php5 contrib to chek if
user space is enabled and automatically overwrite the template ..

please how i can chek if all work good??

:-)



Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: php5 for user web space
« Reply #20 on: April 18, 2009, 09:51:51 AM »
now the errors on the boot screen:

Code: [Select]
Syntax error on line 1876 of /etc/httpd/conf/httpd.conf:
/etc/httpd/conf/httpd.conf:1876: <Directory> was not closed


the wrong line is the following:

]zac[

this is one line!! i i not covered the users ;-)

did you modify the template fragment with a windows editor?

Quote
my new step is to change the userweb template like this:

Code: [Select]
{
    use esmith::AccountsDB;

    $OUT = "";
    my $accounts = esmith::AccountsDB->open;
    my @users = $accounts->users;

    foreach my $user (@users)
    {
        $OUT .= "\n<Directory /home/e-smith/files/users/".$user->key;
        $OUT .= "/home/public_html>\n";

        $OUT .= " AddHandler php5-cgi .php\n";
        $OUT .= " Action php5-cgi /php5-cgi/php-cgi\n";

        # Set the sandbox within which PHP is confined to play
        my $tmppath = "/home/e-smith/files/users/";
        $tmppath .= $user->key . "/";
        my $basedir = $user->prop('PHPBaseDir') || ($tmppath);
        $OUT .= " php_admin_value open_basedir $basedir\n";
        $OUT .= "</Directory>\n";
    }

the \n character should not be necessary if you edit the fragment directly on SME

Quote
after the post-upgrade
all work good, all the users have they web pages with php5, but i'm not prepared to see if the base dir is well configured..

well.. you need simply to test it :-)

Quote
i think the natral way of evolution is to change the php5 contrib to chek if
user space is enabled and automatically overwrite the template ..

I disagree.. I think that the user web space contrib has to be modified to check if php5-cli is installed
anyway, I would open a nfr in the bugtracker for it

Quote
please how i can chek if all work good??
:-)

well... I think you can simply wait for your users to tell you if something goes wrong..

Ciao
Stefano

Offline redteo

  • *
  • 122
  • +0/-0
    • redteo blog
Re: php5 for user web space
« Reply #21 on: April 18, 2009, 04:45:12 PM »
i use nano to edit files in ssh shell connection.
you can se the template used, that during the postupgrade
done a worng conf file.. maybe a conflict with others template or the code your suggested is wrong. np
look back to my post..
i see that the original template use \n and i did the same following :-/
i don't know the porpuse of openbase dir if it is used to chroot on user dir the use of command (imagemagik etc) it works, and is not a proble, i copied the binari usefull for the user in the user dir changing the skeleton.. (is not nice but work ;-)

i don't know how to raise bugs.. and is the same change php5 or userspace contrib.. the thing is let the people know that we have this opportunity. if you want i can bee you cavia to generate a new rpm for the user space..

OT. and now so sorry for my inprouving english here i'm a self learner :-D