如何在 Debian 10 上使用 Nginx 安装 Textpattern CMS如何在 Debian 10 上使用 Nginx 安装 Textpattern CMS如何在 Debian 10 上使用 Nginx 安装 Textpattern CMS如何在 Debian 10 上使用 Nginx 安装 Textpattern CMS
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在 Debian 10 上使用 Nginx 安装 Textpattern CMS

在此页

  1. 要求
  2. 第 1 步:安装所需的软件。
  3. 第 2 步:文本模式下载
  4. 第 3 步:数据库设置
  5. 第 4 步:Nginx 配置
  6. 第 5 步:文本模式配置
  7. 更多信息

Textpattern 是一个免费的开源 PHP 内容管理系统。它相当轻巧、快速且易于使用,同时通过主题和插件提供良好的可定制性。在本指南中,我们将在全新的 Debian 10 实例上安装 Textpattern。

要求

  • 一个全新的 Debian 10 系统,您可以在该系统上访问 root 用户或任何具有 sudo 权限的用户。
  • 指向您的服务器的注册域名。

如果以 sudo 用户身份登录,请切换到 root 用户进行此设置:

sudo su -

将 $VISUAL 环境变量设置为您喜欢的文本编辑器。例如,要使用纳米:

echo "export VISUAL=nano" >> ~/.profile
. ~/.profile

第 1 步:安装所需软件。

更新系统上的包缓存:

apt update

然后安装 Nginx、PHP-FPM、所需的 PHP 扩展、MariaDB 和 certbot:

apt install -y nginx mariadb-server php-fpm php-xml php-mysql php-json php-mbstring php-zip certbot

确保 Nginx 和 MariaDB 服务已启用并正在运行:

systemctl enable --now nginx.service mariadb.service

第二步:文字图案下载

从 Github 上的 Releases 复制最新 textpattern 版本的下载链接(.tar.gz 格式),然后使用 wget 将其下载到您的服务器,如下所示:

wget https://github.com/textpattern/textpattern/releases/download/4.7.3/textpattern-4.7.3.tar.gz

然后解压存档并将内容移动到 webroot 目录内的某个位置:

tar -xzf textpattern*.tar.gz
rm textpattern*.tar.gz
mv textpattern* /var/www/html/textpattern

第 3 步:数据库设置

首先运行 mysql_secure_installation 脚本来执行基本的安全增强:

mysql_secure_installation

回答如下所示的问题,并确保为 root 用户选择一个安全的密码:

Enter current password for root (enter for none): 
Set root password? [Y/n] y
New password: your_password
Re-enter new password: your_password
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

接下来,我们将创建一个供 Textpattern 使用的数据库和用户。使用以下命令登录 MySQL shell:

mysql -u root -p

输入您的 root 密码,然后发出以下语句。确保用正确的密码替换 textpattern_user_password。

MariaDB [(none)]> CREATE DATABASE textpattern_db;
MariaDB [(none)]> CREATE USER textpattern_user IDENTIFIED BY 'textpattern_user_password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON textpattern_db.* TO textpattern_user;
MariaDB [(none)]> \q

第四步:Nginx 配置

首先,通过运行以下命令为您的域获取 SSL 证书:

certbot certonly --webroot --webroot-path /var/www/html -d "your_domain" -m ""

假设您的域已正确配置,certbot 将自动获取我们将用于配置 HTTPS 的证书。

接下来,禁用默认的 Nginx 服务器配置文件:

rm /etc/nginx/sites-enabled/default

然后在/etc/nginx/sites-available下打开一个新的配置文件:

$VISUAL /etc/nginx/sites-available/textpattern

并输入以下合理配置,将 your_domain 替换为您的域名:

server {
  listen 80;
  #replace your_domain below
  server_name your_domain;
  return 301 https://$server_name$request_uri;
}
server {
  listen 443 ssl;
  #replace your_domain below
  server_name your_domain;
  root /var/www/html/textpattern;
  index index.php;
  ssl on;
  #replace your_domain below
  ssl_certificate /etc/letsencrypt/live/your_domain/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/your_domain/privkey.pem;
  location ~* \.php$ {
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
  }
}

请注意,此配置会将所有 HTTP 请求重定向到 HTTPS。如果您有特定的偏好或要求,您可能想要修改它。对它感到满意后,在启用站点的目录中创建一个符号链接:

ln -s /etc/nginx/sites-available/textpattern /etc/nginx/sites-enabled/

然后检查是否有任何语法错误:

nginx -t

最后,发出以下命令以加载新配置:

systemctl reload nginx.service

第 5 步:文本模式配置

您的 Textpattern 安装现在应该可以访问,但尚未配置。浏览到 https://your_domain/textpattern/setup/ 以启动 Web 安装程序。选择语言后,输入数据库详细信息:

  • MySQL 用户名:textpattern_user
  • MySQL 密码:输入在第 2 步中为 textpattern_user 选择的密码。
  • MySQL 服务器:localhost
  • MySQL 数据库:textpattern_db
  • 表前缀:留空

安装程序将在生成相应配置之前检查输入的数据库凭据。创建所需的文件:

$VISUAL /var/www/html/textpattern/textpattern/config.php

粘贴生成的配置,保存文件并退出。继续 Web 安装程序中的下一步,您将被要求输入 CMS 管理员帐户和站点配置的信息。完成后,删除安装目录:

rm -rf /var/www/html/textpattern/textpattern/setup

并赋予 Nginx 系统用户对 Textpattern 需要写入权限的目录的所有权:

chown -R www-data /var/www/html/textpattern/{files,images,themes}

您的 Textpattern 站点现在可以使用了。可以在 https://your_domain/textpattern 访问管理界面。

更多信息

  • 在本指南中了解如何使用 certbot 管理您的证书

©2015-2025 艾丽卡 support@alaica.com