Project

General

Profile

Support #974

Updated by Daniel Curtis over 2 years ago

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

 * Make sure the system is up to date: 
 <pre> 
 sudo apt update && sudo apt upgrade 
 </pre> 

 h2. Install Nginx 

 * Install nginx: 
 <pre> 
 sudo apt install nginx 
 </pre> 

 * Start and enable nginx at boot: 
 <pre> 
 sudo systemctl nginx enable 
 sudo systemctl nginx start 
 </pre> 

 h2. Install PHP 

 * Install php-fpm and extensions: 
 <pre> 
 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 
 </pre> 

 * Start and enable php-fpm: 
 <pre> 
 sudo systemctl enable php7.3-fpm 
 sudo systemctl start php7.3-fpm 
 </pre> 

 h2. Install MariaDB 

 * Install MariaDB: 
 <pre> 
 sudo apt install mariadb-server mariadb-client 
 </pre> 

 * Secure the database server: 
 <pre> 
 sudo mysql_secure_installation 
 </pre> 
 #* NOTE: I had an issue logging in as root, to workaround this: 
 <pre> 
 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 
 </pre> 

 h3. Configure a new MySQL database 

 
 * Log into the MySQL console: 
 <pre> 
 mysql -h localhost -u root -p 
 </pre> 
 #* Create the wordpressuser user with the SuperSecretPassword password and the wordpressdb database: 
 <pre> 
 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 
 </pre> 

 h2. Install Wordpress 

 * Install git: 
 <pre> 
 sudo apt install git 
 </pre> 

 * Download wordpress: 
 <pre> 
 cd /var/www 
 sudo git clone -b 6.0-branch --depth=1 https://github.com/WordPress/WordPress.git 
 </pre> 

 * Create the nginx config: 
 <pre> 
 sudo nano /etc/nginx/sites-enabled/wordpress.conf 
 </pre> 
 #* And add the following: 
 <pre> 
 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; 
     } 
 } 
 </pre> 

 * Change the wordpress ownership: 
 <pre> 
 sudo chown -R www-data:www-data /var/www/WordPress/ 
 </pre> 

 * Restart nginx: 
 <pre> 
 sudo systemctl nginx restart 
 </pre>

Back