Changes

Jump to navigation Jump to search
4,723 bytes added ,  02:49, 15 November 2023
Line 1: Line 1:  +
{{Languages|PHP}}
 
Starting with SME 10, the '''php''' module is no longer used for httpd. Instead we rely on '''php-fpm''' which can enable every available version of php.  
 
Starting with SME 10, the '''php''' module is no longer used for httpd. Instead we rely on '''php-fpm''' which can enable every available version of php.  
   Line 24: Line 25:  
|php55
 
|php55
 
|customization of /opt/remi/php55/root/etc/php.ini
 
|customization of /opt/remi/php55/root/etc/php.ini
| rowspan="8" |if no properties defined, will use php keys properties
+
| rowspan="11" |if no properties defined, will use php keys properties
 
|-
 
|-
 
|php56
 
|php56
Line 46: Line 47:  
|php80
 
|php80
 
|customization of /etc/opt/remi/php80/php.ini
 
|customization of /etc/opt/remi/php80/php.ini
 +
|-
 +
|php81
 +
|customization of /etc/opt/remi/php81/php.ini
 +
|-
 +
|php82
 +
|customization of /etc/opt/remi/php82/php.ini
 +
|-
 +
|php83
 +
|customization of /etc/opt/remi/php83/php.ini
 
|}
 
|}
 
Every version of php has its own php-fpm service running, the related configuration db entry is (as shown in the Table above) php-fpm for php (ie php54), php55-php-fpm for php55 and so on.
 
Every version of php has its own php-fpm service running, the related configuration db entry is (as shown in the Table above) php-fpm for php (ie php54), php55-php-fpm for php55 and so on.
Line 75: Line 85:  
|-
 
|-
 
|allow_url_fopen
 
|allow_url_fopen
|AllowUrlfOpen
+
|AllowUrlFopen
 
|AllowUrlFopen
 
|AllowUrlFopen
 
|off
 
|off
Line 234: Line 244:  
After that:
 
After that:
   −
  cd /etc/e-smith/templates-custom/etc/php.ini
+
  sed -i /etc/e-smith/templates-custom/etc/php.ini/30ErrorHandling -e 's/display_errors.*/display_errors          = On/g'
pico 30ErrorHandling
  −
 
  −
Modify the second line to read:
  −
 
  −
display_errors          = On
      
After that issue the following commands:
 
After that issue the following commands:
   −
  expand-template /etc/php.ini
+
  signal-event webapps-update
 
  −
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.
+
Now access your page again and see what the error is.  
    
====Undo Changes====
 
====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:
 
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
+
  signal-event webapps-update
/etc/rc7.d/S86httpd-e-smith restart
      
====Enable changes for a specific ibay====
 
====Enable changes for a specific ibay====
Line 283: Line 279:  
<!--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>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>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  
Be careful to write it down to the letter as we need it in the next step
+
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:
 
For the Primary ibay the ouptut of above command would normally look like this:
 
  /home/e-smith/files/ibays/Primary/html/
 
  /home/e-smith/files/ibays/Primary/html/
Line 291: Line 287:  
  db accounts setprop Primary PHPBaseDir /home/e-smith/files/ibays/Primary/html/:/opt/gallery2/
 
  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.
 
Above command would allow for invocation of scripts in the /opt/gallery2 path from the Primary ibay html folder by PHP.
To allow uploading of files to via http to a ibay name wiki
+
To allow uploading of files to via http to a ibay name wiki:
 
  db accounts setprop wiki PHPBaseDir /home/e-smith/files/ibays/wiki/:/tmp/
 
  db accounts setprop wiki PHPBaseDir /home/e-smith/files/ibays/wiki/:/tmp/
   Line 302: Line 298:  
upload_tmp_dir
 
upload_tmp_dir
   −
From SME Server V8 up to and including SME Server V9, you could sometimes have an error thrown by PHP and would then need to specify a temporary directory (e.g. upload_tmp_dir) which is not set in php.ini. see [[bugzilla:6650]] and [[bugzilla:7652]]. Many php applications need this setting, the best-known culprits are Wordpress, Roundcube, eGroupWare, and there are others. ther symptoms observed are that you can't upload contents to the PHP application.
+
From SME Server V8 up to and including SME Server V9, you could sometimes have an error thrown by PHP and would then need to specify a temporary directory (e.g. upload_tmp_dir) which is not set in php.ini. see [[bugzilla:6650]] and [[bugzilla:7652]]. Many php applications need this setting, the best-known culprits are Wordpress, Roundcube, eGroupWare, and there are others. The symptoms observed are that you can't upload contents to the PHP application.
   −
An easy resolution is to make a Custom Template to resolve this issue. see [[Uploadtmpdir]]
+
An easy resolution is to make a Custom Template to resolve this issue. See [[Uploadtmpdir]].
    +
=== Advanced use of the php-fpm pools ===
   −
===Installation of composer===
+
==== For the ibays with php-fpm.d/ibays.conf ====
 +
For the ibays better option is to simply use the contrib [[Webhosting]].
 +
 
 +
==== For the contrib sharefolders with php-fpm.d/shares.conf ====
 +
Similar to ibays.
 +
 
 +
==== For the contribs with php-fpm.d/www.conf ====
 +
Please read [[Building Your Contrib]].
 +
 
 +
==== For your custom needs with php-fpm.d/custom.conf ====
 +
You can build your own pool to use in any place on your server, even in a subfolder of an ibay or in place of the regular ibay php-pool (property PHPCustomPool).
 +
 
 +
There are two ways in doing that:
 +
 
 +
===== using db php =====
 +
Using the default template : /etc/e-smith/templates/etc/php-fpm.d/custom.conf , you can set your own pool doing:
 +
db php set MYPOOLNAME pool Version 81 status enabled
 +
here are the accepted supplementary properties, as always missing or empty means using default.
 +
{| class="wikitable"
 +
!property
 +
!default
 +
!values
 +
!information
 +
|-
 +
|status
 +
|enabled
 +
|enabled,disabled
 +
|-
 +
|Version
 +
|
 +
|
 +
|php version to use eg 80 for php 8.0
 +
|-
 +
|MemoryLimit
 +
|128M
 +
|
 +
|-
 +
|MaxExecutionTime
 +
|30
 +
|
 +
|-
 +
|MaxInputTime
 +
|60
 +
|
 +
|-
 +
|AllowUrlFopen
 +
|off
 +
|
 +
|-
 +
|MaxChildren
 +
|15
 +
|
 +
|-
 +
|PostMaxSize
 +
|10M
 +
|
 +
|-
 +
|UploadMaxFilesize
 +
|10M
 +
|
 +
|-
 +
|FileUpload
 +
|enabled
 +
|
 +
|-
 +
|BaseDir
 +
|
 +
|
 +
|-
 +
|DisabledFunctions
 +
|system,show_source,symlink,exec,dl,shell_exec,passthru,phpinfo,escapeshellarg,escapeshellcmd
 +
|
 +
|-
 +
|User
 +
|www
 +
|
 +
|-
 +
|Group
 +
|www
 +
|
 +
|-
 +
|DisplayErrors
 +
|disabled
 +
|
 +
|-
 +
|LogErrors
 +
|disabled
 +
|
 +
|-
 +
|MaxChildren
 +
|15
 +
|
 +
|-
 +
|AutoPrependFile
 +
|enabled
 +
|
 +
|will use the autoprepend file
 +
|-
 +
|MailForceSender
 +
|php\@$DomainName
 +
|
 +
|
 +
|}
 +
You will then need two httpd.conf custom template fragment to use your pool. You will need to change  '''MYPOOL''' to what you want
 +
mkdir -p  /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/
 +
vim /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98mypoolusage
 +
 
 +
<Directory /home/e-smith/files/ibays/test/html/mysubfolder>
 +
    SSLRequireSSL
 +
    Options None
 +
    Options +Indexes
 +
    Options +FollowSymLinks
 +
    DirectoryIndex index.php index.shtml index.htm index.html
 +
    <FilesMatch \.php$>
 +
          SetHandler "proxy:unix:/var/run/php-fpm/php80-MYPOOLNAME.sock|fcgi://localhost"
 +
    </FilesMatch>
 +
    AllowOverride All
 +
    order deny,allow
 +
    deny from all
 +
    allow from all
 +
</Directory>
 +
Then just do:
 +
signal-event webapps-update
 +
 
 +
===== using a templates-custom =====
 +
You can write your own fragment in /etc/e-smith/templates-custom/etc/php-fpm.d/custom.conf/ e.g. /etc/e-smith/templates-custom/etc/php-fpm.d/custom.conf/15mypool
 +
 
 +
You will also need to write a httpd fragment similarly to what shown just above.
 +
 
 +
Here is an example if you want a custom pool for your ibay,  in /etc/e-smith/templates-custom/etc/php-fpm.d/ibays.conf/15MYIBAY<syntaxhighlight lang="perl">
 +
{
 +
 
 +
use esmith::AccountsDB;
 +
use esmith::php;
 +
my $a = esmith::AccountsDB->open_ro || die "Couldn't open the accounts database";
 +
my $ibay = $a->get("MYIBAY");
 +
  my $version            = PhpFpmVersionToUse($ibay);
 +
  my $dynamic            = $ibay->prop('CgiBin') || 'disabled';
 +
  my $custom              = $ibay->prop('CustomPool') || undef;
 +
  next unless ($dynamic eq 'enabled' && $version eq $PHP_VERSION && $custom);
 +
  my $key                = $ibay->key;
 +
  my $name                = lc $key;
 +
  my $pool_name          = 'php' . $version . '-' . $name;
 +
  $OUT .=<<"_EOF" if ($version eq $PHP_VERSION);
 +
 
 +
[$pool_name]
 +
user = www
 +
group = www
 +
listen.owner = root
 +
listen.group = www
 +
listen.mode = 0660
 +
listen = /var/run/php-fpm/$pool_name.sock
 +
;
 +
;
 +
;put whatever you need there
 +
;
 +
;
 +
_EOF
 +
}
 +
 
 +
</syntaxhighlight>
 +
 
 +
You have then to force the ibay to use it by doing :<syntaxhighlight lang="bash">
 +
db accounts MYIBAY setprop CustomPool enabled
 +
</syntaxhighlight>This will prevent the generation of the default ibay pool in  ibays.conf , and let you use /var/run/php-fpm/php$version-$name.sock socket from your template-custom... or from the db php using the same key as the name of the ibay.
 +
 
 +
===Installation of Composer===
    
This is made tricky as we do not have the PHP CLI configured.
 
This is made tricky as we do not have the PHP CLI configured.
   −
But we can install it as follows with command line arguments. This is using php74
+
But we can install it as follows with command line arguments. This is using php74.
    
Download:
 
Download:
 
  php74 -d allow_url_fopen=on -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
 
  php74 -d allow_url_fopen=on -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
 +
 +
Hash check:
 +
php74 -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    
Install:
 
Install:
  php74 -d allow_url_fopen=on  ./composer-setup.php  
+
  php74 -d allow_url_fopen=on  ./composer-setup.php
 +
 
 +
=== Bugs ===
 +
Please raise bugs under the SME-Server 10.X section in [http://bugs.contribs.org/enter_bug.cgi Bugzilla] and select the smeserver-php component or use {{BugzillaFileBug|product=SME%20Server%2010.X|component=e-smith-*%20and%20smeserver-*&20packages|title=this link}}.
    +
Below is an overview of the current issues for this package:
 +
{{#bugzilla:columns=id,product,version,status,summary |sort=id|order=desc |component=smeserver-php|noresultsmessage="No open bugs found."}}
 
----
 
----
    
[[Category: Howto]]
 
[[Category: Howto]]
 +
[[Category: Webapps]]
board, director
297

edits

Navigation menu