Difference between revisions of "PHP"
(typo) |
|||
Line 57: | Line 57: | ||
====Modifying the PHPBaseDir setting for an ibay==== | ====Modifying the PHPBaseDir setting for an ibay==== | ||
<ol> | <ol> | ||
+ | (Please also see: [http://wiki.contribs.org/Useful_Commands#PHP_Related_Commands these] instructions on the [http://wiki.contribs.org/Useful_Commands UsefullCommands] page.) | ||
<!--Please do not remove the following closing tag as a fromatting/rendering bug will kick in, for more details see: http://bugzilla.wikimedia.org/show_bug.cgi?id=10893--></li><li>Open a SME Server shell as root user and document the current setting of the PHPBaseDir directive by writing down the output of the following command: | <!--Please do not remove the following closing tag as a fromatting/rendering bug will kick in, for more details see: http://bugzilla.wikimedia.org/show_bug.cgi?id=10893--></li><li>Open a SME Server shell as root user and document the current setting of the PHPBaseDir directive by writing down the output of the following command: | ||
db accounts getprop ibayname PHPBaseDir | db accounts getprop ibayname PHPBaseDir |
Revision as of 07:54, 8 May 2008
Display Error Messages
By default PHP does not display error messages on screen. Some times you get a blank page when executing PHP scripts. Usually some sort of error has occurred, but this error text will not be displayed as SME Server is configured to not display them. Instead the error messages are reported to the log files of the webserver and the general logfile of the server.
Try to analyze your logfiles: /var/log/httpd/error_log and /var/log/httpd/access_log and perhaps also /var/log/messages.
Enable changes
If you (for debugging purposes for instance) would like to enable it you can do it with the instructions found below:
mkdir -p /etc/e-smith/templates-custom/etc/php.ini cp /etc/e-smith/templates/etc/php.ini/30ErrorHandling /etc/e-smith/templates-custom/etc/php.ini
After that:
cd /etc/e-smith/templates-custom/etc/php.ini pico 30ErrorHandling
Modify the second line to read:
display_errors = On
After that issue the following commands:
expand-template /etc/php.ini
Depending on your server version use the proper command to restart your webbrowser.
SME Server 7 and newer:
sv t httpd-e-smith
older releases:
/etc/rc7.d/S86httpd-e-smith restart
Now access your page again and see what the error is.
Undo Changes
If everything works you remove the 30ErrorHandling file from the /etc/e-smith/templates-custom/etc/php.ini folder and issue the last two lines again:
expand-template /etc/php.ini /etc/rc7.d/S86httpd-e-smith restart
Open basedir restriction
SME Server has a security measure in place which is called 'open basedir restriction'. This measure prevents PHP from executing or invoking other PHP scripts outside the scope of it's own tree in other words it creates a 'sandbox' or 'jail'. Overall configuration is defined in the php.ini file but you can add an override on a per ibay basis.
Error message
The PHP open basedir restriction usually present to the user like this in the /var/log/messages file:
Aug 12 17:27:42 homer httpd: PHP Warning: main(): open_basedir restriction in effect. File(/tmp/test.php) is not within the allowed path(s): (/home/e-smith/files/ibays/Primary/html/) in /home/e-smith/files/ibays/Primary/html/test.php on line 2
In general you will find this message in the log files only as by default PHP is configured to prevent the display of error messages to the end users. This can be changed as per this HowTo.
Modifying the PHPBaseDir setting for an ibay
-
(Please also see: these instructions on the UsefullCommands page.)
- Open a SME Server shell as root user and document the current setting of the PHPBaseDir directive by writing down the output of the following command: db accounts getprop ibayname PHPBaseDir Be careful to write it down to the letter as we need it in the next step For the Primary ibay the ouptut of above command would normally look like this: /home/e-smith/files/ibays/Primary/html/
- Decide on what directory you would like to add and issue the following: db accounts setprop ibayname PHPBaseDir value Replace ibayname with the name of the ibay and value with the old value for the PHPBaseDir directive you have written down and a colon (:) followed by the full path to the directory you would like to add with a tailing slash (/), e.g. db accounts setprop Primary PHPBaseDir /home/e-smith/files/ibays/Primary/html/:/opt/gallery2/ Above command would allow for invocation of scripts in the /opt/gallery2 path from the Primary ibay html folder by PHP.
- After defining the new setting we need to reflect the change in the configuration file of the web server and have the web server reload it's configuration file. This is done by issuing the following command: signal-event ibay-modify ibayname Be sure to replace ibayname with the name of the ibay you have just modified.
PHP 5
SME 7.x uses PHP 4, upgrading to PHP 5 is not recommended and not supported. However, you can add PHP5 as a cgi-bin handler for any given directory on the webserver. See this HOWTO for instructions: http://sme.firewall-services.com/spip.php?article46
If you really want to upgrade the entire system to PHP 5 (for instance, if you need the mysqli extension), here's how to do it:
yum --enablerepo=centosplus install php.i386 php-pear-Net-Socket php-pear-Auth-SASL php-pear-DB php-pear-HTTP php-pear-Mail php-pear-XML-Parser /sbin/e-smith-signal-event post-upgrade /sbin/e-smith-signal-event reboot
Horde webmail is confirmed to work under PHP 5, provided you've upgraded to the latest SME version. Please note again that PHP 5 is not officially supported by SME 7.x, and therefore you may run into trouble when upgrading SME (see e.g. http://forums.contribs.org/index.php?topic=38194.0 and http://forums.contribs.org/index.php?topic=39611.0).
See also: