WordPress Setup Guide on Debian 12: Nginx, PHP, and MySQL Environment Configuration

To set up WordPress, you can use a Linux system. The Linux environment can either be a virtual machine on your local computer or a server from a cloud provider. Since WordPress is developed using PHP, you’ll need to install the PHP runtime environment, as well as the web service Nginx and MySQL database.

Log in to your Linux system using an SSH tool. In this case, I’m using Debian 12.

Installing and Configuring Nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
apt update
apt install -y nginx

rm -rf /var/root/html/* # Delete the default Nginx files in the root directory
vim /etc/nginx/sites-enabled/default # Edit the Nginx configuration file

index index.html index.htm index.php; # Add index.php

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000; # Configure PHP forwarding
}

# After editing the configuration, use the following command to check if the configuration file is correct. If the following output appears, it's correct:
➜ ~ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

systemctl start nginx # Start the Nginx service
systemctl enable nginx

netstat -ntlp # Check if port 80 is listening

Installing MySQL

1
2
3
4
5
6
7
8
9
10
11
12
13
apt install -y gnupg

wget https://repo.mysql.com/mysql-apt-config_0.8.33-1_all.deb # Download the deb package

dpkg -i mysql-apt-config_0.8.33-1_all.deb # Install the apt source

apt update # Update the apt sources

apt install -y mysql-server # Install MySQL

systemctl start mysql # Start MySQL

systemctl enable mysql

Installing PHP

1
2
3
4
5
6
7
8
9
apt install -y php php-fpm php8.2-mysql php8.2-mbstring php8.2-gd php8.2-xml php8.2-curl

vim /etc/php/8.2/fpm/pool.d/www.conf # Edit this file

listen = 9000 # Add the listening port

systemctl start php8.2-fpm # Start FPM

systemctl enable php8.2-fpm

WordPress Setup Guide on Debian 12: Nginx, PHP, and MySQL Environment Configuration

https://www.avayuan.com/wordpress-linux-php-nginx-mysql/

Author

avayuan

Posted on

2024-12-27

Updated on

2025-01-20

Licensed under