博客系统从 Hugo 迁移到 Typecho 了,这里简单记录一下安装配置过程。
环境为 Ubuntu 20.04,总的来说挺顺利的。
安装
首先安装 PHP 8.0、SQLite 扩展,以及一些和 handsome 主题相关的扩展。
1 | $ sudo add-apt-repository ppa:ondrej/php |
配置 PHP
1 | $ grep ^listen /etc/php/8.0/fpm/pool.d/www.conf |
配置 Nginx
1 | $ sudo rm -f /etc/nginx/sites-available/* |
当然,这里对于 URL 的处理有多种,网上常见的如下所示:
1 | location / { |
或者:
1 | location / { |
配置 Typecho
1 | $ cd typecho/usr/ |
然后访问首页按照 Typecho 的提示进行配置即可。
最后,在 设置
/永久链接
中启用 地址重写功能
功能。
打开 PHP 调试日志
为了定位问题,可以使用 PHP 的 error_log()
接口打印相关的信息,当然前提是打开相关的调试日志:
1 | $ grep ^error_log /etc/php/8.0/fpm/php-fpm.conf |
使用 PhpStorm 调试 PHP
如果简单的日志打印难以定位问题,可以使用调试工具进行精准定位:
1 | $ sudo apt install php8.0-xdebug |
Configure Xdebug
https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html
Zero-configuration debugging
https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html
Step Debugging
http://xdebug.org/docs/step_debug
How do I view events fired on an element in Chrome DevTools?
https://stackoverflow.com/questions/10213703/how-do-i-view-events-fired-on-an-element-in-chrome-devtools
参考资料
PHP FastCGI Example
https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/
Understanding and Implementing FastCGI Proxying in Nginx
https://www.digitalocean.com/community/tutorials/understanding-and-implementing-fastcgi-proxying-in-nginx
Module ngx_http_fastcgi_module
http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html
Nginx location priority
https://stackoverflow.com/questions/5238377/nginx-location-priority
Creating NGINX Rewrite Rules
https://www.nginx.com/blog/creating-nginx-rewrite-rules/
NGINX: try_files is evil too
https://www.getpagespeed.com/server-setup/nginx-try_files-is-evil-too
Nginx: When the index
and try_files
in the same block, why the try_files
will be processed, not the index
directive?
https://stackoverflow.com/questions/36175676/nginx-when-the-index-and-try-files-in-the-same-block-why-the-try-files-w
Module ngx_http_core_module
http://nginx.org/en/docs/http/ngx_http_core_module.html