GNU/Linux >> Tutoriels Linux >  >> Ubuntu

Installer WordPress sur Nginx avec Ubuntu : de zéro au site en ligne

Nginx est un serveur web performant, apprécié pour sa capacité à gérer de nombreuses connexions simultanées. Voici comment installer WordPress sur Ubuntu avec Nginx et PHP 8.1.

Préparer Ubuntu

sudo apt update
sudo apt upgrade
sudo apt install ufw
sudo ufw enable
sudo ufw allow http
sudo ufw allow https
sudo ufw allow 22

Créez un utilisateur avec droits sudo plutôt que travailler en root :

adduser username
usermod -aG sudo username

Installer Nginx

sudo apt install nginx
sudo service nginx restart
sudo service nginx status

Configurer le bloc serveur

sudo unlink /etc/nginx/sites-enabled/default
sudo nano /etc/nginx/sites-available/example.com

Exemple de configuration :

server {
 listen 80;
 server_name example.com;
 root /var/www/example.com;
 index index.php index.html;
 location / {
  try_files $uri $uri/ /index.php?$args;
 }
 location ~ \.php$ {
  include snippets/fastcgi-php.conf;
  fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
 }
}

Activez le site et testez la configuration :

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo service nginx restart

Installer MariaDB et PHP

sudo apt install mariadb-server
sudo mysql_secure_installation
sudo mysql
create database wordpress;
create user 'sandy'@'localhost' identified by 'password';
grant all privileges on wordpress.* to 'sandy'@'localhost';
sudo add-apt-repository ppa:ondrej/php
sudo apt install php-cli php-fpm php-mysql php-json php-mbstring php-xml php-gd php-curl

Installer WordPress

sudo mkdir /var/www/example.com
wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
sudo tar -xvf /tmp/wordpress.tar.gz -C /tmp/
sudo mv /tmp/wordpress/* /var/www/example.com
sudo chown -R www-data:www-data /var/www/example.com
sudo find /var/www/example.com/ -type d -exec chmod 755 {} \;
sudo find /var/www/example.com/ -type f -exec chmod 644 {} \;

Ouvrez votre domaine, renseignez les identifiants de base de données et terminez l’installation. Pensez ensuite aux mises à jour automatiques et à Livepatch.

Ubuntu
  1. Installer WordPress avec Nginx sur Ubuntu 18.04

  2. Héberger WordPress sur Ubuntu 20.04 avec MySQL 8 et Nginx

  3. Installer LEMP sur Ubuntu 16.04

  4. Nginx sur Ubuntu 18.04 : installation, blocs serveur et fichiers clés

  5. Installer phpMyAdmin sur Ubuntu 20.04 avec Nginx

Installer Nginx sur Ubuntu 18.04 LTS

Installer le serveur web Nginx sur Ubuntu 20.04

Installer NGINX sur Ubuntu 18.04 et configurer un hôte virtuel

Installer WordPress avec NGINX sur Ubuntu 18.04 (stack LEMP)

Installer Nginx sur Ubuntu 14.04

Installer Nginx sur Ubuntu 20.04