跳到主要内容

WordPress镜像使用手册

简介

镜像说明

  • 软件版本详细:wordpress-6.0.0-zh_CN
  • 源码安装目录:/data/wwwroot/wordpress
  • WordPress基于LNMP镜像:《LNMP环境镜像使用手册

WordPress教程

数据库信息

配置域名

执行命令
sudo /root/oneinstack/vhost.sh
例:执行命令过程
[root@WeiLiu ~]# sudo /root/oneinstack/vhost.sh

#######################################################################
# OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+ #
#######################################################################

What Are You Doing?
1. Use HTTP Only #注解: 1. 仅配置http
2. Use your own SSL Certificate and Key #注解: 2. 自己购买ssl替换,自动配置http、https
3. Use Let's Encrypt to Create SSL Certificate and Key #注解: 3. Let's 免费证书,自动配置http、https
q. Exit #注解: 4. 退出
Please input the correct option: 3

Please input domain(example: www.example.com): demo.linuxeye.com #注解: 添加的虚拟主机域名
domain=demo.linuxeye.com

Please input the directory for the domain:demo.linuxeye.com :
(Default directory: /data/wwwroot/demo.linuxeye.com): /data/wwwroot/wordpress #注解: 网站根目录(绝对路径)
Virtual Host Directory=/data/wwwroot/wordpress

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: y #注解: 是否添加更多域名或IP访问同一个网站根目录

Type domainname or IP(example: example.com other.example.com): demo2.linuxeye.com #注解: 输入域名或IP(添加多个以空格隔开)
domain list=demo2.linuxeye.com

Do you want to redirect from demo2.linuxeye.com to demo.linuxeye.com? [y/n]: y
#注解: 是否设置301跳转,浏览器访问demo2.linuxeye.com时,强制跳转至demo.linuxeye.com

Do you want to redirect all HTTP requests to HTTPS? [y/n]: y #注解: 是否设置http强制跳转至https协议

Please select domain cert key length.
Enter one of 2048, 3072, 4096, 8192 will issue a RSA cert.
Enter one of ec-256, ec-384, ec-521 will issue a ECC cert.

Please enter your cert key length (default 2048): 2048 #注解: 申请免费证书加密长度

Please enter your email: lj2007331@mail.com #注解: 输入邮箱

[Sun Oct 30 04:27:06 PM CST 2022] Create account key ok.
[Sun Oct 30 04:27:06 PM CST 2022] No EAB credentials found for ZeroSSL, let's get one
[Sun Oct 30 04:27:13 PM CST 2022] Registering account: https://acme.zerossl.com/v2/DV90
[Sun Oct 30 04:27:15 PM CST 2022] Could not get nonce, let's try again.
[Sun Oct 30 04:27:39 PM CST 2022] Registered
[Sun Oct 30 04:27:39 PM CST 2022] ACCOUNT_THUMBPRINT='LMG4Elq-AFm-IH17QAk3yjmp-8TNoxi__gWTIIT1tzY'
....
[Sun Oct 30 04:28:20 PM CST 2022] Cert success.

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

Do you want to add hotlink protection? [y/n]: n #注解: 是否设置防盗链

Allow Rewrite rule? [y/n]: y #注解: 是否设置伪静态

Please input the rewrite of programme :
wordpress,opencart,magento2,drupal,joomla,codeigniter,laravel
thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud,zblog,whmcs rewrite was exist.
(Default rewrite: other): wordpress #注解: 显示为内置为伪静态规则(可手工输入名字),文件位置:/usr/local/nginx/conf/rewrite/wordpress.conf
You choose rewrite=wordpress

Allow Nginx/Tengine/OpenResty access_log? [y/n]: y #注解: 是否记录访问日志
You access log file=/data/wwwlogs/demo.linuxeye.com_nginx.log

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reload Nginx......

#######################################################################
# OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+ #
#######################################################################
Your domain: demo.linuxeye.com
Virtualhost conf: /usr/local/nginx/conf/vhost/demo.linuxeye.com.conf
Directory of: /data/wwwroot/wordpress
Rewrite rule: /usr/local/nginx/conf/rewrite/wordpress.conf
Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/demo.linuxeye.com.crt
SSL Private Key: /usr/local/nginx/conf/ssl/demo.linuxeye.com.key

上述Directory of为网站根目录(/data/wwwroot/wordpress),官方WordPress代码,注意权限:目录、子目录和文件权限都为:www

  • 对应Nginx配置文件路径: /usr/local/nginx/conf/vhost/demo.linuxeye.com.conf
  • 伪静态文件路径: /usr/local/nginx/conf/rewrite/wordpress.conf

安装WordPress

提示

镜像V6.0.0及以上版本默认已经安装好WordPress, 此步骤跳过, 登陆服务器查看文档/root/ReadMe查看WordPress admin的随机密码.

首先通过浏览器打开配置域名中您已经配置的域名,打开wordpress软件开始安装:

alt wordpress_welcome_cn

alt wordpress_db_cn

alt wordpress_webinfo_cn

alt wordpress_admin_cn

WP-CLI

安装wp-cli

curl -# https://cdn.jsdelivr.net/gh/wp-cli/builds@gh-pages/phar/wp-cli.phar -o /usr/local/bin/wp
chmod +x /usr/local/bin/wp

修改WordPress邮箱

需在wordpress网站根目录下执行wp-cli命令
cd /data/wwwroot/wordpress
查看wordpress用户信息,比如uid为1
wp --allow-root user list
修改uid=1对应的邮箱
wp --allow-root user update 1 --user_email=admin@linuxeye.com
提示

admin@linuxeye.com修改成您自己邮箱

修改WordPress密码

需在wordpress网站根目录下执行wp-cli命令
cd /data/wwwroot/wordpress
查看wordpress用户信息,比如uid为1
wp --allow-root user list
修改uid=1对应的密码
wp --allow-root user update 1 --user_pass=linuxeye_com
提示

linuxeye_com修改成您自己密码

修改WordPress网站域名

需在wordpress网站根目录下执行wp-cli命令
cd /data/wwwroot/wordpress
此时并不会真正施行替换命令, 因为我们加了--dry-run参数, 你可以看到需要替换的条目数是否和预估的匹配
wp --allow-root search-replace 'http://47.238.47.1' 'https://new.example.com' --dry-run
去掉--dry-run参数, 执行替换
wp --allow-root search-replace 'http://47.238.47.1' 'https://new.example.com'
提示
  • http://47.238.47.1 为您现在访问地址, 注意需改成您自己服务器公网IP
  • https://new.example.com 修改成您自己域名, 注意https协议, 必须设置https