sudo apt-get install ssh;
#test:
ssh myusername@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 mariadb-server;
sudo mysql;
Assign a password for the mysql root user;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Motdepasse780!';
mysql> quit;
Bye
sudo mysql_secure_installation;sudo chown `whoami`:`whoami` ~/.mysql_history
#TEST
mysql -uroot -pMotdepasse780!
(password)
sudo mysql -uroot -pMotdepasse780!
or
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 22.04.x (php 8.2.x):
sudo apt install php libapache2-mod-php php-mysql;
PHP 8.1.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-mysql php-zip php-gd php-mbstring php-curl php-xml php-bcmath php-json;
#OUTDATED 7.4, most likely not needed
#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 php8.2-cli php8.2-fpm php8.2-pdo php8.2-mysql php8.2-zip php8.2-gd php8.2-mbstring php8.2-curl php8.2-xml php8.2-bcmath php8.2-imagick php8.2-fpm php8.2-phpdbg
sudo apt install php8.3-cli php8.3-fpm php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php8.3-bcmath php8.3-imagick php8.3-fpm php8.3-phpdbg
sudo apt install php-cgi;
#Very important: Enable fcgid
sudo a2enmod actions alias proxy_fcgi fcgid;
#Excel
https://github.com/PHPOffice/PhpSpreadsheet
sudo systemctl restart apache2;
PHP 8.1 Example
<VirtualHost *:80>
...
<FilesMatch \.php$>
# Apache 2.4.10+ can proxy to unix socket
SetHandler "proxy:unix:/var/run/php/php8.1-fpm.sock|fcgi://localhost/"
</FilesMatch>
...
</VirtualHost>
Enable rewrite mod for friendly urls
sudo a2enmod rewrite; sudo service apache2 restart;
MySQL - create username for db with password
CREATE DATABASE bdd;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'Password1!';
GRANT ALL PRIVILEGES ON dbname.* to 'dbname'@'localhost';
FLUSH PRIVILEGES;
sudo apt-get install composer;
#Change the active php version
sudo update-alternatives --config php;