Tencent Cloud provides developer lab to help users build personal WordPress blogs. The tutorial content is as follows. Users can click the developer lab to quickly complete the experiment on the computer.

The screenshots

Prepare the LNMP environment

Task duration: 30 to 60 minutes

LNMP stands for Linux, Nginx, MySQL, and PHP. It is the basic running environment on which the WordPress blogging system relies. Let’s prepare the LNMP environment first

Install Nginx

Install Nginx with yum:

yum install nginx -yCopy the code

Modify/etc/nginx/conf. D/default. Conf, removal of IPv6 address to monitor, refer to the following sample:

The sample code: / etc/nginx/conf. D/default. Conf
server {
    listen       80 default_server;
    # listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

}Copy the code

Start Nginx:

nginxCopy the code

At this point, access the experimental machine’s external HTTP service (http://< your CVM IP address) to verify that the installation is successful.

Set Nginx to start automatically upon startup:

chkconfig nginx onCopy the code

CentOS 6 does not support IPv6. You must disable IPv6 address listening; otherwise, Nginx cannot start successfully.

MySQL installation

MySQL > install MySQL with yum

yum install mysql-server -yCopy the code

After installation, start MySQL service:

service mysqld restartCopy the code

Change the password of user root for MySQL.

/usr/bin/mysqladmin -u root password 'MyPas$word4Word_Press'Copy the code

MySQL > set MySQL to automatically start upon startup:

chkconfig mysqld onCopy the code

The passwords in the following commands are automatically generated for you by the tutorial. For the sake of the experiment, it is not recommended to use other passwords. If you set a different password, remember the password and use it in the following steps.

Installing PHP

Install PHP with yum:

yum install php-fpm php-mysql -yCopy the code

After installation, start the php-fpm process:

service php-fpm startCopy the code

Once started, you can use the following command to see which port the PHP-fpm process listens on

netstat -nlpt | grep php-fpmCopy the code

Set phP-fpm to automatically start upon startup:

chkconfig php-fpm onCopy the code

By default, php-fpm and php-mysql are installed on CentOs 6.

Php-fpm listens on port 9000 by default

Install and configure WordPress

Task duration: 30 to 60 minutes

The installation of WordPress

Install WordPress with yum:

yum install wordpress -yCopy the code

Once installed, you can see the wordpress source code at /usr/share/wordpress.

Configuring the Database

Enter the MySQL:

mysql -uroot --password='MyPas$word4Word_Press'Copy the code

Create a database for WordPress:

CREATE DATABASE wordpress;Copy the code

MySQL > set up MySQL

exitCopy the code

To synchronize the above DB configuration to the WordPress configuration file, see the following configuration:

Example code: /etc/wordpress/wp-config.php
<? php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the * installation. You don't have to use the web site, you can * copy this file to "wp-config.php" and fill in the values. * * This file contains the following configurations:  * * * MySQL settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://codex.wordpress.org/Editing_wp-config.php * * @package WordPress */ // ** MySQL settings - You can get this info  from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpress'); /** MySQL database username */ define('DB_USER', 'root'); /** MySQL database password */ define('DB_PASSWORD', 'MyPas$word4Word_Press'); /** MySQL hostname */ define('DB_HOST', 'localhost'); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', ''); /**#@+ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! * You can generate these using the {@ link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret - key service} * You can change these at any point in time to invalidate all existing cookies. This will force all users to Have to log in again. * * @since 2.6.0 */ define('AUTH_KEY', 'put your unique phrase here'); define('SECURE_AUTH_KEY', 'put your unique phrase here'); define('LOGGED_IN_KEY', 'put your unique phrase here'); define('NONCE_KEY', 'put your unique phrase here'); define('AUTH_SALT', 'put your unique phrase here'); define('SECURE_AUTH_SALT', 'put your unique phrase here'); define('LOGGED_IN_SALT', 'put your unique phrase here'); define('NONCE_SALT', 'put your unique phrase here'); /**#@-*/ /** * WordPress Database Table prefix. * * You can have multiple installations in one database if you give each  * a unique prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_'; /** * See http://make.wordpress.org/core/2013/10/25/the-definitive-guide-to-disabling-auto-updates-in-wordpress-3-7 */ /* Disable all file change, as RPM base installation are read-only */ define('DISALLOW_FILE_MODS', true); /* Disable automatic updater, in case you want to allow above FILE_MODS for plugins, themes, ... */ define('AUTOMATIC_UPDATER_DISABLED', true); /* Core update is always disabled, WP_AUTO_UPDATE_CORE value is ignore */ /** * For developers: WordPress debugging mode. * * Change this to true to enable the display of notices during development. * It is strongly recommended that plugin and theme developers use WP_DEBUG * in their development environments. * * For information on other constants that can be used for debugging, * visit the Codex. * * @link https://codex.wordpress.org/Debugging_in_WordPress */ define('WP_DEBUG', false); /* That's all, stop editing! Happy blogging. */ /** Absolute path to the WordPress directory. */ if ( ! defined('ABSPATH') ) define('ABSPATH', '/usr/share/wordpress'); /** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php');Copy the code

If you did not use the password created in this tutorial, change the password in the command below to log in

Configure Nginx

With WordPress installed, we configure Nginx to forward requests to PHP-FPM for processing

First, rename the default configuration file:

cd /etc/nginx/conf.d/
mv default.conf defaut.conf.bakCopy the code

To create a wordpress.conf configuration in /etc/nginx/conf.d, refer to the following:

The sample code: / etc/nginx/conf. D/wordpress. Conf
server { listen 80; root /usr/share/wordpress; location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php index.php; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~.php${fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}Copy the code

After configuration, notify Nginx process to reload:

nginx -s reloadCopy the code

The default Server listens on port 80, conflicts with the WordPress service port, rename it to the.bak suffix to disable the default configuration

Prepare domain name and resolution

Task duration: 15 to 30 minutes

Domain name registration

If you don’t have a domain name, you can buy it on Tencent Cloud, and the process can be seen in the video below.

  • Video – Buy domain name on Tencent Cloud

Domain name resolution

After the domain name is purchased, the domain name needs to be resolved to the experimental cloud host. The IP address of the experimental cloud host is:

< your CVM IP address >Copy the code

The domain name purchased in Tencent Cloud can be added to the console for parsing records. The process can be referred to the following video:

  • Video – How to resolve domain name on Tencent Cloud

The domain name takes effect after being resolved. Run the ping command to check whether the domain name takes effect. For example:

ping www.yourdomain.comCopy the code

If the ping command returns the IP address that you set, the IP address is successfully resolved.

Note the substitution in the following command
www.yourmpdomain.comDomain name for your own registration

And you’re done!

Congratulations, your WordPress blog has been deployed. You can visit the blog through your browser to see the results.

By IP address:

This blog can be accessed at http://< your domain name >/wp-admin/install.php

View by domain name:

Blog access address: http://www.yourdomain.com/wp-admin/install.php, which replace www.yourdomain.com before the application domain.