For full control over your website, manually deploy an LNMP stack and install WordPress. This approach allows you to build a blog, portal, or other types of websites.
Prerequisites
-
Enable public access: Assign a public IP address or associate an elastic IP address (EIP) with the instance.
-
Add a security group rule: Allow inbound traffic over TCP on ports 22 and 80 in the security group of your instance.
Procedure
The following steps show how to deploy WordPress 6.4.4 on an Alibaba Cloud Linux 3 instance.
Step 1: Deploy the LNMP stack
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.
-
Install core components such as Nginx, MySQL, and PHP.
WordPress depends on specific versions of PHP and MySQL. A version mismatch will cause the installation to fail. For details, see WordPress Compatibility.
Step 2: Create a WordPress database
Create a dedicated database and database user for WordPress.
-
Log on to MySQL. Use the password you set for the database when you deployed the LNMP stack.
mysql -u root -p -
Create a database and user, and grant privileges.
Make a note of the database name, username, and password for later use.
-- Create the WordPress database. CREATE DATABASE WORDPRESS_DATABASE; -- Create a dedicated user and set a password. We recommend a strong password of at least 12 characters, containing uppercase and lowercase letters, numbers, and special symbols. CREATE USER 'WORDPRESS_USER'@'localhost' IDENTIFIED BY 'WORDPRESS_PASSWORD'; -- Grant this user all privileges on the WordPress database. GRANT ALL PRIVILEGES ON WORDPRESS_DATABASE.* TO 'WORDPRESS_USER'@'localhost'; -- Flush the privileges to apply the changes. FLUSH PRIVILEGES; -- Exit MySQL. EXIT;In MySQL 5.7 and later, the password strength validation plugin is installed by default. Passwords 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 web root directory and download the Chinese version of WordPress 6.4.4.
To install the English version, replace the URL with
https://wordpress.org/wordpress-6.4.4.zip. In later steps, replace the archive name withwordpress-6.4.4.zip.sudo cd /usr/share/nginx/html sudo wget https://cn.wordpress.org/wordpress-6.4.4-zh_CN.zip -
Install
unzipand extract the WordPress archive.sudo yum install unzip -y sudo unzip wordpress-6.4.4-zh_CN.zip -
Copy the
wp-config-sample.phpfile towp-config.php, keeping the original 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 name, username, and password you created in Step 2.
sudo vim wp-config.phpPress the
ikey to enter Insert mode./** The name of the database for WordPress */ define('DB_NAME', 'WORDPRESS_DATABASE'); /** Database username */ define('DB_USER', 'WORDPRESS_USER'); /** Database password */ define('DB_PASSWORD', 'WORDPRESS_PASSWORD'); /** Database hostname */ define('DB_HOST', 'localhost');After you make the changes, press the
Esckey, enter:wq, and then pressEnterto save and exit.
Step 4: Configure Nginx
Modify the default Nginx site configuration 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.conf -
Modify the Nginx configuration file.
Press the
ikey to 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.server { listen 80; server_name localhost; root /usr/share/nginx/html/wordpress; location / { index index.php index.html index.htm; } location ~ .php$ { root /usr/share/nginx/html/wordpress; fastcgi_pass unix:/run/php-fpm/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }Press the
Esckey, enter:wq, and then press theEnterkey to save and exit the configuration file. -
Check the configuration syntax.
If the output shows
syntax is ok, you can safely restart the service.sudo nginx -tIf a syntax error is reported, you can restore the default configuration by running
sudo mv /etc/nginx/conf.d/default.conf.bak /etc/nginx/conf.d/default.conf. -
Restart Nginx to apply the configuration.
sudo systemctl restart nginx
Step 5: Install and log in to WordPress
After completing the server-side configuration, you must complete the WordPress setup in your web browser.
-
In a web browser on your local computer, go to
http://<Public IP address of your ECS instance>to access the WordPress installation page. -
Enter your site information, including Site Title, administrator User Name, Password, and Your Email, and then click Install WordPress.
-
After the installation is complete, click Log In, and log in with the username and password you set in the previous step.
A successful login confirms that your WordPress site is running. For more information, see the official WordPress documentation.
Next steps
Manage files with FTP
To upload WordPress themes or plugins using FTP, you first need to build an FTP site (Linux).
Configure a domain name and HTTPS
Accessing your site via a public IP address is insecure and not recommended for production environments.
-
Register a domain name and complete an ICP filing
-
If you do not have a domain name, you can register one 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. For first-time filing, see ICP filing process. For other cases, see ICP filing process.
-
-
Point your domain name to the public IP address of your ECS instance.
-
Replace the instance public IP address with your new domain name.
-
Remotely 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 your instance's public IP address andDOMAINwith your domain name.use WORDPRESS_DATABASE; 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, to protect user privacy, enhance browser trust, and improve SEO rankings.
FAQ
Can't access WordPress with public IP?
-
Check the security group: Confirm that port 80 is allowed in the instance's security group rules.
-
Check the firewall: Make sure the operating system's internal firewall (like firewalld) is not blocking port 80.
-
Check service status: On the ECS instance, run
sudo systemctl status nginxandsudo systemctl status php-fpmto ensure the services are in anactive (running)state. -
Check port listening: Confirm that a service is listening on port 80.
For detailed troubleshooting methods, see Troubleshoot issues when a service on an ECS instance is inaccessible.
"Not Found" error with permalinks?
Using static-like URLs improves search engine optimization. Before setting permalinks in WordPress, you must first configure a rewrite rule on your Nginx server.
-
Connect to your instance and open the Nginx configuration file.
sudo vim /etc/nginx/conf.d/default.confPress the
ikey to enter Insert mode. Inside thelocation /block, add the following line.try_files $uri $uri/ /index.php?$args;Press the
Esckey, enter:wq, and then press theEnterkey to save and exit the file. -
Restart the Nginx service to apply the changes.
sudo systemctl restart nginx
FTP or permission errors during updates?
This issue is typically due to insufficient file permissions for the WordPress configuration, themes, or plugins. Follow these steps to resolve it.
-
Log on to your ECS instance and open the WordPress configuration file.
sudo vim /usr/share/nginx/html/wordpress/wp-config.phpPress the
ikey to enter Insert mode and add the following lines at the end of the file.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 your WordPress dashboard and refresh the page. This action should resolve the FTP credential prompt.
If you still see a "could not create directory" error, update the owner of the web root directory to the Nginx user, which is
nginx.sudo chown -R nginx /usr/share/nginx/html/wordpress
Change default MySQL user and password?
-
Remotely connect to your ECS instance and log on to the MySQL database.
mysql -u root -p -
Switch to the
mysqldatabase and view the current usernames.use mysql; select user from mysql.user; -
Change the database username and password.
-
Change the database 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 user's password.
ALTER USER 'USER_NAME'@'localhost' IDENTIFIED BY 'PASSWORD';For example, to change the password for the
rootuser toPassword@2025!:ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password@2025!';
-
-
Flush the privileges to apply the changes, then exit the MySQL database.
FLUSH PRIVILEGES; EXIT;
Related topics
-
To deploy WordPress in Docker, see Deploy applications with Docker Compose.
-
To install WordPress using BT-Panel, see Manually deploy BT-Panel.
-
To host multiple websites on a single ECS instance, see Configure multiple sites on Nginx.