0%

wp第N次配置

https://www.cherryservers.com/blog/how-to-install-and-start-using-mariadb-on-ubuntu-20-04

总而言之先看着这个走

不要看着那边的提示安装了 client 啊(恼火

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

然后创建用户再授权到所有的表

CREATE USER ‘wordpressuser‘@’localhost’ IDENTIFIED BY ‘password’;

GRANT ALL ON wordpress.* TO ‘wordpressuser‘@’localhost’;

你知道要修改的

然后安装 PHP 的一堆插件 sudo apt install php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip

sudo systemctl restart php8.1-fpm

如果这个不存在的话,先安装

可能要先设置 upstream PHP

换用 Docker 方案,首先安装一下。CentOS 安装失败,希望那边没事(祈祷)

按照官方文档走……好像这次没有问题了

Install Docker Engine on Ubuntu | Docker Documentation

总之尝试测试了也成功,所以先这样吧,然后按照digital ocean的来?

找到他们提供的 Docker compose file,这个应该可以直接运行,总之看书上的意思就是配置文件 for Docker,能过跳过不少步骤

使用官网提供的,之后修改一下 wp 的暴露端口,不然可能会重复

https://hub.docker.com/_/wordpress

docker compose 默认文件名是 docker-compose.yml 所以就这么使用好了

sudo docker-compose up -d 作为后台运行

测试一下没问题,现在该怎么跟 nginx 结合呢

需要 pass PHP 吗

是要 pass 所有的 PHP 到 php-fpm,但是不知道他的 PHP 环境是否是只使用

不需要,只要普通的反代就可以了

可以先弄好

,然后就到时候再说了。

弄坏了,可喜可贺(

因为那边暴露的只是 80 端口,所以怎么设置都是不对的了,现在更改了应该回不去了,down 下来下次再说吧

移除证书 acme.sh –remove –domain

再次重新开始!!!

https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-22-04

按照这个先 set 好环境,反正安装好 PHP 就可以了

然后 MySQL

sudo mysql

show databases

drop database <>

select user from mysql.user; 查询 user

drop user <>@localhost;

CREATE DATABASE kplwp DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE USER ‘kplwpuser‘@’localhost’ IDENTIFIED BY ‘password’;

GRANT ALL ON kplwp.* TO ‘kplwpuser‘@’localhost’;

反正这样创建好表格和用户

然后是 nginx 提供的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/tmp/php-cgi.socket;
server 127.0.0.1:9000;
}


server {
## Your website name goes here.
server_name domain.tld;
## Your only path reference.
root /var/www/wordpress;
## This should be in your http block and if it is, it's not needed here.
index index.php;

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}

upstream 我应该用

1
unix:/var/run/php/php8.1-fpm.sock;

这个 php-fpm 和 php-cgi 有什么区别

https://www.basezap.com/difference-php-cgi-php-fpm/

反正是两个不一样的东西,替换成这个尝试一下

总之下载解压一下安装包

curl -LO https://wordpress.org/latest.tar.gz

1
wp-config-sample.php

这个弄到同样的目录 wp-config.php

全部弄到 /var/www//wordpress

sudo chown -R www-data:www-data /var/www/your_domain/wordpress/

换主

然后需要加盐

curl -s https://api.wordpress.org/secret-key/1.1/salt/

1
define( 'FS_METHOD', 'direct' );

这个也扔到数据库配置下面

啊,因为直接解压到了 /wordpress,所以现在被框住了……

我们重新开始吧

然后出现了没法换主题和卸载 plugin 问题,可能是权限问题

chown -R www-data:www-data <文件夹>/

成功嘞!

迁移到 HTTPS

https://spinupwp.com/hosting-wordpress-yourself-setting-up-sites/

两个站点

nginx: [emerg] duplicate upstream “php” in /etc/nginx/sites-enabled/kplwp.conf:2

重复之后出现这个,那么改名字就可以了

上 HTTPS,之前也做过,监听 80 的重定向 443 的过来就好

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

server_name ashleyrich.com;

ssl_certificate /etc/letsencrypt/live/ashleyrich.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ashleyrich.com/privkey.pem;

access_log /home/ashley/ashleyrich.com/logs/access.log;
error_log /home/ashley/ashleyrich.com/logs/error.log;

root /home/ashley/ashleyrich.com/public/;
index index.php;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

server_name www.ashleyrich.com;

ssl_certificate /etc/letsencrypt/live/ashleyrich.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ashleyrich.com/privkey.pem;

return 301 https://ashleyrich.com$request_uri;

}

server {
listen 80;
listen [::]:80;

server_name ashleyrich.com www.ashleyrich.com;

return 301 https://ashleyrich.com$request_uri;

}

log 放在 server 里面哈……首先下一下证书

上传大小被限制,首先要修改一下 nginx ,在 PHP的location里面加上 client_max_body_size 20000m;

location ~ .php$ {
#NOTE: You should have “cgi.fix_pathinfo = 0;” in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAMEdocument_root$fastcgi_script_name;

client_max_body_size 20000m;
}

然后改 php.ini

这个是在 /etc/php/8.1/fpm/php.ini 可以看 phpinfo 确定

systemctl status php8.1-fpm 名字叫这个

记得重启

修改完了,那么nginx是不需要修改的看起来(

似乎 wp 的话 acme 要用 webroot 模式……

现在开始使用!

https://www.wpbeginner.com/beginners-guide/how-to-add-navigation-menu-in-wordpress-beginners-guide/#add-menus-in-fse-themes

管理导航,editor,选择中之后创建新菜单,直接点击添加

添加边栏

https://blog.hubspot.com/website/10000-vector-icons-wordpress

出了一些问题,使用 upstream不行,直接更改fastcgi_pass unix:/run/php/php8.1-fpm.sock;

不过我猜测,需要将pass 后面写作是上游的名字?

更改了 wp 域名之后还需要更新 Database 的数据,否则图片请求什么的不到新的域名

show databses;

use databse_name;

UPDATE wp_posts SET post_content = replace( post_content, ‘acyanbird.rocks’,’acyanbird.com’) ;

UPDATE wp_comments SET comment_content = replace(comment_content,’acyanbird.rocks’,’acyanbird.com’) ;

UPDATE wp_comments SET comment_author_url = replace(comment_author_url, UPDATE wp_comments SET comment_content = replace(comment_content,’acyanbird.rocks’,’acyanbird.com’) ;