Current Location: Home> Latest Articles> How to Deploy and Run PHP Mini Program Backend: LNMP and WNMP Environment Setup Guide

How to Deploy and Run PHP Mini Program Backend: LNMP and WNMP Environment Setup Guide

gitbox 2025-07-01

Introduction to LNMP and WNMP Environments

LNMP refers to a server environment configuration consisting of Linux, Nginx, MySQL, and PHP, often used to set up and run PHP mini program backends. WNMP, on the other hand, is the equivalent setup for Windows, which uses Windows OS along with Nginx, MySQL, and PHP for deployment.

Deploying LNMP on Linux

Installing Linux OS

Start by ensuring that a Linux operating system is installed on your server. Common choices include Ubuntu and CentOS. Once installed, perform system updates and complete the basic configurations.

Installing Nginx

Run the following commands to install Nginx:

sudo apt-get update
sudo apt-get install nginx

Once installed, enable Nginx to start automatically on boot and start the Nginx service:

sudo systemctl enable nginx
sudo systemctl start nginx

Installing MySQL

Install MySQL with the following commands:

sudo apt-get install mysql-server
sudo mysql_secure_installation

During the installation, you will be prompted to set the root password and perform some security configurations.

Installing PHP

Install PHP and related modules by running the following command:

sudo apt-get install php-fpm php-mysql

Next, edit the PHP configuration file `php.ini` to set the following common configurations:

cgi.fix_pathinfo=0
upload_max_filesize=32M
post_max_size=32M
date.timezone=Asia/Shanghai

After saving and exiting the editor, restart the PHP-FPM service to apply the changes:

sudo systemctl restart php7.4-fpm

Deploying WNMP on Windows

Downloading Nginx

Go to the official Nginx website and download the Windows version of the installer, then extract it to a designated directory.

Installing MySQL

Download the MySQL installer from the official website and follow the installation wizard to complete the setup.

Installing PHP

Download the PHP Windows installer package, extract it to a designated directory, and configure the `php.ini` file accordingly.

Conclusion

LNMP and WNMP are popular server environment configurations for deploying and running PHP mini program backends. Whether using a Linux or Windows system, by installing and configuring Nginx, MySQL, and PHP, you can create a stable and efficient server environment for development. This setup provides robust support for backend operations, ensuring smooth and reliable performance for PHP mini programs.