sudo apt-get install ssh;
#test:
ssh j@localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:2zwyEmNvT+eG+jG/GhckoZQ2yWthMNp0LgkXVzIb7gw.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
j@localhost's password: xxxxxxx
sudo apt update;
sudo apt install apache2;
#test:
sudo apt install curl; sudo apt install mysql-server; sudo mysql_secure_installation;sudo chown `whoami`:`whoami` ~/.mysql_history
#TEST
mysql -uroot -p
(mot de passe)
sudo mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.7.28-0ubuntu0.18.04.4 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
PHP (version par défaut ubuntu 18.04.3 (php 7.2.x):
sudo apt install php libapache2-mod-php php-mysql;
PHP 7.3.x:
sudo add-apt-repository ppa:ondrej/php; sudo apt-get update;
Nous voulons dire au serveur web de donner priorité aux fichiers PHP, ainsi il faut exiger à Apache de regarder pour un fichier index.php
en premier.
Afin d’effectuer cela, entrez cette commande pour ouvrir le fichier dir.conf
dans un éditeur de texte avec des privilèges root :
sudo nano /etc/apache2/mods-enabled/dir.conf;
Cela va ressembler à cela :
/etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
Déplacer le fichier d’index PHP (surligner ci-dessous) à la première position après la spécification DirectoryIndex
, de la manière suivante :
/etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Lorsque vous avez terminé, sauvegarder et fermer le fichier en appuyant sur CTRL+X
. Confirmer la sauvegarde en entrant la touche Y
et en appuyant sur ENTER
afin de vérifier la localisation du fichier de sauvegarde.
Ensuite, redémarrer le serveur web Apache afin que vos modifications prennent effet. Cela s’effectuera en inscrivant ceci :
sudo systemctl restart apache2;
sudo apt install php-cli;
#TEST php
sudo vim /var/www/html/info.php;
<?php
phpinfo();
?>
#Extensions
sudo apt install php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-bcmath php-json php-bcmath php-imagick;
sudo apt install php7.3-cli php7.3-fpm php7.3-json php7.3-pdo php7.3-mysql php7.3-zip php7.3-gd php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath php7.3-imagick;
sudo apt install php7.4-cli php7.4-fpm php7.4-json php7.4-pdo php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath php7.4-imagick;
sudo apt install php8.1-cli php8.1-fpm php8.1-pdo php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath php8.1-imagick php8.1-fpm php8.1-phpdbg
sudo apt install libapache2-mod-fcgid; sudo apt install software-properties-common; sudo apt install php7.2 php7.2-fpm; sudo apt install php5.6 php5.6-fpm;
sudo apt install php5.6-cli php5.6-fpm php5.6-json php5.6-pdo php5.6-mysql php5.6-zip php5.6-gd php5.6-mbstring php5.6-curl php5.6-xml php5.6-bcmath php5.6-imagick;
sudo apt install php7.2-cli php7.2-fpm php7.2-json php7.2-pdo php7.2-mysql php7.2-zip php7.2-gd php7.2-mbstring php7.2-curl php7.2-xml php7.2-bcmath php7.2-imagick;
sudo apt install php7.1-cli php7.1-fpm php7.1-json php7.1-pdo php7.1-mysql php7.1-zip php7.1-gd php7.1-mbstring php7.1-curl php7.1-xml php7.1-bcmath php7.1-imagick;
sudo apt install php-cgi
#Très important: Activer fcgid
sudo a2enmod actions alias proxy_fcgi fcgid;
#Excel
https://github.com/PHPOffice/PhpSpreadsheet
sudo systemctl restart apache2;
PHP 7.3 hôte virtuel (Apache2)
<VirtualHost *:80>
...
<FilesMatch \.php$>
# Apache 2.4.10+ can proxy to unix socket
SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost/"
</FilesMatch>
...
</VirtualHost>
Activer les urls 'propre' aussi connu comme 'chemin'
sudo a2enmod rewrite; sudo service apache2 restart;
MySQL - créer utilisateur pour bdd avec mot de passe
CREATE DATABASE bdd;
CREATE USER 'utilisateur'@'localhost' IDENTIFIED BY 'Secret123!';
GRANT ALL PRIVILEGES ON bdd.* to 'bdd'@'localhost';
FLUSH PRIVILEGES;
sudo apt-get install composer;
Commentaires
Ownership
We had to change the ownership.
incomplete documentation
Lets add php.ini memory configuration
also lets add mysql my.cnf or conf for MAX_ALLOWED_PACKET which should be minimum 32MB but I usually put 64MB although 32 should be sufficient.
docker instructions
post installation for docker so that you can run docker in the docker group
https://docs.docker.com/install/linux/linux-postinstall/
php.ini
remember to also increase the php.ini memory limit for cli /apache2 and fpm php.ini files for all versions of installed php
so memory_limit is default to 128M should be increased to say 1024M
max_execution_time is default to 30 seconds, increase that to 180 (for dev)