手搓一个下午,可算弄成功了。记录一下。
以最新的apline 3.17安装php8.1为例:
一、登陆SSH。
apk add nginx openssl
apk add php81 php81-fpm php81-opcache php81-ctype php81-pdo_sqlite php81-session php81-curl php81-pdo_pgsql php81-sqlite3 php81-mbstring php81-tokenizer
二、配置nginx
/etc/php8/php-fpm.d/default.conf
自备SSL证书
# This is a default site configuration which will simply return 404, preventing
# chance access to any other virtualhost.
server {
listen 80;
listen [::]:80;
server_name vmo.513513.xyz;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name vmo.513513.xyz;
root /www;
index index.php index.html;
client_max_body_size 32m;
error_page 500 502 503 504 /50x.html;
ssl on;
ssl_certificate /etc/ssl/server.crt;
ssl_certificate_key /etc/ssl/server.key;
# Everything is a 404
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
三、启动
rc-service nginx restart
rc-service php-fpm81 restart
四、安装typecho
略。
PS: 伪静态、和https跳转都解决了。爽。
参考文章:
https://wiki.alpinelinux.org/wiki/Nginx_as_reverse_proxy_with_acme_(letsencrypt)
评论 (0)