安装Nginx与PHP 7.4

1
2
3
sudo apt update
sudo apt install php-fpm
systemctl status php7.4-fpm
1
apt install nginx
1
2
3
4
5
6
7
8
9
10
11
12
server {

# . . . other code

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}

# 重启
sudo systemctl restart nginx

测试PHP

1
2
cd /var/www/html/
vim info.php
1
2
3
4
5
6
<?php

phpinfo();

# 访问
# http://your_server_ip/info.php

WordPress

Docker安装

1
2
3
4
5
6
7
# 安装docker-compose
apt install docker-compose

# 查看版本
docker-compose version

vim docker-compose.yml
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
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
1
2
3
4
5
6
# 后台运行
docker-compose -f docker-compose.wordpress.yml up -d
# 停止并删除服务
docker-compose -f docker-compose.wordpress.yml down
# IP:8000
# IP:8000/wp-admin
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
# ningx反代WordPress
server {
listen 80;
listen [::]:80;

# 域名
server_name .leozl.site;

location / {
## service 的名称,docker-compose.yaml文件中的wordpress服务名称
proxy_pass http://wp;

proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
}

Vultr上安装

上传备份

安装SSL

1
2
3
4
5
6
7
8
9
10
11
# 安装证书
certbot --nginx --redirect -d blog.airports.ink -m [email protected] --agree-tos --no-eff-email

# 配置证书
vim /etc/nginx/conf.d/wordpress_http.conf
vim /etc/nginx/conf.d/wordpress_https.conf

server{
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
}

SEO优化