Project

General

Profile

Support #974

Install Wordpress on Debian

Added by Daniel Curtis over 2 years ago. Updated over 1 year ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Web Server
Target version:
Start date:
07/13/2022
Due date:
% Done:

100%

Estimated time:

Description

This is a simple guide for setting up WordPress with nginx on Debian 10.

  • Make sure the system is up to date:
    sudo apt update && sudo apt upgrade
    

Install Nginx

  • Install nginx:
    sudo apt install nginx
    
  • Start and enable nginx at boot:
    sudo systemctl nginx enable
    sudo systemctl nginx start
    

Install PHP

  • Install php-fpm and extensions:
    sudo apt install php-fpm php-common php-gd php-getid3 php-mysql php7.3-cli php7.3-common php7.3-gd php7.3-json php7.3-mysql php7.3-opcache php7.3-readline
    
  • Start and enable php-fpm:
    sudo systemctl enable php7.3-fpm
    sudo systemctl start php7.3-fpm
    

Install MariaDB

  • Install MariaDB:
    sudo apt install mariadb-server mariadb-client
    
  • Secure the database server:
    sudo mysql_secure_installation
    
    • NOTE: I had an issue logging in as root, to workaround this:
      sudo systemctl stop mariadb
      sudo mysqld_safe --skip-grant-tables --skip-networking
      mysql -u root
      
      UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';
      FLUSH PRIVILEGES;
      
      sudo kill -9 $(pgrep mysql)
      
      sudo systemctl start mariadb
      

Configure a new MySQL database

  • Log into the MySQL console:
    mysql -h localhost -u root -p
    
    • Create the wordpressuser user with the SuperSecretPassword password and the wordpressdb database:
      CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'SuperSecretPassword';   
      CREATE DATABASE IF NOT EXISTS  `wordpressdb` CHARACTER SET utf8 COLLATE utf8_general_ci;
      GRANT ALL PRIVILEGES ON `wordpressdb`.* TO 'wordpressuser'@'localhost';
      flush privileges;
      exit
      

Install Wordpress

  • Install git:
    sudo apt install git
    
  • Download wordpress:
    cd /var/www
    sudo git clone -b 6.0-branch --depth=1 https://github.com/WordPress/WordPress.git
    
  • Create the nginx config:
    sudo nano /etc/nginx/sites-enabled/wordpress.conf
    
    • And add the following:
      server {
          listen       80;
          server_name  wordpress-example.com;
          root /var/www/wordpress;
          index index.php index.html index.htm;
          client_max_body_size 122400m;
      
          location / {
              try_files $uri $uri/ /index.php?q=$uri&$args;
          }
      
          error_page      500 502 503 504  /50x.html;
          location = /50x.html {
              root /usr/local/www/nginx-dist;
          }
      
          location ~ \.php$ {
              try_files $uri =404;
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $request_filename;
              include fastcgi_params;
          }
      }
      
  • Change the wordpress ownership:
    sudo chown -R www-data:www-data /var/www/WordPress/
    
  • Restart nginx:
    sudo systemctl nginx restart
    

Also available in: Atom PDF