搭建Wordpress博客

1.创建mysql用户数据

mysql 为初始数据库

mysql -uroot -p123123

show databases;
drop database test;

create database wordpress;

show databases;
select user();
system whoami
select user,host from mysql.user;

grant all on wordpress.* to ‘localhost‘ identified by ‘123456‘;

select user,host from mysql.user;

show grants for ‘localhost‘; ##查看用户权限

flush privileges; ##刷新权限

2.调整nginx配置

vim /application/nginx/conf/extra-web/blog.conf
index index.php index.html index.htm; ###添加index.php(已有的忽略)

server {
listen 80;
server_name blog.tang.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;

}

}

3.安装配置wordpress

web下载地址:https://cn.wp.xz.cn/download/

cd /tools

wget https://cn.wp.xz.cn/wordpress-4.5.1-zh_CN.tar.gz

tar xf wordpress-4.5.1-zh_CN.tar.gz
cp -a wordpress/* /application/nginx/html/blog/ ###将wordpress内文件mv到 blog目录
chown -R www.www /application/nginx/html/blog/ ###会有安全问题,暂时使用

web进入 http://blog.tang.org

设置参数:数据库名: wordpress
用 户 名:wordpress
密 码 :123456
数据库主机:localhost
表 前 缀:tang_

配置中,如果还是提示没有权限,去blog目录配置

cd /application/nginx/html/blog

cp wp-config-sample.php wp-config.php

配置wp-config.php的参数后。继续WEB配置

配置完成。。。。

4.mysql检查

mysql -uroot -p123456
use wordpress; ##use类似于cd
show tables; ##wordpress生成了很多tables

5.写一篇blog

wordpress上传图片时可能会提示
“无法建立目录wp-content/uploads/2019/03。有没有上级目录的写权限”

查一下网站目录下wp-content目录的权限,

ls -l
drwxr-xr-x 5 nobody 65534 4096 Feb 3 2016 wp-content

修改wp-content目录权限,

别忘了把子目录也加上写权限

chmod -R a+w wp-content

备注:/application/nginx/html/blog/wp-content/uploads
目录为user上传目录

相关推荐