Install Apache2, MariaDB and PHP (FAMP) Stack on FreeBSD

Step 1 – Install Apache Web Server

pkg update

pkg install apache24

sysrc apache24_enable="YES"

service apache24 start

service apache24 status


Step 2 – Install MariaDB Server

pkg search mariadb

pkg install mariadb1011-server-10.11.8_1 mariadb1011-client-10.11.8_1

sysrc mysql_enable="yes"

service mysql-server start

/usr/local/bin/mysql_secure_installation

mysql -u root -p -e "show databases"

Step 3 – Install PHP

pkg install php80 mod_php80 php80-mbstring php80-zlib php80-curl php80-gd php80-mysqli

nano /usr/local/etc/apache24/Includes/php.conf

<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>


nano /usr/local/www/apache24/data/info.php

<?php phpinfo(); ?>

membuat file php.ini

cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini-production.default
ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Lokasi file konfigurasi Apache di /usr/local/etc/apache24.
File konfigurasi Apache di /usr/local/etc/apache24/httpd.conf.
Lokasi webroot directory Apache di /usr/local/www/apache24/data/.

Membuat VirtualHost

Sebelumnya saya sudah mengubah file /etc/hosts pada Linux desktop client agar pada saat mengakses http://freebsd.ap mengarah ke IP server 192.168.56.100. Untuk client versi Windows, ubah file hosts di c:\Windows\System32\Drivers\etc\hosts.

nano /etc/hosts

192.168.56.100 freebsd.com

Selanjutnya membuat webroot directory untuk virtualhost di folder /home/user.

$ cd
$ mkdir -p /public_html/freebsd.com
$ cd public_html
# chmod -R 775 freebsd.com
# chown -R $USER:www freebsd.com

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/home/user/public_html/freebsd.com"
ServerName freebsd.com
ServerAlias www.freebsd.com
ErrorLog "/var/log/apache_freebsd.ap-error_log"
CustomLog "/var/log/apache_freebsd.ap-access_log" common
<Directory /home/user/public_html/freebsd.com>
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>


service apache24 restart



sumber : https://www.atlantic.net/dedicated-server-hosting/install-apache2-mariadb-and-php-famp-stack-on-freebsd/

Leave a Reply

Your email address will not be published. Required fields are marked *