GNU/Linux >> Linux Esercitazione >  >> Debian

Installare WordPress con Nginx su Debian 10 e 11

Panoramica

Questa guida installa WordPress con Nginx su Debian 10 e 11. Su un solo server Debian configuriamo stack LEMP: Nginx, PHP e MariaDB. In alternativa, WordPress può essere separato tra web server e database, oppure eseguito con Docker.

Installare pacchetti

sudo apt install nginx php-cli php-fpm php-mysql php-json php-opcache php-mbstring php-xml php-gd php-curl mariadb-server
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Configurare MariaDB

sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE sampledbwp;
GRANT ALL ON sampledbwp.* TO 'sample-admin'@'localhost' IDENTIFIED BY 'SamplePassword1';
quit

Installare WordPress

cd /var/www/html/
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzfv latest.tar.gz
cd wordpress
sudo mv wp-config-sample.php wp-config.php
sudo nano wp-config.php

Inserisci nome database, utente, password e salt keys da https://api.wordpress.org/secret-key/1.1/salt/

sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress

Configurare Nginx

sudo nano /etc/nginx/sites-available/wordpress.conf

Esempio:

server {
 listen 80;
 listen [::]:80;
 root /var/www/html/wordpress;
 index index.php index.html index.htm;
 server_name mysite.com www.mysite.com;
 location / {
  try_files $uri $uri/ /index.php?$args;
 }
 location ~ \.php$ {
  include snippets/fastcgi-php.conf;
  fastcgi_pass unix:/run/php/php7.3-fpm.sock;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 }
}

Verifica root e versione php-fpm. Rimuovi il sito default e abilita WordPress:

sudo rm /etc/nginx/sites-available/default
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Sicurezza

Valuta di rimuovere xmlrpc.php e wp-config-sample.php, cambiare URL di login, attivare 2FA e installare un firewall plugin come Wordfence o Sucuri. Evita l’username admin.

Riepilogo

WordPress con Nginx su un solo server è adatto a iniziare o testare. Per produzione con traffico elevato, separa web server e database per facilitare manutenzione e aggiornamenti.

Debian
  1. Come installare Nginx su Debian 8 Jessie

  2. Come installare Nginx su Debian 9 Stretch

  3. Installare Webmin su Debian 10 e 11: due metodi completi

  4. Installare Plone con Nginx su un VPS Debian 8

  5. Installare WordPress con Nginx su Debian 10

Come installare PHP 8.1 su Debian 11 e 10

Come installare un server SVN su Debian 11/10

Come installare Nginx con PHP-FPM su Debian 10

Come installare WordPress con stack LEMP su Debian 11 Bullseye

Installare WordPress con stack LAMP su Debian 11 Bullseye

Installare phpMyAdmin con Nginx su Debian 11 Bullseye