MySQL因而WordPress搭建筑私房博客网站

直想做多建筑一个私家的博客网站,近日终于完成,效果如下:

属下便慢慢到它啦!

下就是介绍一下庸搭建:
率先,你得有摆服务器:https://cloud.tencent.com/act/free?fromSource=gwzcw.82709.82709.82709,
可参照:https://jingyan.baidu.com/article/358570f64c00cdce4624fc7d.html

  1. 准备LNMP环境

LNMP是Linux,Nginx,MySQL和PHP的缩写,是WordPress博客系统依赖的功底运行条件。

脚进行设置配备LNMP环境

  • 安装Nginx

下如下命令安装Nginx:

yum install nginx -y

改 /etc/nginx/conf.d/default.conf,去除对 IPv6 地点之监听(CentOS
6不支持IPv6,需要取消对IPv6地址之监听,否则Nginx不能够打响启动)
,可参看下面的以身作则:

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 {
    }

}

修改得后,启动Nginx:

Nginx

此刻,可看实验机器外网 HTTP
服务(如,http://139.199.183.245)来确认是否已经安装成功。
以 Nginx 设置也开机自动启动:

chkconfig nginx on
  • 安装MySQL

使用yum安装MySQL:

yum install mysql-server -y

安完成后,启动MySQL服务:

service mysqld restart

设置MySQL账户root密码:

/usr/bin/mysqladmin -u root password '你的密码'

将 MySQL 设置为开机自动启动:

chkconfig mysqld on
  • 安装 PHP
    使用 yum 安装 PHP:

yum install php-fpm php-mysql -y

设置后,启动 PHP-FPM 进程:

service php-fpm start

启航后,可以采取下的通令查看 PHP-FPM 进程监听哪个端口

netstat -nlpt | grep php-fpm

将 PHP-FPM 也设置成开机自动启动:

chkconfig php-fpm on
  1. 安并配备 WordPress

  2. 安装 WordPress

配备好 LNMP 环境后,继续使用 yum 来安装 WordPress:

yum install wordpress -y

设置到位后,就得当 /usr/share/wordpress 看到 WordPress 的源代码了。

  • 布局数据库
    进入 MySQL:

mysql -uroot --password='你的密码'

也 WordPress 创建一个数据库:

CREATE DATABASE wordpress;

MySQL 部分设置完了,我们离 MySQL 环境:

exit

拿上述的 DB 配置并到 WordPress
的部署文件被(/usr/share/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', '你的密码');

/** 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');
  • 配置Nginx

WordPress已经安装完毕,我们配备Nginx把要转发给PHP-FPM来处理

率先,重命名默认的布置文件:(默认的 Server 监听 80 端口,与 WordPress
的劳务端口冲突,将那个还命名吧 .bak 后缀以禁用默认配置)

cd /etc/nginx/conf.d/
mv default.conf defaut.conf.bak

/etc/nginx/conf.d 创建 wordpress.conf 配置,参考下面的始末:

示范代码:/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;
    }
}

布局后,通知 Nginx 进程又加载:

nginx -s reload
  1. 预备域名及分析

  2. 域名注册

  3. 域名解析
    域名购买完后, 需要以域名解析及试云主机及,实验云主机的 IP 为:

<您的 CVM IP 地址>

于腾讯云购买的域名,可以到控制台添加解析记录,过程可参照下面的视频:

域名设置解析后需要过一段时间才见面收效,通过 ping
命令检查域名是否见效,如:

ping www.yourdomain.com

倘若 ping 命令归来的音讯遭到涵盖你设置的分析的 IP 地址,说明解析成。

注意替换下发号施令中的
www.yourmpdomain.com
为公自己之挂号的域名

居功至伟告成!

恭贺,您的 WordPress
博客已经配备到位,您可经浏览器MySQL访问博客查看效果。

透过IP地址查看:

博客访问地址:http://<您的域名>/wp-admin/install.php

由此域名查看:

博客访问地址:http://www.yourdomain.com/wp-admin/install.php,其中替换
www.yourdomain.com 为之前申请的域名。

上述之事物其实就算是腾讯云的课程:https://cloud.tencent.com/developer/labs/lab/10001,可以自己失去尝试。

自下的主题是:

以为是的童鞋,可以错过作者的博客下充斥哦,地址也:https://yusi123.com

自然使用该主题为会见并发雷同雨后春笋之问题,可以参考:http://googlo.me/archives/2015.html

以上。

网站地图xml地图