To gain full control over your website environment, manually deploy an LNMP stack and install WordPress to build a flexible blog or web portal.
Prerequisites
-
Enable public access: Assign a static public IP address or bind an Elastic IP Address (EIP) to the ECS instance.
-
Add a security group rule: Allow inbound traffic on TCP ports 22 and 80 in the security group of the instance.
Procedure
This tutorial uses Alibaba Cloud Linux 3 to demonstrate how to deploy WordPress 6.4.4.
Step 1: Deploy the LNMP environment
Log on to an ECS instance.
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target instance.
Navigate to the details page of the target instance. Click Connect and select Workbench. Follow the on-screen prompts to access the terminal.
-
This installs core components such as Nginx, MySQL, and PHP.
WordPress depends on specific PHP and MySQL versions. A version mismatch will cause the WordPress installation to fail. For details, see WordPress Compatibility.
Step 2: Create the WordPress database
Create a dedicated database and database user for WordPress.
-
Log on to MySQL. Use the database password you set during the LNMP deployment.
mysql -u root -p -
Create the database and user, and grant privileges.
Record the database name, username, and password for later use.
-- Create a database named wordpress. CREATE DATABASE WORDPRESS_DATABASE; -- Create a dedicated user named wordpress_user and set a password. Use a strong password that is at least 12 characters long and contains uppercase letters, lowercase letters, digits, and special characters. CREATE USER 'WORDPRESS_USER'@'localhost' IDENTIFIED BY 'WORDPRESS_PASSWORD'; -- Grant all privileges on the wordpress database to the user. GRANT ALL PRIVILEGES ON wordpress.* TO 'WORDPRESS_USER'@'localhost'; -- Flush the privileges to apply the changes. FLUSH PRIVILEGES; -- Exit MySQL. EXIT;In MySQL 5.7 and later, the password validation plugin is installed by default. Password rules: 8 to 30 characters, and must include uppercase letters, lowercase letters, digits, and special characters. The allowed special characters are
()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/.
Step 3: Download and configure WordPress
-
Go to the Nginx web root directory and download the Chinese version of WordPress 6.4.4.
To install the English version of WordPress, replace the URL with
https://wordpress.org/wordpress-6.4.4.zipand replace the name of the zip file withwordpress-6.4.4.zipin the following unzip step.sudo cd /usr/share/nginx/html sudo wget https://cn.wordpress.org/wordpress-6.4.4-zh_CN.zip -
Install the
unzipcommand and decompress the WordPress zip file.sudo yum install unzip -y sudo unzip wordpress-6.4.4-zh_CN.zip -
Copy the
wp-config-sample.phpfile to create awp-config.phpfile, and keep the original file as a backup.cd /usr/share/nginx/html/wordpress sudo cp wp-config-sample.php wp-config.php -
Edit the configuration file and enter the database information from Step 2, including the database name, username, and password.
sudo vim wp-config.phpPress
ito enter Insert mode./** The name of the database for WordPress */ define('DB_NAME', 'WORDPRESS_DATABASE'); /** MySQL database username */ define('DB_USER', 'WORDPRESS_USER'); /** MySQL database password */ define('DB_PASSWORD', 'WORDPRESS_PASSWORD'); /** MySQL hostname */ define('DB_HOST', 'localhost');After you finish, press
Esc, type:wq, and pressEnterto save and exit.
Step 4: Configure Nginx
Modify the default Nginx site configuration so that it can correctly handle PHP requests.
-
Back up the default configuration and create a new Nginx configuration file.
sudo mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak sudo vim /etc/nginx/conf.d/default.conf -
Modify the Nginx configuration file.
Press
ito enter Insert mode. In theserverandlocation ~ .php$blocks, replace the value afterrootwith the WordPress root directory. In this example, the WordPress root directory is/usr/share/nginx/html/wordpress.
Press
Esc, type:wq, and pressEnterto save and exit. -
Check the configuration syntax.
If the
syntax is okmessage appears, restart Nginx.sudo nginx -tIf a syntax error is reported, you can run the
sudo mv /etc/nginx/conf.d/default.conf.bak /etc/nginx/conf.d/default.confcommand to restore the default configuration. -
Restart Nginx for the configuration to take effect.
sudo systemctl restart nginx
Step 5: Install WordPress and log in
After completing the server configuration, initialize WordPress in your browser.
-
On your local computer, open a browser and visit
http://<Public IP address of the ECS instance>to go to the WordPress installation page. -
Fill in the basic information for your website, including the Site Title, administrator User Name, Password, and Your Email, and then click Install WordPress.
-
After the installation is complete, click Log In and use the username and password that you set in the previous step to log in.
If you can log in, your WordPress site is up and running. For more information, see the WordPress getting started guide.
Next steps
Manage files via FTP
To upload WordPress themes or plugins via FTP, you need to build an FTP site on Linux.
Set up domain resolution and configure HTTPS
Using an IP address to access a website is unprofessional and insecure. We recommend that you point a domain name to your website and enable HTTPS encryption.
-
Register a domain name and complete ICP filing
-
If you do not have a domain name, you can register a domain name with Alibaba Cloud.
-
If your domain name points to a website hosted on an Alibaba Cloud server in the Chinese mainland, you must complete an ICP filing.To apply for an ICP filing for the first time, see the ICP filing process. For other scenarios, see the ICP filing process.
-
-
Point your domain name to the public IP address of your ECS instance.
-
Replace the public IP address of the instance with your new domain name.
-
Connect to the instance and log on to the MySQL database.
mysql -u root -p -
Switch to the WordPress database and set the domain name.
Replace
PUBLIC_IPwith the instance's public IP address andDOMAINwith your domain name.use wordpress; UPDATE wp_options SET option_value = replace(option_value, 'http://PUBLIC_IP', 'http://DOMAIN') where option_name = 'home' OR option_name = 'siteurl'; EXIT;
-
-
Configure an SSL certificate (HTTPS)
Deploy an SSL certificate to enable HTTPS and encrypt data in transit, protect user privacy, and improve browser trust and SEO rankings.
FAQ
Cannot access WordPress with public IP?
-
Check the security group: Confirm that the instance security group allows inbound traffic on port 80.
-
Check the firewall: Confirm that the OS firewall (such as firewalld) does not block port 80.
-
Check service status: Run
sudo systemctl status nginxandsudo systemctl status php-fpmon the ECS instance, and make sure both services areactive (running). -
Check port listening: Confirm that a service is listening on port 80.
For detailed troubleshooting steps, see Troubleshoot issues when you cannot access services on an ECS instance.
Permalink settings break page access?
To improve how search engines index your site, use static URLs. Before setting permalinks in WordPress, you must add a rewrite rule to your Nginx configuration.
-
Connect to the instance and open the Nginx configuration file.
sudo vim /etc/nginx/conf.d/default.confPress
ito enter Insert mode. In thelocation /block, add the following line.try_files $uri $uri/ /index.php?$args;Press
Esc, type:wq, and pressEnterto save and exit. -
Restart Nginx to apply the changes.
sudo systemctl restart nginx
FTP credentials or directory errors during updates?
Insufficient file permissions for the WordPress configuration file, themes, or plugins usually cause this issue. Use the following steps to fix it.
-
Log on to the ECS instance and open the WordPress configuration file.
sudo vim /usr/share/nginx/html/wordpress/wp-config.phpPress
ito enter Insert mode. At the end of the file, add the following lines.define("FS_METHOD","direct"); define("FS_CHMOD_DIR", 0777); define("FS_CHMOD_FILE", 0777);Press
Esc, type:wq, and pressEnterto save and exit. -
Return to the WordPress dashboard and refresh the page to fix the FTP credentials prompt.
If the "unable to create directory" issue persists, change the owner of the web root directory to the Nginx user
nginx.sudo chown -R nginx /usr/share/nginx/html/wordpress
Change the MySQL username and password
-
Connect to the ECS instance and log on to MySQL.
mysql -u root -p -
Switch to the
mysqldatabase and view the usernames.use mysql; select user from mysql.user; -
Change the database username and password.
-
Change the database username to a new username.
UPDATE user SET user='NEW_USER_NAME' WHERE user='USER_NAME';For example, to change the username from
roottoadmin:UPDATE mysql.user SET user='admin' WHERE user='root'; -
Change the password of the database user.
ALTER USER 'USER_NAME'@'localhost' IDENTIFIED BY 'PASSWORD';For example, to change the password of the
rootuser toPassword@2025!:ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password@2025!';
-
-
Flush the privileges for the changes to take effect and exit the MySQL database.
FLUSH PRIVILEGES; EXIT;
References
-
To deploy WordPress in Docker, see Deploy an application by using Docker Compose.
-
To install WordPress in Baota Panel, see Manually deploy Baota Panel.
-
To host multiple websites on a single ECS instance, see Configure multiple websites with Nginx.