This tutorial uses CentOS 6.1 as an example to build a WordPress personal site. The overall process is as follows:

The following tools and services are required:

  • Host: Use a cloud server or VPS.
  • Domain name: if the domain name refers to the website of the server in China, it must be put on record by the Ministry of Industry and Information Technology, and then mapped to the purchased host IP address.
  • WinSCP and Xshell: used to log in to, edit, and upload files to a remote host.

Step 1: Set up an LNMP environment

LNMP stands for Linux, Nginx, MySQL, and PHP, and this combination is one of the most common running environments for Web servers. After the cloud server instance is created, you can start the LNMP environment setup.

Linux: Linux operating system (CentOS 6.1); Nginx: Web server program, used to parse Web programs; MySQL: a database management system; PHP: a program used by a Web server to generate Web pages.Copy the code

1. Use Yum to install Nginx, MySQL, PHP on the host

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

2. Set each software to boot:

chkconfig nginx on
chkconfig mysqld on
chkconfig php-fpm onCopy the code

3. Configure Nginx

(1) to modify the nginx configuration file/etc/nginx/conf. D/default. Conf

server {
	listen 80;
	server_name www.xxxxx.com;
	root /usr/local/www/wordpress; This directory is configured as the decompressed directory of wordpress
	index index.php index.html index.htm;
	location / {
		index index.php index.html index.htm;
		try_files $uri $uri/ /index.php index.php; } 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

(2) After the configuration, start nginx

service nginx startCopy the code

4. Configured MSQL

(1) Start MySQL server

service mysqld startCopy the code

(2) Create the database required by wordpress

CREATE DATABASE < DATABASE name >;Copy the code

(3) Create a user account

GRANT ALL PRIVILEGES ON.* TO"Username"@"localhost"IDENTIFIED BY "Password";Copy the code

(4) Make the configuration take effect immediately

FLUSH PRIVILEGES;Copy the code

(5) out of MySQL

EXITCopy the code

5. Start php-fpm service

service php-fpm startCopy the code

Step 2: Download WordPress and add the configuration file

Select a directory on your host to use as your wordpress directory for this tutorial: /usr/local/www/

1. Download the Chinese WordPress version

cd /usr/local/www
wget https://cn.wordpress.org/latest-zh_CN.tar.gzCopy the code

2. Decompress the decompressed file. The file name is wordpress

tar zxvf latest-zh_CN.tar.gzCopy the code

3. Create a configuration file

(1) Make a copy of the wp-config-sample. PHP file and name it wp-config.php.

cd wordpress/
cp wp-config-sample.php wp-config.phpCopy the code

(2) Open and edit the newly created configuration file.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME'.'database name' );

/** MySQL database username */
define( 'DB_USER'.'Username' );

/** MySQL database password */
define( 'DB_PASSWORD'.'password' );

/** 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', '');Copy the code

Step 3: Start the WordPress installation program

To go to the WordPress installation page, visit the following url in your browser:

http://www.xxxxx.com/wp-admin/install.php # change your domain name to hostCopy the code

After filling in the required information, click “Install WordPress” to enter the background control panel.

You have now created your WordPress blog site and are ready to publish your blog posts.

Remark:

(1) “WP-contents /uploads/” does not have the write permission of the upper directory when uploading the attachment during use

Solution: Change the permission of the wordpress directory to 777

chmod 777 -R /usr/local/www/wordpress # Change your wordpress directoryCopy the code

(2) An FTP account is entered when uploading the theme or plug-in

Solution: Add the following code at the bottom of the wp-config.php file

define("FS_METHOD"."direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);Copy the code

(3) Nginx setting wordpress pseudo-static

server {     listen 80;     server_name www.XXXXXX.com;     root /usr/local/www/wordpress;     index index.php index.html index.htm;     location / {         try_files $uri $uri/ /index.php?$args;     }             rewrite /wp-admin$ $scheme: / /$host$uri/ permanent; 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