To gain full control over your website environment, you can manually deploy an LNMP stack and install WordPress. This lets you flexibly build blogs and portal websites.
Preparations
Enable public access: Assign a static public IP address to the instance or associate an elastic IP address (EIP) with the instance.
Add a security group rule: In the inbound direction for the security group of the instance, allow TCP access on ports 22 and 80.
Procedure
This topic uses Alibaba Cloud Linux 3 and WordPress 6.4.4 as an example.
Step 1: Deploy an LNMP environment
Log on to the ECS instance.
Go to ECS console - Instances. In the top navigation bar, select the target region and resource group.
Go to the details page of the target instance. Click Connect and select Workbench. Follow the prompts on the page to log on to the terminal.
Install core components such as Nginx, MySQL, and PHP.
WordPress depends on specific versions of PHP and MySQL. A version mismatch will cause the WordPress installation to fail. For more information about dependencies, see WordPress Compatibility.
Step 2: Create a WordPress database
Create a dedicated database and database user for WordPress.
Log on to MySQL. Use the database password that you set when you deployed the LNMP environment.
mysql -u root -pCreate a database and a user, and then grant permissions.
Record the database name, username, and password for later use.
-- Create a database named WORDPRESS_DATABASE CREATE DATABASE WORDPRESS_DATABASE; -- Create a dedicated user WORDPRESS_USER and set a password. We recommend that you set a strong password that is at least 12 characters long and contains uppercase letters, lowercase letters, digits, and special characters. CREATE USER '<span class="var-span" contenteditable="true" data-var="WORDPRESS_USER">WORDPRESS_USER'</span>@'localhost' IDENTIFIED BY '<span class="var-span" contenteditable="true" data-var="WORDPRESS_PASSWORD">WORDPRESS_PASSWORD'</span>; -- Grant this user all privileges on the wordpress database GRANT ALL PRIVILEGES ON wordpress.* TO '<span class="var-span" contenteditable="true" data-var="WORDPRESS_USER">WORDPRESS_USER'</span>@'localhost'; -- Flush privileges to apply the settings FLUSH PRIVILEGES; -- Exit MySQL EXIT;By default, the password validation plugin is installed in MySQL 5.7 and later. The password must be 8 to 30 characters long and contain uppercase letters, lowercase letters, digits, and special characters. Supported special characters include
()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/.
Step 3: Download and configure WordPress
Go to the Nginx website 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.zip. In the subsequent steps, you must also replace the compressed package name withwordpress-6.4.4.zip.sudo cd /usr/share/nginx/html sudo wget https://cn.wordpress.org/wordpress-6.4.4-zh_CN.zipInstall the
unzipcommand and decompress the WordPress package.sudo yum install unzip -y sudo unzip wordpress-6.4.4-zh_CN.zipCopy the
wp-config-sample.phpfile towp-config.phpand keep the original file as a backup.cd /usr/share/nginx/html/wordpress sudo cp wp-config-sample.php wp-config.phpEdit the configuration file. Enter the database information that you created in Step 2, including the database name, username, and password.
sudo vim wp-config.phpPress the
ikey to enter edit mode./** The name of the database for WordPress */ define('DB_NAME', '<span class="var-span" contenteditable="true" data-var="WORDPRESS_DATABASE">WORDPRESS_DATABASE'</span>); /** MySQL database username */ define('DB_USER', '<span class="var-span" contenteditable="true" data-var="WORDPRESS_USER">WORDPRESS_USER'</span>); /** MySQL database password */ define('DB_PASSWORD', '<span class="var-span" contenteditable="true" data-var="WORDPRESS_PASSWORD">WORDPRESS_PASSWORD'</span>); /** MySQL hostname */ define('DB_HOST', 'localhost');After you make the changes, press the
Esckey, enter:wq, and press theEnterkey to save the file and exit.
Step 4: Configure Nginx
Modify the default site configuration of Nginx to 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.confModify the Nginx configuration file.
Press the
ikey to enter edit mode. In theserverandlocation ~ .php$blocks, replace the content afterrootwith the WordPress root directory. In this example, the WordPress root directory is/usr/share/nginx/html/wordpress.
Press the
Esckey, enter:wq, and then press theEnterkey to save and exit the configuration file.Check the configuration syntax.
If
syntax is okis displayed, you can restart Nginx.sudo nginx -tIf a syntax error is reported, you can run
sudo mv /etc/nginx/conf.d/default.conf.bak /etc/nginx/conf.d/default.confto restore the default configuration.Restart Nginx to apply the configuration.
sudo systemctl restart nginx
Step 5: Install and log on to the WordPress website
After you complete the server-side configuration, you must use a browser to initialize WordPress.
On your local machine, open a browser and go to
http://<Public IP address of the ECS instance>to access the WordPress installation page.Enter the basic information for the website, including Site Title, administrator Username, Password, and Your Email. Then, click Install WordPress.
After the installation is complete, click Log In. Use the username and password that you set in the previous step to log on.
A successful logon indicates that the WordPress website is built and running. For more information, see the official WordPress documentation.
What to do next
Manage files using FTP
To upload WordPress themes or plugins using FTP, you must build an FTP site on a Linux instance.
Resolve a domain name and configure HTTPS
Accessing your website using its IP address is unprofessional and insecure. We recommend that you associate a domain name with your website and enable HTTPS encryption.
Register a domain name and apply for an ICP filing
If you do not have a domain name, you can register a domain name on Alibaba Cloud.
If your website is hosted on an Alibaba Cloud server in the Chinese mainland, you must apply for an ICP filing for the domain name.For more information, see ICP filing process.
Resolve the domain name to the public IP address of the ECS instance.
Replace the public IP address of the instance with the new domain name.
Remotely connect to the instance and log on to the MySQL database.
mysql -u root -pSwitch to the WordPress database and set the domain name.
Replace
public_ipwith the public IP address of the instance 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)
Deploying an SSL certificate enables HTTPS-encrypted data transfer for your website. This protects user privacy and improves browser trust and search engine optimization (SEO) rankings.
FAQ
Why can't I access WordPress using the public IP address?
Check security groups: Confirm that port 80 is allowed in the security group of the instance.
Check the firewall: Confirm that the internal firewall of the operating system, such as firewalld, is not blocking port 80.
Check service status: On the ECS instance, run
sudo systemctl status nginxandsudo systemctl status php-fpmto make sure the services are in theactive (running)state.Check port listening: Confirm that port 80 is being listened on.
For more information about how to troubleshoot the issue, see What do I do if I cannot access a service deployed on an instance?.
Why are pages inaccessible after I set permalinks in WordPress?
Making your website static helps search engines index it. Before you set permalinks for your WordPress site, you must first set static rules in the Nginx server.
Remotely connect to the instance and open the Nginx configuration file.
sudo vim /etc/nginx/conf.d/default.confPress the
ikey to enter edit mode. In thelocation /block, add the following code.try_files $uri $uri/ /index.php?$args;Press the
Esckey, enter:wq, and then press theEnterkey to save and exit the configuration file.Restart the Nginx service to apply the configuration.
sudo systemctl restart nginx
Why am I prompted for FTP logon credentials or told that a directory cannot be created when I update WordPress or upload themes or plugins?
This issue may occur because the permissions for the WordPress configuration file, themes, or plugins are insufficient. You can follow these steps to resolve the issue.
Log on to the ECS instance and open the WordPress configuration file.
sudo vim /usr/share/nginx/html/wordpress/wp-config.phpPress the
ikey to enter edit mode. At the bottom of the file, add the following code.define("FS_METHOD","direct"); define("FS_CHMOD_DIR", 0777); define("FS_CHMOD_FILE", 0777);Press the
Esckey, enter:wq, and then press theEnterkey to save and exit the configuration file.Return to the WordPress dashboard and refresh the page. This should resolve the issue of being prompted for FTP logon credentials.
If the issue of being unable to create a directory persists, change the user who has permissions on the website root directory to the Nginx user
nginx.sudo chown -R nginx /usr/share/nginx/html/wordpress
How do I change the default username and password of the MySQL 5.7 database in a WordPress image?
Remotely connect to the ECS instance and log on to the MySQL database.
mysql -u root -pGo to the
mysqldatabase and view the username.use mysql; select user from mysql.user;Change the username and password of the database.
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 to apply the changes and then exit the MySQL database.
FLUSH PRIVILEGES; EXIT;
References
To deploy WordPress in Docker, see Use Docker Compose to deploy an application.
To build multiple websites on a single ECS instance, see Use Nginx to configure multiple websites.