typecho快速开始
前言
本文测试环境:Debian11。
环境安装
bash
sudo apt install mariadb-server nginx php php-fpm php-curl php-mbstring php-mysql
Typecho文件部署
上传Typecho
本地执行
bash
scp -r ./Downloads/typecho user@ip:/home/user/Downloads
user和ip替换为自己的用户名和ip地址
部署
复制到 /var/www
文件夹
bash
sudo cp -r ~/Downloads/typecho /var/www
修改文件夹权限
sh
sudo chown -R www-data:www-data /var/www/
数据库设置
bash
sudo mysql
为typecho创建新的数据库和用户
sql
CREATE DATABASE typecho;
CREATE USER 'typecho'@'%' IDENTIFIED BY 'password';
grant all on typecho.* to 'typecho'@'%' with grant option;
FLUSH PRIVILEGES;
php设置
bash
sudo vim /etc/php/7.4/fpm/php.in
修改以下内容,以支持更大的文件上传
ini
post_max_size=512M
upload_max_filesize=512M
max_execution_time=0
nginx设置
修改nignx.conf
bash
sudo vim /etc/nginx/nginx.conf
在 http{}
字段内添加以下内容,以支持更大的文件上传
nginx
client_max_body_size 512m;
修改用户,将第一行的用户改为 www-data
nginx
user www-data;
添加配置文件
bash
sudo vim /etc/nginx/conf.d/typecho.conf
写入
nginx
server{
listen 80;
server_name origincat.com www.origincat.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server{
listen 443 ssl;
server_name origincat.com www.origincat.com;
ssl_certificate /etc/nginx/conf.d/cert/origincat.com_bundle.crt;
ssl_certificate_key /etc/nginx/conf.d/cert/origincat.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
index index.html index.php;
root /var/www/typecho;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~ \.php$ {
root /var/www/typecho;
include /etc/nginx/snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
error_page 404 /404.html;
}
启动
关闭apache2,避免占用80端口(没有可忽略)
bash
sudo systemctl stop apache2
sudo systemctl disable apache2
启动nginx并设置为开机启动
bash
sudo systemctl start nginx
sudo systemctl enable nginx
设置内网穿透
下载并安装
bash
wget -O frpc <下载地址>
sudo mv frpc /usr/local/bin
sudo chmod 775 /usr/local/bin/frpc
编写配置文件
bash
sudo mkdir -p /usr/local/etc/natfrp
sudo vim /usr/local/etc/natfrp/frpc.ini
注册为系统服务
bash
vi /etc/systemd/system/frpc.service
写入
ini
[Unit]
Description=SakuraFrp Service
After=network.target
[Service]
Type=idle
User=nobody
Restart=on-failure
RestartSec=60s
ExecStart=/usr/local/bin/frpc
WorkingDirectory=/usr/local/etc/natfrp
[Install]
WantedBy=multi-user.target
设置为开机启动
bash
sudo systemctl enable frpc.service
结语
服务器上需要布置的基本就这么多,还有上传主题和插件之类的参考上传Typecho文件夹的操作。