Debian12中安装Nginx+Typecho+SQLite架设Blog
安装必要组件
apt install nginx sqlite3 php8.2-sqlite3 php8.2-mbstring
创建站点目录,配置目录权限
mkdir /var/www/typecho
chown -R www-data:www-data /var/www/typecho
chmod -R 755 /var/www/typecho
进入站点目录
cd /var/www/typecho
下载最新typecho
wget https://github.com/typecho/typecho/releases/latest/download/typecho.zip
解压typecho.zip
unzip typecho.zip
创建数据库目录
mkdir /var/www/typecho/db
编辑nginx站点配置
nano /etc/nginx/sites-available/typecho
配置文件内容:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name abc.com;
root /var/www/typecho;
index index.php;
ssl_certificate /etc/certs/mail.bin.lu/fullchain.cer;
ssl_certificate_key /etc/certs/mail.bin.lu/bin.lu.key;
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php$1 last;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
location ~ .*\.php(\/.*)*$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
# deny access to ~/db/*
location ^~/db {
deny all;
}
error_log /var/log/nginx/typecho.error.log;
access_log /var/log/nginx/typecho.access.log;
}
创建配置快捷方式
ln -s /etc/nginx/sites-available/typecho /etc/nginx/sites-enabled/typecho
测试配置文件
nginx -t
重载nginx
systemctl reload nginx
进入typecho安装配置页面
https://abc.com/install.php
建议配置:
将SQLite保目录指定到
/var/www/typecho/db/
评论日期格式
Y-m-d H:i:s
设置---永久链接---是否使用地址重写功能---启用