# php



Le paquet **php 8.0** est dispo:

https://www.synology.com/fr-fr/support/download/DS916+?version=7.0#packages



#### Les services **php** actifs:

```bash
  $ systemctl | grep PHP
  pkg-WebStation-php74@182b445b-6caf-469f-acaa-a763582ba8db.service                                                                 loaded active running WebStation PHP7.4 fpm process
  pkg-WebStation-php80@139939eb-365d-4381-9996-ecf91c4216bc.service                                                                 loaded active running WebStation PHP8.0 fpm process
  pkg-WebStation-php80@4d11e742-c46a-406c-a988-263bfd259fc1.service                                                                 loaded active running WebStation PHP8.0 fpm process
  pkg-WebStation-php82@49b74e5d-1252-4bbb-947e-68a70242310a.service                                                                 loaded active running WebStation PHP8.2 fpm process
  pkg-WebStation-php82@95f7fe6c-5dbc-4f31-9c63-99ef91a6df1e.service                                                                 loaded active running WebStation PHP8.2 fpm process
  pkgctl-PHP7.4.service                                                                                                             loaded active exited  PHP7.4's service unit
  pkgctl-PHP8.0.service                                                                                                             loaded active exited  PHP8.0's service unit
  pkgctl-PHP8.2.service                                                                                                             loaded active exited  PHP8.2's service unit
  PHP7.4.slice                                                                                                                      loaded active active  PHP7.4's slice
  PHP8.0.slice                                                                                                                      loaded active active  PHP8.0's slice
  PHP8.2.slice                                                                                                                      loaded active active  PHP8.2's slice
```

#### Les services **apache** actifs:

```bash
$ systemctl | grep apache
  pkg-apache24.service                                                                                                    loaded active running Apache2.4 daemon
```



#### Redémarrer un service:

```bash
$ sudo systemctl restart pkgctl-PHP8.2.service
```

```bash
$ sudo systemctl stop pkgctl-PHP8.2.service
$ sudo systemctl start pkgctl-PHP8.2.service
```



#### Mettre PHP 8.0 cli par défaut:

```bash
$ sudo -i
Password:
root@DS916:~# cd /usr/bin/

root@DS916:/usr/bin# mv php php73
root@DS916:/usr/bin# ln -s /volume1/@appstore/PHP8.0/usr/local/bin/php80 php

root@DS916:/usr/bin# php -v
PHP 8.0.17 (cli) (built: Mar 22 2022 17:54:40) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.17, Copyright (c) Zend Technologies
```



#### Liste des php.ini:

```bash
$ find / -name php.ini 2>/dev/null

/usr/local/etc/php73/cli/php.ini
/usr/local/etc/php80/cli/php.ini		memory_limit = 512M
/usr/local/etc/php74/cli/php.ini		memory_limit = 128M
/etc.defaults/php/php.ini				memory_limit = 128M 
/volume1/@appstore/PHP7.0/usr/local/etc/php70/php.ini
/volume1/@appstore/PHP7.2/usr/local/etc/php72/cli/php.ini
/volume1/@appstore/PHP7.4/usr/local/etc/php74/cli/php.ini 	memory_limit = 128M
/volume1/@appstore/PHP8.0/usr/local/etc/php80/cli/php.ini 	memory_limit = 512M
/etc/php/php.ini		memory_limit = 512M
/volume1/@appstore/PHP8.0/misc/php-fpm.ini <- memory_limit pris en compte par php-info		memory_limit = 512M


$ find / -name php*.ini 2>/dev/null
/usr/local/etc/php82/cli/php.ini														# memory_limit = 128M
/usr/local/etc/php74/cli/php.ini	          								# memory_limit = 128M
/usr/local/etc/php80/cli/php.ini														# memory_limit = 128M
/etc/php/php.ini
/etc.defaults/php/php.ini
/volume1/@appstore/PHP8.2/misc/php-fpm.ini									# memory_limit = 128M
/volume1/@appstore/PHP8.2/usr/local/etc/php82/cli/php.ini   # memory_limit = 128M
/volume1/@appstore/PHP7.4/misc/php-fpm.ini									# memory_limit = 128M
/volume1/@appstore/PHP7.4/usr/local/etc/php74/cli/php.ini   # memory_limit = 128M
/volume1/@appstore/PHP8.0/misc/php-fpm.ini									# memory_limit = 128M
/volume1/@appstore/PHP8.0/usr/local/etc/php80/cli/php.ini   # memory_limit = 128M

```



### PHP 8.0

#### Liste des fichiers de conf:

```bash
# Si modif
$ php --ini

Configuration File (php.ini) Path: /usr/local/etc/php80/cli
Loaded Configuration File:         /usr/local/etc/php80/cli/php.ini
Scan for additional .ini files in: /usr/local/etc/php80/cli/conf.d
Additional .ini files parsed:      /usr/local/etc/php80/cli/conf.d/extension.ini,
/usr/local/etc/php80/cli/conf.d/nextcloud.ini,
/usr/local/etc/php80/cli/conf.d/timezone.ini

# Sinon
$ php --ini
Configuration File (php.ini) Path: /etc/php
Loaded Configuration File:         /etc/php/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
```



```bash
bruno@DS916:~ $ cd /usr/local/etc/php80/cli/conf.d
total 20
-rw-r--r-- 1 root root  773 May  4 08:17 extension.ini
-rw-r--r-- 1 root root   68 May  4 09:48 nextcloud.ini
-rw-r--r-- 1 root root   32 May  4 08:17 timezone.ini
```



#### Erreur Nextcloud *OC\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache*:

Il faut rajouter l'extension apcu mais elle n'est pas dispo dans le profil PHP.

```bash
bruno@DS916:/usr/local/etc/php80/cli/conf.d $ cat nextcloud.ini

extension = apcu.so

[apc]
apc.shm_size = 512M
apc.enable_cli = 1
```



#### Liste des modules PHP:

```bash
$ php -m
[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imap
intl
json
ldap
libxml
mailparse
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
ssh2
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]
```



#### Log:

```bash
sudo tail -f /volume1/@appdata/PHP8.0/log/php80-fpm.log		# alimenté

sudo tail -f /volume1/@appdata/PHP8.2/log/php80-fpm.log		# n'existe pas
```

Webstation -> Paramètrers du language de script -> sélectionner un profil -> Coeur ->

- error_log : /volume1/web/log/php82_error.log
- log_errors : On



#### Dossier des modules:

`/volume1/@appstore/PHP8.0/usr/local/lib/php80/modules/`

`/volume1/@appstore/PHP8.2/usr/local/lib/php82/modules/`



Les extensions n'apparaissent pas dans les <u>Extensions du profil PHP</u> (Web Station). Il faut éditer `extension_list.json`:

```bash
$ sudo nano /volume1/@appstore/PHP8.2/misc/extension_list.json

        "apcu": {
                "enable_default": true,
                "desc": "APC User Cache."
        },



        "redis": {
                "enable_default": true,
                "desc": "The php redis extension provides an API for communicating with the Redis key-value store.."
        },
```



#### Installer Composer:

On se place dans /usr/local/bin:

```bash
bruno@DS916:~ $ cd /usr/local/bin
```

et on installe Composer:

```bash
bruno@DS916:/usr/local/bin $ sudo curl -s http://getcomposer.org/installer | sudo php80
Password:
All settings correct for using Composer
Downloading...

Composer (version 2.5.7) successfully installed to: /usr/local/bin/composer.phar
Use it: php composer.phar

```

Pour l'appeler directement, on crée un script:

```bash
bruno@DS916:/usr/local/bin $ sudo nano composer
```

```bash
#!/bin/bash
php /usr/local/bin/composer.phar $*
```

```bash
bruno@DS916:/usr/local/bin $ sudo chmod --reference=composer.phar composer
```

```bash
bruno@DS916:/usr/local/bin $ composer --version
Composer version 2.5.7 2023-05-24 15:00:39
```

