Install LNMP#
First, you need to download LNMP: wget http://soft.vpser.net/lnmp/lnmp2.0.tar.gz -cO lnmp2.0.tar.gz
After the download is complete, unzip and execute: tar zxf lnmp2.0.tar.gz && cd lnmp1.5 && ./install.sh lnmp
Choose the version you want to install and press Enter to start the installation. This may take some time, please be patient. When you see the following display, it means the installation is successful.
Configure Nginx#
In the directory /usr/local/nginx/conf, check the Nginx configuration file. The line root /home/wwwroot/default;
indicates that the website's root directory is /home/wwwroot/default. You can access http://ip to view it.
If you have bound a domain name, you can configure Cloudflare's free certificate and SSL for the website.
In the Cloudflare control panel, make sure the SSL option is set to Full or Full(strict), and generate a private key (usually in .key format) and a certificate file (usually in .pem format) and place them on the server.
Inside the server block of the Nginx configuration file, add the following SSL configuration:
# Configure SSL
listen 443 ssl;
ssl_certificate /path/to/your_cloudflare_cert.pem; # Point to the Cloudflare certificate file
ssl_certificate_key /path/to/your_cloudflare_private.key; # Point to the Cloudflare private key file
After adding, verify if there are any configuration errors in Nginx: nginx -t
. Reload Nginx: nginx -s reload
Install WordPress#
Download the WordPress installation package and unzip it to /home/wwwroot: wget https://cn.wordpress.org/latest-zh_CN.zip && unzip latest-zh_CN.zip -d /home/wwwroot
Log in to MySQL, create the WordPress database, and exit after creating:
mysql -u root -p
create database wordpress;
exit
If you need to connect to the database on the server locally, you also need to perform the following configuration:
- Allow port 3306 in the firewall:
ufw allow 3306
- Create a user for remote access:
CREATE USER 'remote_user'@'%' IDENTIFIED BY 'securepassword';
- Refresh the configuration:
FLUSH PRIVILEGES;
Use vim to modify the Nginx configuration file: vim /usr/local/nginx/conf/nginx.conf
, and set the website's root directory to /home/wwwroot/wordpress. Save the file.
Modify the permissions of the WordPress directory: cd /home/wwwroot && chown -R www wordpress/ && chgrp -R www wordpress/
Use a browser to access http://ip/wp-admin/setup-config.php to start the installation.