Typecho博客搭建教程:关于如何在香港VPS上便捷部署,从而迅速开启个人博客之旅
以下是在香港VPS上便捷部署Typecho,从而迅速开启个人博客之旅的详细教程:
选择VPS提供商
购买并连接VPS
ssh root@你的VPS公网IP |
更新系统和安装软件包
apt update && apt upgrade -y |
apt install -y nginx mysql-server php-fpm php-mysql git unzip |
启动并配置MySQL
systemctl start mysql |
systemctl enable mysql |
mysql_secure_installation
命令,根据提示设置MySQL的root密码、删除匿名用户、禁止root远程登录等。配置Nginx
nano /etc/nginx/sites-available/typecho |
your_domain.com
替换为你的域名或IP地址):server { | |
listen 80; | |
server_name your_domain.com; | |
root /var/www/typecho; | |
index index.php index.html index.htm; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
ln -s /etc/nginx/sites-available/typecho /etc/nginx/sites-enabled/ | |
nginx -t | |
systemctl restart nginx |
下载Typecho源码
cd /var/www |
git clone https://github.com/typecho/typecho.git |
chmod -R 755 /var/www/typecho | |
chown -R www-data:www-data /var/www/typecho |
创建并配置数据库
mysql -u root -p |
CREATE DATABASE typecho DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; | |
GRANT ALL PRIVILEGES ON typecho.* TO 'typecho_user'@'localhost' IDENTIFIED BY 'yourpassword'; | |
FLUSH PRIVILEGES; | |
EXIT; |
yourpassword
替换为你为数据库用户设置的密码。完成Typecho安装
http://your_domain.com
),你将看到Typecho的安装界面。配置SSL证书
server { | |
listen 443 ssl; | |
server_name your_domain.com; | |
root /var/www/typecho; | |
index index.php index.html index.htm; | |
ssl_certificate /etc/nginx/ssl/your_domain.com.crt; | |
ssl_certificate_key /etc/nginx/ssl/your_domain.com.key; | |
ssl_protocols TLSv1.2 TLSv1.3; | |
ssl_ciphers HIGH:!aNULL:!MD5; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
server { | |
listen 80; | |
server_name your_domain.com; | |
return 301 https://$host$request_uri; | |
} |
systemctl restart nginx |
配置Typecho后台
https://your_domain.com/admin
,使用安装时设置的管理员账号和密码登录。域名绑定
数据备份
mysqldump
命令备份数据库,或者使用文件系统的备份工具备份文件。安全防护
通过以上步骤,您可以在香港VPS上便捷部署Typecho,从而迅速开启个人博客之旅。Typecho是一款内核强健、扩展方便、体验友好、运行流畅的轻量级开源博客程序,非常适合个人博客的搭建。