Preparing the LNMP environment
Task time: 30 min to 60 min
LNMP is the abbreviation of Linux, Nginx, MySQL and PHP. It is the basic running environment that WordPress blog system depends on. Let's prepare the LNMP environment first.
Install Nginx
Install Nginx using yum:
yum install nginx -y
Modify / etc/nginx/conf.d/default.conf to remove IPv6 address monitoring[? ] Refer to the following example:
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 { } }
After the modification is completed, start Nginx:
nginx
At this point, the HTTP service of the experimental machine's extranet can be accessed.( Http://<your CVM IP address> ) To confirm that the installation has been successful.
Set Nginx to boot automatically:
chkconfig nginx on
CentOS 6 does not support IPv6 and needs to cancel the IPv6 address monitoring, otherwise Nginx cannot start successfully.
Install MySQL
Use yum to install MySQL:
yum install mysql-server -y
After installation, start MySQL service:
service mysqld restart
Set MySQL account root password:[?]
/usr/bin/mysqladmin -u root password 'MyPas$word4Word_Press'
Set MySQL to boot automatically:
chkconfig mysqld on
The passwords in the following commands are automatically generated for you by the tutorial. For the convenience of the experiment, it is not recommended to use other passwords. If you set other passwords, remember them and use them in subsequent steps.
Install PHP
Use yum to install PHP:.[?]
yum install php-fpm php-mysql -y
After installation, start the PHP-FPM process:
service php-fpm start
After startup, you can use the following command to see which port the PHP-FPM process is listening on[?]
netstat -nlpt | grep php-fpm
Set PHP-FPM to boot automatically:
chkconfig php-fpm on
By default, CentOs 6 has installed PHP-FPM and PHP-MYSQL. The following commands may prompt installation.
PHP-FPM defaults to listen on port 9000
Install and configure WordPress
Task time: 30 min to 60 min
Install WordPress
After configuring the LNMP environment, continue to use yum to install WordPress:
yum install wordpress -y
When the installation is complete, you can see the source code of WordPress in / usr/share/wordpress.
Configure the database
Enter MySQL::[?]
mysql -uroot --password='MyPas$word4Word_Press'
Create a database for WordPress:
CREATE DATABASE wordpress;
When the MySQL section is set up, we exit the MySQL environment:
exit
To synchronize the above DB configuration to the WordPress configuration file, you can refer to the following configuration:
Sample 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');
If you did not use the password created by the tutorial in the previous step, please modify the password login in the following command
Configure Nginx
WordPress has been 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.bak
Create wordpress.conf configuration at / etc/nginx/conf.d, refer to the following:
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; } }
After configuration, notify the Nginx process to reload:
nginx -s reload
The default Server listens on port 80, which conflicts with WordPress's service port and renames it to the. bak suffix to disable the default configuration
Preparing domain names and parsing
Task time: 15 to 30 minutes
Domain name registration
If you don't have a domain name, you can Buy on Tencent Cloud The process can be referred to in the video below.
- Video - Buying Domain Names 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 of the experimental cloud host is:
<Your CVM IP address>
In the domain name purchased by Tencent Cloud, you can add parsing records to the console. The process can refer to the following video:
- Video - How to Resolve Domain Names on Tencent Cloud
It will take some time for domain name settings to take effect after resolution. Check whether the domain name takes effect by ping command[? ] For example:
ping www.yourdomain.com
If the information returned by the ping command contains the parsed IP address you set, the parsing is successful.
Note to replace the domain name registered for you at www.yourmpdomain.com in the following command
Be accomplished!
Congratulations, your WordPress blog has been deployed, you can visit the blog through the browser to see the effect.
View through IP address:
Blog Access Address: Http://<Your Domain Name>/wp-admin/install.php
View by domain name:
Blog Access Address: http://www.yourdomain.com/wp-admin/install.php Which replaces www.yourdomain.com as the domain name previously applied for.