# Plesk



### maboiteverte.fr

Certificat wildcard IONOS

```

```

### sur-le-sentier-fr

Certificat wildcard Let's Encrypt

```

```

Installer node.js mais ne pas l'activer. (sinon erreur Passenger pour WordPress)

#### Test certificat:

https://www.digicert.com/help/

https://tools.letsdebug.net

Autres outils:

https://ssl-config.mozilla.org/

https://observatory.mozilla.org/



#### Installer bat - fd

```bash
apt install fzf bat fd-find
```

```bash
mkdir -p ~/.local/bin
ln -s /usr/bin/batcat ~/.local/bin/bat

ln -s $(which fdfind) ~/.local/bin/fd
```



#### Commande plesk:

```bash
~# plesk
Usage: plesk [command]

Commands:
  bin - Run the specified Plesk command-line utility (e.g., domain, client)
  conf - Open the specified Plesk configuration file in the editor
  daily - Run daily maintenance script
  db - Database related commands. Open MySQL console by default.
  ext - Call a command-line interface of the specified Plesk extension
  help - Show help and exit
  installer - Parallels Installer shortcuts and command completion
  log - Open the specified Plesk configuration file in the editor
  login - generate login link for specified user
  php - Run a PHP script using the Plesk PHP interpreter
  repair - Check and repair Plesk
  sbin - Run the specified Plesk internal utility
  version - Show product version information



plesk installer --select-release-current --install-component php7.2
```



#### Réparer Plesk:

```bash
$ plesk installer --select-release-current --reinstall-patch --upgrade-installed-components 

$ plesk repair installation  
```



#### Tester la zone DNS:

```bash
# plesk bin dns --info maboiteverte.fr

default._domainkey.maboiteverte.fr. TXT  v=DKIM1; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxzyvpKYtbnO85FVd+ohgg8z/IMequZWqFtGJsA++Re+491ZyXWLTJtkwASalrPf+2FOYNZ+VyMeiTe9uwMXtoVgalE1+kwaDA6MiaZaG+GlFCOxe7658IcTbWcrTkrnoGp98kNO9S4Nz6J+jhYDaomhir7JXl6/I6e+FrE8CSq2TtzWw1iWOXyDMepwI+uLRwFNzPTbvJGeNJQThlxwjPyBfjhsN3nhKyk6xN3hqjRZGIudKxcg1fs9hYexlDRVYnpoQIE0e3g/8U3nPYsRFYQUooAu6h5t3buOVkF/526WNBif2SYrv4gv4M9ioAgpPlQ9AUpFj7+GrIwChZHFeMQIDAQAB;
_domainkey.maboiteverte.fr. TXT  o=-
_imaps._tcp.maboiteverte.fr. SRV 0 0 993 maboiteverte.fr.
_pop3s._tcp.maboiteverte.fr. SRV 0 0 995 maboiteverte.fr.
_smtps._tcp.maboiteverte.fr. SRV 0 0 465 maboiteverte.fr.
_domainconnect.maboiteverte.fr. TXT  domainconnect.plesk.com/host/eloquent-benz.212-227-191-167.plesk.page/port/8443
www.maboiteverte.fr. CNAME  maboiteverte.fr.
_dmarc.maboiteverte.fr. TXT  v=DMARC1; p=quarantine; adkim=s; aspf=s
maboiteverte.fr. TXT  v=spf1 +a +mx +a:eloquent-benz.212-227-191-167.plesk.page -all
ftp.maboiteverte.fr. CNAME  maboiteverte.fr.
ipv4.maboiteverte.fr. A  212.227.191.167
mail.maboiteverte.fr. A  212.227.191.167
maboiteverte.fr. MX 10 mail.maboiteverte.fr.
webmail.maboiteverte.fr. A  212.227.191.167
maboiteverte.fr. A  212.227.191.167
ns2.maboiteverte.fr. A  212.227.191.167
maboiteverte.fr. NS  ns2.maboiteverte.fr.
ns1.maboiteverte.fr. A  212.227.191.167
maboiteverte.fr. NS  ns1.maboiteverte.fr.
_acme-challenge.maboiteverte.fr. TXT  MimhDPvw3yZEhONNc_FTbhdrXF1ucw-yB-qq_lR53Bw
gitea.maboiteverte.fr. A  212.227.191.167
joplin.maboiteverte.fr. A  212.227.191.167
SUCCESS: Getting information for Domain 'maboiteverte.fr' complete.
```

```bash
# plesk bin dns --info sur-le-sentier.fr | sed '/^$/d'
default._domainkey.sur-le-sentier.fr. TXT  v=DKIM1; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxV47adeJmaGva29VEH8WABYOuXweTNKq2U4CG1VY3zzvfjqWdBZmCRHzo12IqKXgBkGz0Gac9VygkWCXPbHlSEFCcfxtoOSa5iIIFH18FoOF2NHWsUS2s2vdiyJUMlj76ov5ZjxbWnxBVVm/lBPdo0plg8PZR5Mxww3iFkRCvdMTLxkJ3PfhEmQ8itseAkqh1TijVjw6pLgZF3epEDVNG1X3glY3wLdWVzYj+hSyEu7JuPG7N6q784QdmsJ9XZvs2Q1ZscK24cNOOLTzpo4SNfQ8mpaAyh1FxUcjHFbuZmpVf/MOZPw5HIZxR5BahsJRimY3rygdkm+dxTyviBGu9wIDAQAB;
_domainkey.sur-le-sentier.fr. TXT  o=-
_imaps._tcp.sur-le-sentier.fr. SRV 0 0 993 sur-le-sentier.fr.
_pop3s._tcp.sur-le-sentier.fr. SRV 0 0 995 sur-le-sentier.fr.
_smtps._tcp.sur-le-sentier.fr. SRV 0 0 465 sur-le-sentier.fr.
_acme-challenge.sur-le-sentier.fr. TXT  ZdehpAyn6echOGS3RzJFUzPh4nnYKK65srnuMYimijk
sur-le-sentier.fr. MX 10 mail.sur-le-sentier.fr.
sur-le-sentier.fr. NS  ns2.sur-le-sentier.fr.
sur-le-sentier.fr. NS  ns1.sur-le-sentier.fr.
sur-le-sentier.fr. A  212.227.191.167
ns1.sur-le-sentier.fr. A  212.227.191.167
ns2.sur-le-sentier.fr. A  212.227.191.167
ftp.sur-le-sentier.fr. CNAME  sur-le-sentier.fr.
mail.sur-le-sentier.fr. A  212.227.191.167
www.sur-le-sentier.fr. CNAME  sur-le-sentier.fr.
sur-le-sentier.fr. TXT  v=spf1 +a +mx +a:eloquent-benz.212-227-191-167.plesk.page -all
webmail.sur-le-sentier.fr. A  212.227.191.167
_dmarc.sur-le-sentier.fr. TXT  v=DMARC1; p=quarantine; adkim=s; aspf=s
ipv4.sur-le-sentier.fr. A  212.227.191.167
_domainconnect.sur-le-sentier.fr. TXT  domainconnect.plesk.com/host/eloquent-benz.212-227-191-167.plesk.page/port/8443
SUCCESS: Getting information for Domain 'sur-le-sentier.fr' complete.
```



#### Liste des extensions installées:

```bash
plesk bin extension --list
```

#### Réparer Plesk :

```bash
plesk repair installation
```

#### Réparer les permissions d'un site:

```bash
plesk repair fs example.com
```

#### Fichiers logs:

```bash
/var/www/vhosts/sur-le-sentier.fr/logs/
```



#### Ajouter l'`user` bruno au groupe `sudo`:

```bash
# ubuntu:

root@localhost:~# usermod -aG sudo bruno
```

```bash
root@localhost:~# adduser sentier sudo
```



#### Redémarrer MySQL / MariaDB:

```bash
# sous root:

service mysql restart || service mariadb restart || service mysqld restart 
```



#### Redémarrer PHP:

```bash
# sous root:

plesk bin php_handler --list | grep -E plesk.*fpm | awk -F" " '{ print $1 }' | while read i; do service $i restart; done
```



#### Liste des modules installés:

```bash
# apache2ctl -M

Loaded Modules:
 core_module (static)
 so_module (static)
```

Vérifier la syntaxe du fichier de configuration:

```bash
# apachectl -t
# apachectl configtest
Syntax OK
```

https://httpd.apache.org/docs/2.4/fr/programs/apachectl.html



#### Installer GeoIP:

```bash
apt-get install plesk-php74-dev build-essential
apt-get install libgeoip-dev geoip-bin geoip-database
/opt/plesk/php/7.4/bin/pecl install http://pecl.php.net/get/geoip-1.1.1.tgz

/opt/plesk/php/7.4/lib/php/modules/geoip.so

Add " extension=geoip.so" to php.ini file: 
For PHP 7.0 modify file /opt/plesk/php/7.0/etc/php.ini
For PHP 7.1 modify file /opt/plesk/php/7.1/etc/php.ini

echo "extension=geoip.so" > /opt/plesk/php/7.4/etc/php.d/geoip.ini

/opt/plesk/php/7.4/etc/php.d# /opt/plesk/php/7.4/bin/php -m | grep geoip

<?php print_r(geoip_record_by_name('php.net')); ?>
Required database not available at /usr/share/GeoIP/GeoIPCity.dat"

Redémarrer Apache:
service apache2 restart
sinon redémarrer le serveur
```

#### Installer GeoIP 2:

```bash
wget https://github.com/maxmind/geoip-api-mod_geoip2/archive/1.2.10.tar.gz
tar -xzvf 1.2.10.tar.gz
cd geoip-api-mod_geoip2-1.2.10/
apxs -i -a -L/usr/local/lib -I/usr/local/include -lGeoIP -c mod_geoip.c

Installer dans
/usr/lib/apache2/modules/mod_geoip.so

Ne marche pas !!
```



[git](git.md)

[Gitea](Gitea.md)

[Ghost](Ghost.md)

[nextcloud](nextcloud.md)

https://support.plesk.com/hc/en-us/articles/360003876473-How-to-clean-temporary-Plesk-files-on-a-Linux-server

https://support.plesk.com/hc/en-us/articles/115002557954-How-to-remove-Plesk-backup-files-and-their-logs?source=search

```bash
root@localhost:~# df -h /tmp
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lv01   47G   44G  1,2G  98% /

root@localhost:~# df -h /
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lv01   47G   44G  1,2G  98% /
```

Remove backup logfiles:

```bash
# status change XX*24 hours ago.

find /var/log/plesk/PMM/ -name 'backup*' -type d -ctime +XX -exec rm -rf {} +;
```

Remove backup files:

```bash
find /var/lib/psa/dumps -name 'backup*' -type f -ctime +XX -exec rm -rf {} +;
```

Allocate additional disk space or remove unnecessary files in `/var/lib/psa/dumps`.

```bash
find / -type f -size +200M -exec du -h {} + 2>/dev/null | sort -r -h

5,0G	/var/lib/psa/dumps/domains/sur-le-sentier.fr/backup_user-data_2108080143.tgz
2,5G	/var/www/vhosts/sur-le-sentier.fr/.wp-toolkit/snapshots/instance_files_2_52x7sld.zip
1,3G	/var/lib/psa/dumps/domains/maboiteverte.fr/backup_user-data_2110310443.tgz
445M	/var/www/vhosts/sur-le-sentier.fr/httpdocs/blog/wp-content/backups-hsmHO/backup_sur-le-sentier.fr-2021-08-28_00-30-sql-d1408.tar
445M	/var/www/vhosts/sur-le-sentier.fr/httpdocs/blog/wp-content/backups-hsmHO/backup_sur-le-sentier.fr-2021-08-21_01-02-sql-30d72.tar
445M	/var/www/vhosts/sur-le-sentier.fr/httpdocs/blog/wp-content/backups-hsmHO/backup_sur-le-sentier.fr-2021-08-13_21-16-sql-4a9e7.tar
444M	/var/www/vhosts/sur-le-sentier.fr/httpdocs/blog/wp-content/backups-hsmHO/backup_sur-le-sentier.fr-2021-08-06_21-55-sql-e4946.tar
444M	/var/www/vhosts/sur-le-sentier.fr/httpdocs/blog/wp-content/backups-hsmHO/backup_sur-le-sentier.fr-2021-07-31_00-58-sql-55db0.tar
444M	/var/www/vhosts/sur-le-sentier.fr/httpdocs/blog/wp-content/backups-hsmHO/backup_sur-le-sentier.fr-2021-07-23_19-09-sql-f389e.tar
443M	/var/www/vhosts/sur-le-sentier.fr/httpdocs/blog/wp-content/backups-hsmHO/backup_sur-le-sentier.fr-2021-09-18_00-06-sql-a7089.tar
443M	/var/www/vhosts/sur-le-sentier.fr/httpdocs/blog/wp-content/backups-hsmHO/backup_sur-le-sentier.fr-2021-09-11_01-02-sql-43a2f.tar
442M	/var/www/vhosts/sur-le-sentier.fr/httpdocs/blog/wp-content/backups-hsmHO/backup_sur-le-sentier.fr-2021-09-03_16-27-sql-24b6a.tar
357M	/var/lib/fail2ban/fail2ban.sqlite3.20210913-061953
357M	/var/lib/fail2ban/fail2ban.sqlite3.20210802-061844
357M	/var/lib/fail2ban/fail2ban.sqlite3
272M	/var/lib/psa/dumps/domains/sur-le-sentier.fr/backup_user-data_2108080143_2108150143.tgz
251M	/var/lib/psa/dumps/domains/sur-le-sentier.fr/backup_user-data_2108080143_2108290143.tgz
251M	/var/lib/psa/dumps/domains/sur-le-sentier.fr/backup_user-data_2108080143_2108220143.tgz
```



#### How to Clear Systemd Journal Logs

##### Voir les derniers logs:

```bash
$ journalctl -r

Hint: You are currently not seeing messages from other users and the system.
      Users in groups 'adm', 'systemd-journal' can see all messages.
      Pass -q to turn off this notice.
-- Logs begin at Tue 2023-08-01 13:45:12 CEST, end at Tue 2023-08-01 14:18:59 CEST. --
août 01 14:18:59 localhost sshd[66502]: Disconnected from user bruno 92.184.105.67 port 59557
août 01 14:18:59 localhost sshd[66502]: Received disconnect from 92.184.105.67 port 59557:11: cleanup
août 01 14:03:57 localhost sshd[66463]: Disconnected from user bruno 92.184.105.67 port 59553

```

##### Voir la place occupée par les logs:

```bash
$ journalctl --disk-usage -q
Archived and active journals take up 24.0M in the file system.
```

##### Faire tourner les journeaux de logs:

Le journal courant est archivé, un nouveau est crée

```bash
$ sudo journalctl --rotate
```

##### Supprimer les journaux vieux de plus de 2 jours:

```bash
# 2h(ours), 2m(onths), 2w(eeks)

$ sudo journalctl --vacuum-time=2d

Vacuuming done, freed 0B of archived journals from /var/log/journal.
Deleted archived journal /var/log/journal/5fd6a638ff89491ab71a5b5150cf1c13/user-10001@74abf00168a74a3884bd8c3fc35ea7c1-0000000002757ece-0005fb79b9881a67.journal (8.0M).
Deleted archived journal /var/log/journal/5fd6a638ff89491ab71a5b5150cf1c13/system@72ce45a2f8954e2c92ac122b6c16569e-00000000027580a5-0005fb79e618be9c.journal (96.0M).
```

##### Garder 100Mo de journaux:

```bash
$ sudo journalctl --vacuum-size=100M
```

##### Garder 5 fichiers de journaux:

```bash
$ sudo journalctl --vacuum-files=5
```

##### Nettoyer automatiquement les vieux journaux:

```bash
# Sauvegarder le fichier de config de journald
$ cp /etc/systemd/journald.conf /etc/systemd/journald.conf.back

# Editer le fichier de configuration de journald
$ sudo nano /etc/systemd/journald.conf

# Décommenter la ligne SystemMaxUse
SystemMaxUse=250M

# Redémarrer journald
$ sudo systemctl restart systemd-journald
```





Installer Plesk Firewall

https://support.plesk.com/hc/en-us/articles/12377540171799

```bash
plesk installer add --components psa-firewall
```



```bash
root@eloquent-benz:~# adduser bruno sudo

root@eloquent-benz:~# adduser sentier sudo
```



```bash
# réseaux
root@eloquent-benz:~# apt install net-tools nmap
```

```bash
# Thumbsup
root@eloquent-benz:~# apt install libimage-exiftool-perl graphicsmagick
```

