How to configure PHP, PHP-FPM, NGINX, and MariaDB in FreeBSD.
* This guide installs packages using pkg. Alternatively you can compile ports.
PHP
To find available php packages, use sudo pkg search -g "php8*"
.
Install what you need with sudo pkg install php83-XXX
.
For Drupal, I had to get these:
pkg install php83 php83-extensions php83-gd php83-composer php83-mbstring php83-mysqli php83-zlib php83-pecl-apcu php83-pecl-uploadprogress
Copy /usr/local/etc/php.ini-development to /usr/local/etc/php.ini, where you can customize settings.
PHP-FPM
* php-fpm is included with the php83 package.
sudo sysrc php_fpm_enabled="YES"
sudo service php-fpm start
Config is in /usr/local/etc/php-fpm.conf and /usr/local/etc/php-fpm.d/www.conf.
Run sudo service php-fpm reload
to update config changes.
NGINX
sudo pkg install nginx
sysrc nginx_enabled="YES"
service nginx start
MariaDB
sudo pkg install mariadb1011-server mariadb1011-client
sysrc mysql_enable="YES"
service mysql-server start
Apply security enhancements:
mysql_secure_installation
Create a database user:
Login to mariadb: sudo mysql
CREATE USER dbuser@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `db\_%`.* TO database@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit
Test with mysql -u dbuser -p password
.