Koozali.org: home of the SME Server

PHP issue [SOLVED]

Offline genisys

  • *
  • 46
  • +0/-0
PHP issue [SOLVED]
« on: July 26, 2012, 11:24:37 PM »
Hello all -
I recently upgraded to SME 8. The upgrade went very smoothly and everything has been working fine, except today I found out that when people go to our website to submit a request form to us, it fails with this error:

Forbidden
You don't have permission to access /php5-cgi/php/Request/process.php on this server.


I think possibly that php5-cgi is not installed and I should do:

yum --enablerepo=smecontribs install smeserver-php5-cgi
signal-event post-upgrade ; signal-event reboot

The notes for this HOWTO says it's for testing only and I really don't know if this is the solution or not, so I'm a bit hesitant doing anything without knowing it's safe. I also do not have any PHP experience. Any help would be appreciated.
« Last Edit: July 31, 2012, 04:06:50 PM by genisys »

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: PHP issue
« Reply #1 on: July 26, 2012, 11:42:15 PM »
you don't need php5-cgi on SME8, you already have php5.3, php5-cgi is bugged and dangerous (search the forums)

I suggest you to modify your form/php page: if you are not able, hire someone

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Re: PHP issue
« Reply #2 on: July 27, 2012, 01:53:57 PM »
Find the template fragment that is inserting a php5-cgi handler into /etc/httpd/conf/httpd.conf, and just take out the reference.

With a default php5-cgi install, there's a db variable per-ibay that enables php5-cgi - you could check your ibays (db accounts show |less -S  - then search for 'php5').  If you have an ibay set to use php5-cgi, delete the db value, expand httpd.conf, and restart httpd-e-smith.

If you setup the site using php5-cgi using sme sitemaker, there will be a custom template fragment in /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf that says something like "AddHandler php5-cgi .php" - just delete that line, expand httpd.conf, and restart httpd-e-smith.

It may be possible to use "AddHandler" in .htaccess -- if so (and if you haven't found anything about php5 yet) you'll need to check in the .htaccess file in the folder serving the failing site.

Offline genisys

  • *
  • 46
  • +0/-0
Re: PHP issue
« Reply #3 on: July 27, 2012, 03:53:44 PM »
Thanks for the responses.

1. I ran this to shut off php5 on the Primary ibay:
     db accounts setprop Primary php5 no
     signal-event ibay-modify Primary

2. In /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf, I see two files:
     80php5-cgi
     90Primary

     80php5-cgi has contents:
ScriptAlias /php5-cgi /usr/bin/php5

<Directory /usr/bin/php5>
       order deny,allow
       deny from all
       allow from all
       Options ExecCGI
</Directory>

     90Primary has contents:
ScriptAlias /php5-cgi /usr/bin/php5

<Directory /usr/bin/php5>
       order deny,allow
       deny from all
       allow from all
       Options ExecCGI
</Directory>

If I remove the "AddHandler" line from 90Primary, will this fix the issue even though there are several other references to php5? Are we needing to change all the references of /usr/bin/php5 (which doesn't exist) to /usr/bin/php (which does exist)? 


Correction:

90Primary contents:

<Directory /home/e-smith/files/ibays/Primary/html>
       AddHandler php5-cgi .php
       Action php5-cgi /php5-cgi/php
</Directory>
« Last Edit: July 27, 2012, 05:13:56 PM by genisys »

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: PHP issue
« Reply #4 on: July 27, 2012, 10:55:32 PM »
Remove both custom templates, and reconfigure the system (via console option, or using signal-event if you know how).

Offline madadam

  • *
  • 149
  • +0/-0
    • http://www.extremetourist.com
Re: PHP issue
« Reply #5 on: July 28, 2012, 01:25:23 PM »
Hi genisys,

You absolutely don't want PHP5-cgi running on your system (see threads in the forum). As you are now using SME 8 which includes PHP 5.3 you will want to remove PHP 5-cgi.

If you installed using the following how-to:

http://wiki.contribs.org/PHP5

then you will need to remove it using either:

Code: [Select]
yum erase smeserver-php5-cgi
- or -

Code: [Select]
rpm -e php5-cgi*
... depending on the package you installed in the first place (the above wiki page will help).

Once you've done this remove the custom templates you found and update the SME account database with:

Code: [Select]
db accounts setprop ibayname php5 no
signal-event ibay-modify ibayname

for each iBay on your system.

Lastly issue:

Code: [Select]
signal-event post-upgrade
signal-event reboot

You should now have a system clean of PHP 5-cgi.
...

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Re: PHP issue
« Reply #6 on: July 28, 2012, 03:28:42 PM »
genisys:

If you end up with a concise list of the steps needed to remove php5-cgi after an upgrade from 7.x to 8.x, please add them to one or both of these wiki pages:

Offline genisys

  • *
  • 46
  • +0/-0
Re: PHP issue
« Reply #7 on: July 30, 2012, 03:52:45 PM »
PHP5 is not actually installed on the new server, so I did this:

1. I deleted the two custom templates in /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf:
     80php5-cgi
     90Primary

2. I ran this to shut off php5 on the Primary ibay:
     db accounts setprop Primary php5 no
     signal-event ibay-modify Primary

3. Then ran:
signal-event post-upgrade
signal-event reboot

Now when I go to the form (the only part of the website which seems to call PHP and isn't working), I submit the form and get a blank page. Is there a config file that I have to change so this page uses php5.3?

Offline madadam

  • *
  • 149
  • +0/-0
    • http://www.extremetourist.com
Re: PHP issue
« Reply #8 on: July 30, 2012, 04:05:13 PM »
Do this:

Code: [Select]
expand-template /etc/httpd/conf/httpd.conf
service httpd-admin restart
service httpd-e-smith restart

And then try again. If you're still getting a blank page go have a look in the messages log in the server manager.
...

Offline genisys

  • *
  • 46
  • +0/-0
Re: PHP issue
« Reply #9 on: July 30, 2012, 04:30:47 PM »
After expanding httpd.conf, I was still getting a blank page and the message log showed:

Jul 30 08:54:54 email httpd: PHP Warning:  fopen(admin/data.dat) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied in /home/e-smith/files/ibays/Primary/html/Request/process.php on line 63

Jul 30 08:54:54 email httpd: PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /home/e-smith/files/ibays/Primary/html/Request/process.php on line 95

Jul 30 08:54:54 email httpd: PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/e-smith/files/ibays/Primary/html/Request/process.php on line 98

I went to line 63 of process.php and tracked down the file that this was writing too. Somehow the permissions were changed, I don't know how that could have happened. It sounds like removing the old templates, turning off php5 on the ibay and expanding httpd.conf were all necessary steps, however I also had this permission issue that needed to be dealt with.

I appreciate all of your help, our form is now working again!   :-)