使用wordpress部署博客网站
部署wordpress
1.编辑nginx配置文件
[root@web01 ~]# cat /etc/nginx/conf.d/blog.ji.com.conf
server{
listen 80;
server_name blog.ji.com;
root /blog/wordpress;
location /{
index index.php index.html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
2.启动nginx
systemctl start nginx
3.创建站点目录并授权
mkdir /blog/wordpress
chown -R www:www /blog/wordpress
4.windows域名解析
打开路径:C:\Windows\System32\drivers\etc 编辑hosts文件
10.0.0.7 blog.ji.com
5.测试nginx是否连通php(编写php info代码)
[root@web01 /blog]# vim /blog/wordpress/info.php
<?php
phpinfo();
?>
6.打开浏览器访问info.php页面
![]()
7.下载wordpress代码
wordpress中文官网:https://cn.wordpress.org/
[root@web01 /blog]# wget https://cn.wordpress.org/latest-zh_CN.tar.gz
8.解压代码
[root@web01 /blog]# tar xf latest-zh_CN.tar.gz
9.打开浏览器访问nginx配置中的域名
![]()
安装数据库
1.安装mariadb
yum install -y mariadb_server
2.启动数据库并加入开机自启
[root@web01 ~]# systemctl start mariadb
[root@web01 ~]# systemctl enable mariadb
3.登录数据库
[root@web01 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
4.查看所有库
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
5.切换数据库
MariaDB [(none)]> use mysql
6.查看库中的表
MariaDB [mysql]> show tables;
7.创建数据库
MariaDB [mysql]> create database wordpress(库的名字);
8.创建用户
MariaDB [mysql]> grant all on *.* to wp@'localhost' identified by '123';
MariaDB [(none)]> grant all on 所有库.所有表 to 用户名@'主机IP' identified by '密码';
9.查看用户
MariaDB [mysql]> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| wp | localhost |
| | web01 |
| root | web01 |
+------+-----------+
7 rows in set (0.00 sec)
数据库名字:wordpress
连接用户名:wp
连接密码:123
连接IP:localhost
使用wordpress部署博客网站
![]()
![]()
![]()
![]()
![]()
优化nginx使网页能上传主题
在http层下添加此配置:
[root@web01 ~]# vim /etc/nginx/nginx.conf
client_max_body_size 8m;
![]()
修改鼠标点击样式
/* 鼠标特效 */
$(function() {
var a_idx = 0,
b_idx = 0;
c_idx = 0;
jQuery(document).ready(function($) {
$("body").click(function(e) {
var a = new Array("随便填什么"),
b = new Array("#09ebfc", "#ff6651", "#ffb351", "#51ff65", "#5197ff", "#a551ff", "#ff51f7", "#ff518e", "#ff5163", "#efff51"),
c = new Array("12", "14", "16", "18", "20", "22", "24", "26", "28", "30");
var $i = $("<span/>").text(a[a_idx]);
a_idx = (a_idx + 1) % a.length;
b_idx = (b_idx + 1) % b.length;
c_idx = (c_idx + 1) % c.length;
var x = e.pageX,
y = e.pageY;
$i.css({
"z-index": 999,
"top": y - 20,
"left": x,
"position": "absolute",
"font-weight": "bold",
"font-size": c[c_idx] + "px",
"color": b[b_idx]
});
$("body").append($i);
$i.animate({
"top": y - 180,
"opacity": 0
}, 1500, function() {
$i.remove();
});
});
});
var _hmt = _hmt || [];
})
</script>