GNU/Linux >> Linux Esercitazione >  >> Debian

Come installare Apache, MariaDB, PHP (stack LAMP) su Debian 11

LAMP sta per Linux, Apache, MariaDB e PHP. Le aziende di hosting vi costruiscono sopra, gli sviluppatori lo usano per tutto, dai blog ai portali, e poiché ogni componente è gratuito e open source è la risposta ovvia agli costosi stack proprietari.

Costruire lo stack

Linux

Installa Debian 11 da zero, oppure aggiorna Debian 10 “Buster” a Debian 11 “Bullseye”.

Quanto segue installa Apache v2.4.48, PHP v7.4 e MariaDB v10.5.

Apache

sudo apt update sudo apt install -y apache2 apache2-utils

Verifica che il servizio si sia avviato.

sudo systemctl status apache2

Output:

● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-08-24 09:20:01 CDT; 33s ago Docs: https://httpd.apache.org/docs/2.4/ Main PID: 1930 (apache2) Tasks: 55 (limit: 2321) Memory: 10.8M CPU: 58ms CGroup: /system.slice/apache2.service ├─1930 /usr/sbin/apache2 -k start ├─1932 /usr/sbin/apache2 -k start └─1933 /usr/sbin/apache2 -k start Aug 24 09:20:01 debian11.itzgeek.local systemd[1]: Starting The Apache HTTP Server... Aug 24 09:20:01 debian11.itzgeek.local systemd[1]: Started The Apache HTTP Server. 

Ora verifica nel browser.

https://localhost/

OPPURE

https://your-ip-add-ress/

La “Apache2 Debian Default Page” conferma che Apache sta servendo.

Come installare Apache, MariaDB, PHP (stack LAMP) su Debian 11

Il tuo HTML va in /var/www/html/; la configurazione principale è /etc/apache2/apache2.conf, con ulteriori file al suo fianco in /etc/apache2.

MariaDB

MariaDB è il principale server di database open source e un rimpiazzo compatibile di MySQL, mantenuto dagli autori originali di MySQL.

sudo apt install -y mariadb-server mariadb-client

Debian 11 fornisce la v10.5.

Al momento della stesura di questo articolo, MariaDB v10.6 è disponibile dal repository ufficiale di MariaDB. Se vuoi, puoi installare MariaDB v10.6 su Debian 11 OPPURE installare MySQL 8.0 / 5.7 al posto di MariaDB.

Controlla il servizio.

sudo systemctl status mariadb

Output:

● mariadb.service - MariaDB 10.5.11 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-08-24 09:31:02 CDT; 2min 42s ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Process: 2951 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS) Process: 2952 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 2954 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl se> Process: 3015 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 3017 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS) Main PID: 3001 (mariadbd) Status: "Taking your SQL requests now..." Tasks: 10 (limit: 2321) Memory: 80.5M CPU: 1.027s CGroup: /system.slice/mariadb.service └─3001 /usr/sbin/mariadbd Aug 24 09:31:04 debian11.itzgeek.local /etc/mysql/debian-start[3022]: information_schema Aug 24 09:31:04 debian11.itzgeek.local /etc/mysql/debian-start[3022]: MySQL 

Rendila più sicura prima di memorizzarci qualcosa di importante.

sudo mysql_secure_installation

LEGGI: Come rendere sicura l'installazione di MariaDB con mysql_secure_installation

PHP

Apache serve .html nativamente ma non PHP. Due pacchetti risolvono il problema: PHP stesso, più l'estensione MySQL così che PHP possa raggiungere il database.

sudo apt install -y php php-mysql libapache2-mod-php

Debian 11 include PHP v7.4.

Riavvia Apache per caricare il modulo.

sudo systemctl restart apache2

Testare lo stack

Inserisci un file di prova nella document root.

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Poi aprilo nel browser.

https://localhost/info.php

OPPURE

https://your-ip-add-ress/info.php

La pagina apparirà come qui sotto.

Come installare Apache, MariaDB, PHP (stack LAMP) su Debian 11

Scorrendo più in basso si trovano i dettagli delle estensioni per MySQL, XML e le variabili PHP in uso.

Conclusione

Lo stack LAMP è installato su Debian 11. Aggiungere phpMyAdmin ti offre un modo via browser per gestire MariaDB.


Debian
  1. Installare e configurare stack LAMP Apache e PHP su Debian 11

  2. Creare un server web senza sforzo: lo stack LAMP su Debian 11

  3. Configurare uno stack LAMP su Debian Wheezy con MariaDB

  4. Configurare stack LAMP su Debian 9

  5. Come Installare lo Stack LAMP Apache, MySQL, PHP su Debian 11

Come installare LAMP (Apache, MySQL, PHP) su Debian 9 Stretch

Come installare LAMP (Apache, MySQL, PHP) su Debian 8 Jessie

Come installare LAMP su Debian 10

Come installare lo stack LAMP su Debian 8

Configurare lo stack LAMP su Debian 11: Apache, MariaDB e PHP

Come installare uno stack LAMP su CentOS 7