How to install Phorum with Nginx on Fedora 30

How to install Phorum with Nginx on Fedora 30

Phorum is an open source forum software based on PHP and MySQL. In this guide, we will guide you step by step using Nginx as the web server, MariaDB as the database, and Phorum installation process of acme.sh and Let’s Encrypt for HTTPS on Fedora 30 operating system.

Claim

The requirements for running Phorum are:

  • Nginx
  • PHP 5.2 or higher
  • MySQL 5.0 or higher

prerequisites

  • Fedora 30 operating system.
  • Non-root user with the following permissions sudo privilege.

Preliminary steps

Check your Fedora system version:

cat /etc/fedora-release# Fedora release 30 (Thirty)

Set time zone:

timedatectl list-timezonessudo timedatectl set-timezone 'Region/City'

Update your operating system package (software). This is an important first step because it ensures that you have the latest updates and security fixes for the operating system’s default packages:

sudo dnf upgrade -y

Install some basic packages that are required for basic management of the Fedora operating system:

sudo dnf install -y curl wget vim git sudo unzip socat bash-completion

Step 1-install PHP

Install PHP and necessary PHP extensions:

sudo dnf install -y php php-cli php-fpm php-common php-mysqlnd

To display PHP compiled in the module, run:

php -mctypecurlexiffileinfo. . .. . .

Check PHP version:

php --version# PHP 7.3.5 (cli) (built: Apr 30 2019 08:37:17) ( NTS )# Copyright (c) 1997-2018 The PHP Group# Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies

Start and enable the PHP-FPM service:

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

Step 2-install MariaDB and create database

Install MariaDB database server

sudo dnf install -y mariadb-server

Check MariaDB version:

mysql --version# mysql  Ver 15.1 Distrib 10.3.12-MariaDB, for Linux (x86_64) using readline 5.1

Start and enable MariaDB service:

sudo systemctl start mariadb.servicesudo systemctl enable mariadb.service

Run mysql_secure installation Script to increase MariaDB security and set password for MariaDB root user:

sudo mysql_secure_installation

Answer each question:

Would you like to setup VALIDATE PASSWORD plugin? NNew password: your_secure_passwordRe-enter new password: your_secure_passwordRemove anonymous users? [Y/n] YDisallow root login remotely? [Y/n] YRemove test database and access to it? [Y/n] YReload privilege tables now? [Y/n] Y

Connect to MariaDB Shell as root user:

sudo mysql -u root -p# Enter password

Create an empty MariaDB database and user for Phorum, and remember the credentials:

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

Exit from MariaDB:

mysql> exit

Replace dbname, username with password Use your own name.

Step 3-Installation acme.sh Client and get “Let’s Encrypt” certificate (optional)

There is no need to use HTTPS to protect the forum, but it is a good practice to keep your site traffic secure. In order to obtain a TLS certificate from Let’s Encrypt, we will use the acme.sh client. Acme.sh is a pure UNIX Shell software for obtaining TLS certificates from Let’s Encrypt with zero dependencies.

Download and install acme.sh:

sudo su - rootgit clone https://github.com/Neilpang/acme.sh.gitcd acme.sh ./acme.sh --install --accountemail [email protected]source ~/.bashrccd ~

Check the acme.sh version:

acme.sh --version# v2.8.0

Gain RSA with ECC / ECDSA Your domain / hostname certificate:

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

If you want to test with a fake certificate, you can add --staging Mark the above command.

After running the above command, your certificate and key will be located at:

  • For RSA: /home/username/example.com table of Contents.
  • For ECC / ECDSA: /home/username/example.com_ecc table of Contents.

To list the certificates you issued, you can run:

acme.sh --list

Create a directory to store your certificates. We will use /etc/letsencrypt table of Contents.

mkdir -p /etc/letsecnrypt/example.comsudo mkdir -p /etc/letsencrypt/example.com_ecc

Install / copy the certificate into the / etc / letsencrypt directory.

# RSAacme.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/ECDSAacme.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"

All certificates will be automatically renewed every 60 days.

After obtaining the certificate, log out from the root user and return to the normal sudo user:

exit

Step 4-install and configure NGINX

Install NGINX:

sudo dnf install -y nginx

Check NGINX version:

nginx -v# nginx version: nginx/1.16.0

Start and enable the NGINX service:

sudo systemctl start nginx.servicesudo systemctl enable nginx.service

Configure NGINX Run for Phorum sudo vim /etc/nginx/conf.d/phorum.conf And add the following configuration.

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$ {
    include default.d/php.conf;    try_files $uri $uri/ /index.php?$query_string;    fastcgi_split_path_info ^(.+.php)(/.+)$;    fastcgi_pass unix:/run/php-fpm/www.sock;    fastcgi_index index.php;    include fastcgi_params;    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;    fastcgi_param PATH_INFO $fastcgi_path_info;
  }
}

Check the NGINX configuration for syntax errors:

sudo nginx -t

Reload the NGINX service:

sudo systemctl reload nginx.service

Step 4-install Phorum

Create a document root for Phorum:

sudo mkdir -p /var/www/phorum

Change ownership /var/www/phorum Directory to [jour_user]:

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

Navigate to the document root:

cd /var/www/phorum

Download the latest stable Phorum distribution from the official website:

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

Extract the downloaded archive and move the file to the document root directory:

tar xvzf phorum-5.2.23.tar.gzrm phorum-5.2.23.tar.gzmv Core-phorum_5_2_23/* . && mv Core-phorum_5_2_23/.* .rmdir Core-phorum_5_2_23

Configure database access:

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

Configure database settings by editing include/db/config.php file:

vim include/db/config.php

Change ownership /var/www/craft Directory to nginx:

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

Run sudo vim /etc/php-fpm.d/www.conf And set users and groups to nginx. Initially, they will be set to apache:

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

To complete the installation, run the web-based installer at http://forum.example.com/admin.php In your web browser.

Sidebar