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 wordpress@'localhost' identified by '123456';
select user,host from mysql.user;
show grants for wordpress@'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上傳目錄