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

加载更多搜索结果...

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

如何在 CentOS 7 上使用 Nginx 安装 Phorum

在此页

  1. 要求
  2. 先决条件
  3. 初始步骤
  4. 第 1 步 - 安装 PHP
  5. 第 2 步 - 安装 MariaDB 并创建数据库
  6. 第 3 步 - 安装 acme.sh 客户端并获取 Let\>)
  7. 第 4 步 - 安装和配置 NGINX
  8. 第 4 步 - 安装 Phorum

Phorum 是一个基于 PHP 和 MySQL 的开源论坛软件。在本指南中,我们将逐步指导您在 CentOS 7 操作系统上安装 Phorum,使用 Nginx 作为 Web 服务器,MariaDB 作为数据库,使用 acme.sh 和 Lets Encrypt for HTTPS。

要求

运行 Phorum 的要求是:

  • Nginx
  • PHP 5.2 或更高版本
  • MySQL/MariaDB 5.0 或更高版本

先决条件

  • CentOS 7 操作系统。
  • 具有 sudo 权限的非根用户。

初始步骤

检查您的 CentOS 版本:

cat /etc/centos-release
# CentOS Linux release 7.6.1810 (Core)

设置时区:

timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'

更新您的操作系统包(软件)。这是重要的第一步,因为它确保您拥有操作系统默认软件包的最新更新和安全修复程序:

sudo yum update -y

安装 CentOS 操作系统基本管理所需的一些基本软件包:

sudo yum install -y curl wget vim git unzip socat bash-completion epel-release

第 1 步 - 安装 PHP

安装 PHP 以及必要的 PHP 扩展:

sudo yum install -y php php-cli php-fpm php-common php-mysql

要显示在模块中编译的 PHP,您可以运行:

php -m

ctype
curl
exif
fileinfo
. . .
. . .

检查 PHP 版本:

php --version

# PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

启动并启用 PHP-FPM 服务:

sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service

第 2 步 - 安装 MariaDB 并创建数据库

安装 MariaDB 数据库服务器:

sudo yum install -y mariadb-server

检查 MariaDB 版本:

mysql --version

启动并启用 MariaDB 服务:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

运行 mysql_secure 安装 脚本以提高 MariaDB 安全性并为 MariaDB root 用户设置密码:

sudo mysql_secure_installation

回答每个问题:

Would you like to setup VALIDATE PASSWORD plugin? N
New password: your_secure_password
Re-enter new password: your_secure_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

以根用户身份连接到 MariaDB shell:

sudo mysql -u root -p
# Enter password

创建一个空的 MariaDB 数据库和用户并记住凭据:

MariaDB> CREATE DATABASE dbname;
MariaDB> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
MariaDB> FLUSH PRIVILEGES;

退出 MariaDB:

MariaDB> exit

将 dbname、username 和 password 替换为您自己的名称。

第 3 步 - 安装 acme.sh 客户端并获取 Lets Encrypt 证书(可选)

不必使用 HTTPS 保护您的论坛,但这是保护您的网站流量的好习惯。为了从 Lets Encrypt 获得 TLS 证书,我们将使用 acme.sh 客户端。 Acme.sh 是一款纯 UNIX shell 软件,用于从 Lets Encrypt 以零依赖方式获取 TLS 证书。

下载并安装 acme.sh:

sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh 
./acme.sh --install --accountemail 
source ~/.bashrc
cd ~

检查 acme.sh 版本:

acme.sh --version
# v2.8.0

为您的域/主机名获取 RSA 和 ECC/ECDSA 证书:<br>

# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256

如果你想要假证书进行测试,你可以在上面的命令中添加 --staging 标志。

运行上述命令后,您的证书和密钥将位于:

  • 对于 RSA:/home/username/example.com 目录。
  • 对于 ECC/ECDSA:/home/username/example.com_ecc 目录。

要列出您颁发的证书,您可以运行:

acme.sh --list

创建一个目录来存储您的证书。我们将使用 /etc/letsencrypt 目录。

mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc

安装/复制证书到 /etc/letsencrypt 目录。

# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

所有证书将每 60 天自动更新一次。

获得证书后,从 root 用户退出并返回到普通 sudo 用户:

exit

第 4 步 - 安装和配置 NGINX

安装 Nginx:

sudo yum install -y nginx

检查 NGINX 版本:

sudo nginx -v
# nginx version: nginx/1.12.2

启动并启用 Nginx 服务:

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

为 Phorum 配置 NGINX。运行 sudo vim /etc/nginx/conf.d/phorum.conf 并添加以下配置。

server {
  listen 80;
  listen 443 ssl;
  server_name example.com;
  root /var/www/phorum;
ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
index index.php index.html; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } }

检查 NGINX 配置是否存在语法错误:

sudo nginx -t

重新加载 NGINX 服务:

sudo systemctl reload nginx.service

第 4 步 - 安装 Phorum

为 Phorum 创建文档根目录:

sudo mkdir -p /var/www/phorum

将 /var/www/phorum 目录的所有权更改为 [jour_user]:

sudo chown -R [your_user]:[your_user] /var/www/phorum

导航到文档根目录:

cd /var/www/phorum

从官方网站下载最新稳定的 Phorum 发行版:

wget https://www.phorum.org/downloads/phorum-5.2.23.tar.gz

解压缩下载的存档并将文件移动到文档根目录:

tar xvzf phorum-5.2.23.tar.gz
rm phorum-5.2.23.tar.gz
mv Core-phorum_5_2_23/* . && mv Core-phorum_5_2_23/.* .
rmdir Core-phorum_5_2_23

配置数据库访问:

cp include/db/config.php.sample include/db/config.php

通过编辑 include/db/config.php 文件配置数据库设置:

vim include/db/config.php

将 /var/www/phorum 目录的所有权更改为 nginx:

sudo chown -R nginx:nginx /var/www/phorum

运行 sudo vim /etc/php-fpm.d/www.conf 并将用户和组设置为 nginx:

sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx

重启 PHP-FPM 服务:

sudo systemctl restart php-fpm.service

要完成安装,请在网络浏览器中访问 http://forum.example.com/admin.php 运行基于网络的安装程序。

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