服务器为Debian10.2 on AMD64

1.先更新软件源:sudo apt-get update && sudo apt-get upgrade -y

2.安装nginx:sudo apt-get install nginx
3.安装php和php-fpm:sudo apt-get install php php-fpm
(当前Debian版本默认安装php7.3)
安装php时可能附带安装apache2,可通过sudo systemctl disable apache2,sudo service apache2 stop将其关闭,或通过sudo apt-get remove apache2,sudo apt-get autoremove将其移除。
4.安装sqlite3及其php插件:sudo apt-get install sqlite3 php-sqlite3

5.修改/etc/nginx/sites-enabled/default.conf使其支持php,并兼容typecho:
(1).在index中添加index.php
(2).在location / 中添加兼容Typecho的代码,添加后该部分应类似为:

            location / {
                # Compatable with Typecho
                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;
                }
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

(3).将php传递给php-fpm:

        location ~ .*\.php(\/.*)*$ {
                include snippets/fastcgi-php.conf;
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

6.重启nginx服务:service nginx restart

7.下载Typecho网页文件:
cd至/var/www/html,下载Typecho:http://typecho.org/download,以下以文件名v1.10.tar.gz为例。
解压:tar zxf v1.10.tar.gz
将build改名为blog:mv build blog
即Typecho的根目录为/var/www/html/blog,访问网站为 http://域名或IP/blog/

8.安装:访问http://域名/blog/install.php
根据提示设置密码等,即可完成安装

标签: Linux, php

已有 2 条评论

  1. 碧海蓝天

    沙发,深度好文

  2. test

    测试评论

添加新评论