2019-02-09

Running phpBB3 forum on freenas jail (FreeBSD)

I. Create jail


1) creating jail with name "phpbb3"
 iocage create -n phpbb3 -r 11.2-RELEASE 

2) (optional) enable dhcp
iocage set vnet=on bpf=yes dhcp=on phpbb3

3) start jail
iocage start phpbb3

II. Install apache


1) login into jail
iocage console phpbb3

2) install apache
pkg install apache24 confirm prompts with y

3) configure apache service
sysrc apache24_enable=yes

4) start apache
service apache24 start

5) verify it works, browse to http://your_jail_ip you should see message "It works!"

III. Install php components


1) install php components
pkg install mod_php72 php72-mysqli php72-dom php72-iconv

2) copy sample php config file
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

IV. Configure apache to use php


1) add apache configuration file for php
nano /usr/local/etc/apache24/Includes/php.conf
enter the following contents:

DirectoryIndex index.php index.html SetHandler application/x-httpd-php SetHandler application/x-httpd-php-source

2) restart apache service service apache24 restart

3) create file for php test in default document root
nano /usr/local/www/apache24/data/info.php enter contents: save and exit

4) browse to http://your_jail_ip/info.php you should see a page with various php details.

5) delete the test file
rm /usr/local/www/apache24/data/info.php

V. Install Mysql

1) install mysql server package
pkg install mysql80-server
2) enable mysql service 
sysrc mysql_enable=yes
3) start mysql service
 service mysql-server start
4) run script to secure mysql installation
mysql_secure_installation
  • choose Y for VALIDATE PASSWORD COMPONENT, in this example we choose level 1 MEDIUM for validation policy
  • enter new password for root and re-enter it
  • choose y to remove anonymous users
  • choose y to allow only local login for root
  • choose y to remove default database and access to it
  • choose y to reload privileges
5) create new database for phpbb3
 a) login to mysql
  myslq -u root -p
 enter your password when prompted
 b) enter command for db creation and hit enter:
 CREATE DATABASE phpbb3;

6) create mysql user
CREATE USER 'phpbb3user'@'localhost' IDENTIFIED BY 'password123'

7) assign permissions for new users to phpbb3 database
 GRANT ALL PRIVILEGES ON phpbb3.* TO 'phpbb3user'@'localhost';

tbc...

8) legacy authentication stuff

9) reload privileges
FLUSH PRIVILEGES;

10) exit mysql
exit


VI. Install phpbb3

1) install package
pkg install phpbb3


tbc


Links used: https://www.digitalocean.com/community/tutorials/how-to-install-an-apache-mysql-and-php-famp-stack-on-freebsd-10-1 https://forums.freebsd.org/threads/installing-www-phpbb3.68616/ https://forums.freenas.org/index.php?threads/iocage-helper-thread.59988/
https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql