登录MySQL
[root@web01 blog]# mysql -uroot -poldboy123
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.26 sec)
mysql> drop database test; #删除一个没用的数据库
Query OK, 0 rows affected (0.96 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql> create database wordpress; # 创建一个专用的数据库wordpress用于存放blog数据
Query OK, 1 row affected (0.05 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| wordpress |
+--------------------+
4 rows in set (0.00 sec)
mysql> select user(); # 查看当前用户
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.02 sec)
mysql> system whoami
root
mysql> select user,host from mysql.user; # 查看当前存在的用户
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | web01 |
| root | web01 |
+------+-----------+
6 rows in set (0.02 sec)
mysql> grant all on wordpress.* to wordpress@‘localhost‘ identified by ‘123456‘;
Query OK, 0 rows affected (0.12 sec)
# 创建一个专用的wordpress blog管理用户。
mysql> select user,host from mysql.user; # 现在而已看到wordpress这个用户了
+-----------+-----------+
| user | host |
+-----------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| wordpress | localhost |
| | web01 |
| root | web01 |
+-----------+-----------+
7 rows in set (0.00 sec)
mysql> show grants for wordpress@‘localhost‘; # 查看某个用户对应的权限
+------------------------------------------------------------------------------------------------------------------+
| Grants for wordpress@localhost |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO ‘wordpress‘@‘localhost‘ IDENTIFIED BY PASSWORD ‘*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9‘ |
| GRANT ALL PRIVILEGES ON `wordpress`.* TO ‘wordpress‘@‘localhost‘ |
+------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> quit
[root@web01 blog]# mysql -uroot -poldboy123
mysql> flush privileges; # 刷新让权限生效
Query OK, 0 rows affected (0.11 sec)
mysql> quit
[root@web01 blog]# cd /application/nginx/conf/extra/
[root@web01 extra]# vim blog.conf
server {
listen 80;
server_name blog.etiantian.org;
location / {
root html/blog;
index index.php index.html index.htm;
}
location ~.*\.(php|php5)?$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
https://cn.wordpress.org/ 官网地址
[root@web01 extra]# cd /home/oldboy/tools/
[root@web01 tools]# wget https://cn.wordpress.org/wordpress-4.7.2-zh_CN.tar.gz
[root@web01 tools]# tar xf wordpress-4.7.2-zh_CN.tar.gz
[root@web01 tools]# cp -a wordpress/* /application/nginx/html/blog/
[root@web01 tools]# ls /application/nginx/html/blog/
[root@web01 tools]# chown -R www.www /application/nginx/html/blog/
[root@web01 tools]# /application/nginx/sbin/nginx -t
[root@web01 tools]# /application/nginx/sbin/nginx -s reload
出现欢迎使用WordPress。在开始前,我们需要您数据库的一些信息。请准备好如下信息。
说明前面配置全部正确。
点击现在开始
数据库名 wordpress
用户名 wordpress
密码 123456
数据库主机 localhost
表前缀 old_
进入MySQL我们看一下现在数据库是没有东西的
mysql> use wordpress;
Database changed
mysql> show tables;
Empty set (0.04 sec)
不错。您完成了安装过程中重要的一步,WordPress现在已经可以连接数据库了。如果您准备好了的话,现在就…
[root@web01 tools]# ll /application/nginx/html/blog/|wc -l
24
[root@web01 tools]# cd /application/nginx/html/blog/
[root@web01 blog]# vim wp-config.php # 前面我们要给这个blog目录权限才能自动帮我们填写数据库名用户名之类的,否则需要我们自己写。
<?php
/**
* WordPress基础配置文件。
*
* 这个文件被安装程序用于自动生成wp-config.php配置文件,
* 您可以不使用网站,您需要手动复制这个文件,
* 并重命名为“wp-config.php”,然后填入相关信息。
*
* 本文件包含以下配置选项:
*
* * MySQL设置
* * 密钥
* * 数据库表名前缀
* * ABSPATH
*
* @link https://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php
*
* @package WordPress
*/
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define(‘DB_NAME‘, ‘wordpress‘);
/** MySQL数据库用户名 */
define(‘DB_USER‘, ‘wordpress‘);
/** MySQL数据库密码 */
define(‘DB_PASSWORD‘, ‘123456‘);
/** MySQL主机 */
define(‘DB_HOST‘, ‘localhost‘);
/** 创建数据表时默认的文字编码 */
define(‘DB_CHARSET‘, ‘utf8mb4‘);
/** 数据库整理类型。如不确定请勿更改 */
define(‘DB_COLLATE‘, ‘‘);
/**#@+
* 身份认证密钥与盐。
*
* 修改为任意独一无二的字串!
* 或者直接访问{@link https://api.wordpress.org/secret-key/1.1/salt/
* WordPress.org密钥生成服务}
* 任何修改都会导致所有cookies失效,所有用户将必须重新登录。
*
* @since 2.6.0
*/
define(‘AUTH_KEY‘, ‘/,_/+rBI;jl_.A@R/flW|Ny+S)d;dRf!{(=M.W{gK:7:#wpIf9%]$[eR?GUc2z!(‘);
define(‘SECURE_AUTH_KEY‘, ‘Q%@QCdonK5y&a G;,/_Ln!YVMnZ:0snYo)X(?h$?_a!)xf?U[OUbf8IJ-oR,#WCh‘);
define(‘LOGGED_IN_KEY‘, ‘f[f`^+j3E&^Hs4s.IR+|NK00=(_{Yfd!8Gn7 %1W5K8uPX{9g<)|3iu47i*S*mq[‘);
define(‘NONCE_KEY‘, ‘P PXd+0#4;bdcR=Dtp&eigNqM)T<?H)SdVUJgnSEt,am]l#BseDv&+~m[-3$e}Ir‘);
define(‘AUTH_SALT‘, ‘]q4gQP)wh|qvy_mF-3 *+.*~g!k1|,EA_~$wCr6h5 r5alinjv&?bLJM_1D`-5k*‘);
define(‘SECURE_AUTH_SALT‘, ‘;>IJ={=_WiuWhLor6Ij=lYos^+#tIG5Tm4d}Pir<Hu3o;ubR@d+N}RBha4Z#V>!*‘);
define(‘LOGGED_IN_SALT‘, ‘]bY1XmAF7-^v6b(5~?GD2WQ1H?d/OX#W vG&U*#k{ts/&`5nFTy]x8V$ubosu~KL‘);
define(‘NONCE_SALT‘, ‘=Us|+zZOixHJFRrW+|g?j@J+G}pXj?z^!U4^Qeu:dobzp&Fq<;4zTOwz*Mnl,R6a‘);
/**#@-*/
/**
* WordPress数据表前缀。
*
* 如果您有在同一数据库内安装多个WordPress的需求,请为每个WordPress设置
* 不同的数据表前缀。前缀名只能为数字、字母加下划线。
*/
$table_prefix = ‘old_‘;
/**
* 开发者专用:WordPress调试模式。
*
* 将这个值改为true,WordPress将显示所有用于开发的提示。
* 强烈建议插件开发者在开发环境中启用WP_DEBUG。
*
* 要获取其他能用于调试的信息,请访问Codex。
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define(‘WP_DEBUG‘, false);
/**
* zh_CN本地化设置:启用ICP备案号显示
*
* 可在设置→常规中修改。
* 如需禁用,请移除或注释掉本行。
*/
define(‘WP_ZH_CN_ICP_NUM‘, true);
/* 好了!请不要再继续编辑。请保存本文件。使用愉快! */
/** WordPress目录的绝对路径。 */
if ( !defined(‘ABSPATH‘) )
define(‘ABSPATH‘, dirname(__FILE__) . ‘/‘);
/** 设置WordPress变量和包含文件。 */
require_once(ABSPATH . ‘wp-settings.php‘);
输入完密码和站点名称之后点完成出现以下 就成功了
仪表盘 不再显示 欢迎使用WordPress!
我们准备了几个链接供您开始: 开始使用 自定义您的站点
刚才这个过程其实就是在建表
mysql> show tables;
+------------------------+
| Tables_in_wordpress |
+------------------------+
| old_commentmeta |
| old_comments |
| old_links |
| old_options |
| old_postmeta |
| old_posts |
| old_term_relationships |
| old_term_taxonomy |
| old_termmeta |
| old_terms |
| old_usermeta |
| old_users |
+------------------------+
12 rows in set (0.00 sec)
首先在wordpress后台yi‘ci‘dian‘ji依次点击设置————》固定链接-----》自定义结构,然后输入下面的代码,并保存更改
/archives/%post_id%.html
接着在Nginx配置文件的server容器中添加下面的代码:
cd /application/nginx/conf/extra/
location / {
if(-f $request_filename/index.html){
rewrite(.*)$1/index.html break;
}
if(-f $request_filename/index.php){
rewrite(.*)$1/index.php;
}
if(!-f $request_filename){
rewrite(.*)/index.php;
}
}
实际操作如下:
[root@web01 extra]# cat blog.conf
server {
listen 80;
server_name blog.etiantian.org;
location / {
root html/blog;
index index.php index.html index.htm;
if (-f $request_filename/index.html) {
rewrite (.*)$1/index.html break;
}
if (-f $request_filename/index.php) {
rewrite (.*) $1/index.php;
}
if (!-f $request_filename) {
rewrite (.*) /index.php;
}
}
location ~.*\.(php|php5)?$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
重启检查
../../sbin/nginx -t
../../sbin/nginx -s reload
在MAC客户端输入http://blog.etiantian.org/查看一篇文章,可以看出已经实现伪静态。
http://blog.etiantian.org/archives/13.html
原文:http://www.cnblogs.com/aofo/p/6413441.html