# DSM 6



### Dossiers utilisateurs:

```bash
bruno@DS916:~ $ pwd
/var/services/homes/bruno
```

```bash
root@DS916:~# pwd
/root
```



### Se connecter en root:

```bash
bruno@DS916:~ $ sudo -su root
Password:
sh-4.3#
```

```bash
# ok

bruno@DS916:~ $ sudo -i
root@DS916:~#
```



### Taches panifiée:

Exécuter un script par un utilisateur xxx: ici le script cron.php de Nextcloud doit être lancé par http

```bash
sudo -u http /usr/local/bin/php73 -f /volume1/web/nextcloud/cron.php
```



### Services:

#### Afficher la liste des services

```bash
root@DS916:~# synoservicecfg --list
DSM
apparmor
atalk
avahi
bluetoothd
bonjour
btacd
```

#### Gérer les services de DSM

```bash
synoservicecfg --list

synoservice --status

synoservicecfg --stop <service>

synoservicecfg --hard-stop <service>

synoservicecfg --start <service>

synoservicecfg --hard-start <service>

synoservice --restart <service>

synoservicectl --restart <service>
```

#### Redémarrer un service

```bash
/usr/syno/sbin/synoservicecfg -restart  syslog-acc
```



### Afficher les logs de connection ssh dans /var/log/message:

- Créer en tant que root le fichier /usr/local/etc/syslog-ng/patterndb.d/sshd.conf comme suit :

```bash
filter f_messages {
        level(info..emerg)
        and not facility( mail, news, cron)
        and not program(syslog-ng)
        and not filter(f_local)
        and not filter(f_synology);
};
```

- Faire un chmod 644 sur le fichier /usr/local/etc/syslog-ng/patterndb.d/sshd.conf créé.

```bash
DS414> cd /usr/local/etc/syslog-ng/patterndb.d/
-rw-rw-rw- 1 root root  454 Jul 16 19:15 sshd.conf
-rw-r--r-- 1 root root  454 Jul 11 15:15 VideoStation.conf
DS414> chmod 644 sshd.conf
-rw-r--r-- 1 root root  454 Jul 16 19:15 sshd.conf
-rw-r--r-- 1 root root  454 Jul 11 15:15 VideoStation.conf
```

- Relancer le syslog pour prise en compte du fichier (sinon un reboot du NAS) :

```bash
DS414> synoservicecfg --restart syslog-acc
```



### Installer un paquet .deb

```bash
# echec pour un problème de signature
sudo dpkg -i nano_2.7.4-1_i386.deb
Password:
Authenticating nano_2.7.4-1_i386.deb ...
debsig: Origin Signature check failed. This deb might not be signed.

dpkg: error processing nano_2.7.4-1_i386.deb (--install):
 verification on package nano_2.7.4-1_i386.deb failed!
Errors were encountered while processing:
 nano_2.7.4-1_i386.deb
 
# option --force-bad-verify
sudo dpkg -i --force-bad-verify nano_2.7.4-1_amd64.deb
Authenticating nano_2.7.4-1_amd64.deb ...
debsig: Origin Signature check failed. This deb might not be signed.

dpkg: verification on package nano_2.7.4-1_amd64.deb failed; but installing anyway as you requested
Selecting previously unselected package nano.
(Reading database ... 118 files and directories currently installed.)
Unpacking nano (from nano_2.7.4-1_amd64.deb) ...

# supprimer le paquet debsig-verify
dpkg --purge dpkg-verify
```



### Installer manuellement un paquet .spk

```bash
sudo synopkg install <package.spk>
```



### Apache:

#### Configuration:

Les fichiers .conf se trouvent dans `/usr/local/etc/apache22 `ou `/usr/local/etc/apache24`

Editer le Le fichier de conf principal:  `nano /usr/local/etc/apache22/conf/httpd22.conf`

Il est conseillé de faire les modifications dans `/usr/local/etc/apache22/sites-enabled`

#### Logs:

Ils sont dans `/var/log/httpd`

```bash
/var/log/httpd $ ls -la
total 540
drwxr-xr-x  2 root   root   4096 Nov 16 03:07 .
drwxr-xr-x 17 root   root   4096 Mar  9 01:15 ..
-rw-r--r--  1 root   root    176 Oct  9 10:10 access_log
-rw-rw----  1 system log  146142 Mar 13 09:50 apache22-error_log
-rw-rw----  1 system log   58824 Nov 16 02:05 apache22-error_log.1.xz
-rw-rw----  1 system log   25992 Dec 11  2016 apache22-error_log.2.xz
-rw-rw----  1 system log    2106 Jan  9  2017 apache24-error_log
-rw-r--r--  1 root   root    363 Oct  9 10:09 error_log
-rw-rw----  1 system log  283282 Nov  2  2016 user-error_log
```

#### Redémarrer Apache:

`sudo synoservice --restart pkgctl-WebStation`

`sudo synoservice --restart pkgctl-Apache2.2`

service [pkgctl-Apache2.2] restart failed, synoerr=[0x2000]

#### Liste des modules Apache:

```bash
httpd22 -M
Loaded Modules:
 core_module (static)
 mpm_worker_module (static)
 ...
```



### php7.0

```bash
php70 --ini
Configuration File (php.ini) Path: /usr/local/etc/php70
Loaded Configuration File:         /usr/local/etc/php70/php.ini
Scan for additional .ini files in: /usr/local/etc/php70/conf.d
Additional .ini files parsed:      /usr/local/etc/php70/conf.d/SYNO.SDS.PhotoStation.ini
```

#### open_basedir

`/tmp:/var/services/tmp:/var/services/web:/var/services/homes:/dev/urandom:/volume1/dokuwiki:/volume1/Repositories:/volume1/nextcloud`

#### php.ini

`extension_dir = "/usr/local/lib/php70/modules"`

#### logs

Web Station -> Paramètres PHP-> Paramètres Avancés -> Coeur -> error_log

#### Connaitre les extensions chargées par PHP CLI:

```bash
php -m
[PHP Modules]
apcu
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
```



#### PHP 7.0.13: curl n'est pas activé:

- Ouvrir /volume1/@appstore/PHP7.0/misc/extension_list.json

```bash
root@DS916:/volume1/@appstore/PHP7.0/misc# ls -la
total 24
drwxr-xr-x 1 root root  134 Jan  7 09:08 .
drwxrwxrwx 1 root root   46 Jan  5 17:22 ..
-rw-r--r-- 1 root root 5082 Dec 19 12:20 extension_list.json
-rw-r--r-- 1 root root 5082 Jan  7 09:08 extension_list.json.bak
-rw-r--r-- 1 root root  147 Dec 19 12:20 logrotate.conf
-rw-r--r-- 1 root root  174 Dec 19 12:20 syslog.conf
root@DS916:/volume1/@appstore/PHP7.0/misc# nano extension_list.json
```

- Ajouter

```bash
       "curl": {
               "enable_default": true,
               "desc": "The curl extension allows you to connect and communicate to many different types of servers wih many different types of protocols."
       },
```

- Aller dans Web Station → Paramètres PHP → version 7.0
- Cocher, décocher et recocher pour activer l'extension (en appliquant à chaque fois)

[:fa-link: Source](https://forum.synology.com/enu/viewtopic.php?f=20&t=104368&p=464772#p464534)



### Les 3 versions de PHP:

- PHP 5.6 (BusyBox)
  /bin/php
- PHP 5.6 (Package PHP 5)
  /usr/local/bin/php56
- PHP 7.3 (Package PHP 7)
  /usr/local/bin/php73
- PHP 7.4 (Package PHP 7)
  /usr/local/bin/php74

Pour Apache, c'est la version choisie dans WebStation qui est active.

<u>En ligne de commande, par défaut, c'est la version Busybox qui est active:</u>

```bash
which php
/bin/php

/bin/php -v
PHP 7.3.16 (cli) (built: Sep 14 2020 18:32:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies

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

D'autres versions sont néanmoins disponibles:

```bash title="PHP 7.0"
which php70
/usr/local/bin/php70

php70 -v
PHP 7.0.33 (cli) (built: Dec 13 2018 12:30:20) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies
    
php70 --ini
Configuration File (php.ini) Path: /usr/local/etc/php70
Loaded Configuration File:         /usr/local/etc/php70/php.ini
Scan for additional .ini files in: /usr/local/etc/php70/conf.d
Additional .ini files parsed:      /usr/local/etc/php70/conf.d/SYNO.SDS.PhotoStation.ini
```

```bash title="PHP 7.2"
which php72
/usr/local/bin/php72

php72 -v
PHP 7.2.29 (cli) (built: Jun  5 2020 14:21:39) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    
php72 --ini
Configuration File (php.ini) Path: /usr/local/etc/php72/cli
Loaded Configuration File:         /usr/local/etc/php72/cli/php.ini
Scan for additional .ini files in: /usr/local/etc/php72/cli/conf.d
Additional .ini files parsed:      /usr/local/etc/php72/cli/conf.d/extension.ini,
/usr/local/etc/php72/cli/conf.d/phpMyAdmin.ini,
/usr/local/etc/php72/cli/conf.d/timezone.ini
```

```bash title="PHP 7.3"
which php73
/usr/local/bin/php73

php73 -v
PHP 7.3.16 (cli) (built: Sep 14 2020 18:32:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies

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

```bash title="PHP 7.3"
which php74
/usr/local/bin/php74

php74 -v
PHP 7.4.9 (cli) (built: Oct 14 2020 15:15:33) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

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



#### Mettre PHP70 par défaut en CLI:

```bash
# On renomme PHP Busybox
$ cd /bin
$ mv php php_5.6.11
$ ls -la
-rwxr-xr-x  1 root   root 6600840 Jun  8 10:31 php_5.6.11

# On crée un lien symbolique 
$ cd /usr/local/bin
$ ln -s /var/packages/PHP7.0/target/usr/local/bin/php70 php

$ which php
/usr/local/bin/php

$ php --ini
Configuration File (php.ini) Path: /usr/local/etc/php70
Loaded Configuration File:         /usr/local/etc/php70/php.ini
Scan for additional .ini files in: /usr/local/etc/php70/conf.d
Additional .ini files parsed:      /usr/local/etc/php70/conf.d/SYNO.SDS.PhotoStation.ini
```



### php7.3

Mettre PHP73 par défaut en CLI:

```bash
$ sudo -i
$ cd /usr/bin
$ mv php php56
#cp /volume1/@appstore/PHP7.3/usr/local/bin/php73 php
$ ln -s /volume1/@appstore/PHP7.3/usr/local/bin/php73 php

root@DS916:/bin# php -v
PHP 7.3.16 (cli) (built: Jun  2 2020 11:39:19) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies

bruno@DS916:~ $ php -v
PHP 7.3.16 (cli) (built: Jun  2 2020 11:39:19) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies

lrwxrwxrwx    1 root     root            45 Sep 17 10:26 php -> /volume1/@appstore/PHP7.3/usr/local/bin/php73

```



```bash
$ find /volume1/@appstore/PHP7.3 -name *.ini
/volume1/@appstore/PHP7.3/etc/php/conf.d/memcached.ini
/volume1/@appstore/PHP7.3/etc/php/conf.d/redis.ini
/volume1/@appstore/PHP7.3/misc/php-fpm.ini
/volume1/@appstore/PHP7.3/usr/local/etc/php73/cli/php.ini
/volume1/@appstore/PHP7.3/usr/local/etc/php73/cli/conf.d/extension.ini

$ find /volume1/@appstore/PHP7.4 -name *.ini
/volume1/@appstore/PHP7.4/etc/php/conf.d/memcached.ini
/volume1/@appstore/PHP7.4/etc/php/conf.d/redis.ini
/volume1/@appstore/PHP7.4/misc/php-fpm.ini
/volume1/@appstore/PHP7.4/usr/local/etc/php74/cli/php.ini
/volume1/@appstore/PHP7.4/usr/local/etc/php74/cli/conf.d/extension.ini
```



### Composer:

<u>Installation:</u>

```bash
root@DS916:/usr/local/bin# curl -s http://getcomposer.org/installer | php70
All settings correct for using Composer
Downloading...

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

<u>Installation des dépendances de l'application (ici Gitlist):</u>

```bash
bruno@DS916:/volume1/web/gitlist $ php70 /usr/local/bin/composer.phar install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 62 installs, 0 updates, 0 removals

- Installing symfony/process (v3.4.6): Downloading (100%)
```

<u>Pour simplifier l'utilisation:</u>

- Créer un script **composer.sh** dans `/usr/local/bin`
- Ajouter le contenu suivant:

```bash
#!/bin/bash
php70 -d extension=phar.so /usr/local/bin/composer.phar $*
```

- Rendre le script exécutable et le renommer:

```bash
$ chmod +X composer.sh

$ mv composer.sh composer
```

- Utilisation:

```bash
$ composer about
Composer - Package Management for PHP
Composer is a dependency manager tracking local dependencies of your projects and libraries.
See https://getcomposer.org/ for more information.
```

- Mise à jour:

```bash
$ sudo composer self-update 
You are already using composer version 1.7.1 (stable channel).
```



### Node.js

Utiliser `--unsafe-perm`

```bash
$ sudo npm install -g thumbsup --unsafe-perm
```

ou

```bash
# Erreur EACCES /opt/tmp

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

$ nvm install --lts=fermium

$ npm config set prefix '~/.npm-packages'
$ npm config set tmp '/tmp'

$ npm -g install npm
$ npm -g install thumbsup
```



### Erreurs:

/bin/nano

nano: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

```bash
sudo ln -s /lib/libncurses.so.5.9 /lib/libtinfo.so.5
```



#### Developer guide:

https://help.synology.com/developer-guide/index.html



#### iTunes Server:

[MàJ pour Apple Music](https://supfiles.synology.com/fsdownload/cgMMujWfd/iTunes%20Server%201.5.3-2504%20Patch)

