Build multiple WordPress websites on Alibaba Cloud simple application server

 I. Introduction

First of all, Alibaba Cloud simple application servers are divided into different application images and system images. The image environment in this article is the WordPress image, and the system default is Alibaba Cloud Linux. If you choose other system images, you need to manually install the WordPress environment yourself. 

Application images (13 models) provide options such as WordPress, LAMP, Docker, and Node.js, which reduce the uploading and installation of applications and enable applications to be used out of the box. System image (8 models) is suitable for users who are familiar with operating system and application environment configuration. System image provides a pure initial operating system environment, and you can install applications by yourself as needed.

In other words, this article is about building a second WordPress website when there is already a WordPress website. Other system environments are for reference only; using this method, you can build the third and fourth WordPress websites in sequence, as long as the server configuration allows it.

There are basically three steps, first: Install WordPress for your new website. Second: Configure the database for the new website. Third: Configure Nginx.

Note⚠️: Create a snapshot backup before proceeding, just in case.

2. Install WordPress

The default installation path of the first website is /data/wwwroot/wordpress, so after we connect to the server, we first create a folder for the new website.

          mkdir /data/wwwroot/site2/

Then download WordPress.

          cd /data/wwwroot/site2/

          wget https://wordpress.org/latest.tar.gz

Unzip the WordPress installation package.

          tar -xzvf latest.tar.gz

At this time, under the site2 path, there is a WordPress installation package latest.tar.gz and the decompressed WordPress directory; first delete the installation package latest.tar.gz, and then enter the WordPress directory.

          rm latest.tar.gz

          cd wordpress/

3. Configure the database

          mysql -u root -p

The database password can be viewed using the sudo cat /root/ReadMe command; configure the database after entering the password.

          create database wp_site2 default character set utf8 collate utf8_unicode_ci;

          grant all on wp_site2.* to 'user_site2'@'localhost' identified by 'password';

          flush privileges;

          exit

For the above identified by ‘password’, it is best to set a more complex password and write it down.

Make a copy of the WordPress configuration file and edit it.

          cp wp-config-sample.php wp-config.php

          vim wp-config.php

Modify the database name, username and password in sequence.(Password here is the password set above)

Continue to scroll down, delete the content in the red box, copy the link pointed by the arrow and open it in the browser, select all the content in the web page, and replace it with the original position of the red box.





4. Configure Nginx files

The Nginx configuration file is in the /usr/local/nginx/conf/vhost/ path by default. There is already a wordpress.conf file in this directory; first we edit this file.

          cd /usr/local/nginx/conf/vhost/

          vim wordpress.conf

The default configuration file Server is empty, change it to server_name site1.com www.site1.com; site1 here should be the domain name of the first website you built.



The default path does not need to be changed; then copy the configuration file and edit it.

          cp wordpress.conf site2.conf

          vim site2.conf

The server_name here is changed to site2.com www.site2.com; the site2 here is the domain name of the second website you built. The path here is modified to: root /data/wwwroot/site2/wordpress;

After the modification is completed, test it:

          nginx -t

As shown in the picture, if it prompts successful, then there is no problem.



Restart the Nginx service.

          systemctl restart nginx

Finally, you can enter site2.com in the browser to complete the WordPress installation.



5. Error message when installing plug-in: Failed to connect to FTP server

Executing the following command can solve the problem:

          chown -R www /data/wwwroot/site2/wordpress

6. This article refers to the following YouTube video, and according to the AliCloud Simple Application Server WordPress mirror environment to make some changes. 



Post a Comment

0 Comments