Install and enable MariaDB 10.4 and bind it to localhost:
pkg install -y mariadb104-server sysrc mysql_enable="YES" sysrc mysql_args="--bind-address=127.0.0.1" service mysql-server start
Secure the new MariaDB installation by running
mysql_secure_installation. There is no root password currently, so press Enter. When asked to set a root password, press Enter and type a strong password. Press Enter for the remaining options to finish securing the server.
Creating a database
While we’re still working with MariaDB, let’s create a user and database for Nextcloud. Start by running
mysql -u root -p and entering the root password you set above.
At the SQL prompt, run the following commands:
CREATE DATABASE nextcloud; CREATE USER 'nc_admin'@'localhost' IDENTIFIED BY '<password>'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'nc_admin'@'localhost'; FLUSH PRIVILEGES; exit
Take note of the password you set for
nc_admin as you’ll need it later.
Install PHP 7.3, as well as the MySQL/MariaDB extension:
pkg install -y php73 php73-mysqli
Copy the example config file to
You may want to edit the config file to suit your needs. In particular, Nextcloud might complain if
memory_limit isn’t at least
512M (default is
To tell Apache how to handle PHP files, create the file
/usr/local/etc/apache24/Includes/php.conf and add the following:
<IfModule dir_module> DirectoryIndex index.php index.html <FilesMatch "\.php$"> SetHandler proxy:fcgi://127.0.0.1:9000 </FilesMatch> </IfModule>
This routes any requests for files with the
.php extension through the PHP-FPM daemon. PHP-FPM was installed when we installed PHP, but it still needs to be enabled:
sysrc php_fpm_enable="YES" service php-fpm start
By default, the daemon runs on TCP port 9000 and only accepts connections from the local machine. The configuration can be modified by editing
/usr/local/etc/php-fpm.d/www.conf. General PHP settings are located in
Restart the web server with
service apache24 restart. To check that PHP is being loaded properly, create the file
/usr/local/www/apache24/data/info.php with the following contents:
<?php phpinfo(); ?>
This file can be viewed at
http://www.yourdomain.com/info.php. If PHP handling is working, it will show a table full of info about the server and loaded PHP modules. The “Server API” field should read “FPM/FastCGI”. Delete the file when you’re done so it doesn’t pose a security risk.
Important: When installing new PHP extensions, you must reload PHP-FPM with
service php-fpm restart to enable them. Restarting the web server, as with
mod_php, is not enough.
- PHP config file:
- FPM config file:
- FPM pool config files: