{"id":1815,"date":"2018-12-23T22:22:29","date_gmt":"2018-12-23T19:22:29","guid":{"rendered":"http:\/\/kifarunix.com\/?p=1815"},"modified":"2024-03-11T21:42:11","modified_gmt":"2024-03-11T18:42:11","slug":"install-apache-mysql-php-famp-stack-on-freebsd-12","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-apache-mysql-php-famp-stack-on-freebsd-12\/","title":{"rendered":"Install FAMP Stack on FreeBSD 12"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"466\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/FAMB-freebsd.png\" alt=\"Install FAMP Stack on FreeBSD 12\" class=\"wp-image-16964\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/FAMB-freebsd.png?v=1685862424 780w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/FAMB-freebsd-768x459.png?v=1685862424 768w\" sizes=\"(max-width: 780px) 100vw, 780px\" \/><\/figure><\/div>\n\n\n<p>Welcome to our tutorial on how to install FAMB Stack on FreeBSD 12. FAMP Stack is an acronym for <a href=\"https:\/\/www.freebsd.org\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>F<\/strong>reeBSD<\/a>, the Operating System, <strong>A<\/strong>pache the web server, <strong>M<\/strong>ySQL the database server and<strong> P<\/strong>HP the server side scripting language.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-famp-stack-on-free-bsd-12\">Installing FAMP Stack on FreeBSD 12<\/a><ul><li><a href=\"#update-package-repository\">Update Package Repository<\/a><\/li><li><a href=\"#install-apache-on-free-bsd-12\">Install Apache on FreeBSD 12<\/a><ul><li><a href=\"#start-and-enable-apache\">Start and Enable Apache<\/a><\/li><\/ul><\/li><li><a href=\"#install-my-sql-on-free-bsd-12\">Install MySQL on FreeBSD 12<\/a><ul><li><a href=\"#start-and-enable-my-sql-service\">Start and Enable MySQL Service<\/a><\/li><li><a href=\"#run-my-sql-initial-secure-script\">Run MySQL Initial Secure Script<\/a><\/li><\/ul><\/li><li><a href=\"#install-php-on-free-bsd-12\">Install PHP on FreeBSD 12<\/a><ul><li><a href=\"#configure-php\">Configure PHP<\/a><\/li><\/ul><\/li><li><a href=\"#configure-apache-web-server\">Configure Apache Web Server<\/a><\/li><li><a href=\"#test-apache-php-processing\">Test Apache PHP Processing<\/a><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-famp-stack-on-free-bsd-12\">Installing FAMP Stack on FreeBSD 12<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"update-package-repository\">Update Package Repository<\/h3>\n\n\n\n<p>Run the command below to update FreeBSD package repository;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pkg update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-apache-on-free-bsd-12\">Install Apache on FreeBSD 12<\/h3>\n\n\n\n<p>Apache Web server is available on the default FreeBSD repositories and can be installed using the <code>pkg<\/code> package manager.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pkg install apache24<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"start-and-enable-apache\">Start and Enable Apache<\/h4>\n\n\n\n<p>To start and enable Apache web server to run on system boot, run the commands below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sysrc apache24_enable=yes<\/code><\/pre>\n\n\n\n<p>This will add the line <code>apache24_enable=\"yes\"<\/code> at the end of the <code>\/etc\/rc.conf<\/code> configuration file.<\/p>\n\n\n\n<p>Start Apache<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">service apache24 start<\/pre>\n\n\n\n<p>You can check the status of Apache as shown below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">service apache24 status\napache24 is running as pid 1206.<\/pre>\n\n\n\n<p>Note that we are using the default Apache FreeBSD configurations in this demo.<\/p>\n\n\n\n<p>To verify that you can actually access you web server from the browser, navigate to the browser and type the IP address of your web server. If everything is working fine, you should be able to see the default FreeBSD Apache web page which says, &#8220;<strong><code>It Works!<\/code><\/strong>&#8220;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-my-sql-on-free-bsd-12\">Install MySQL on FreeBSD 12<\/h3>\n\n\n\n<p>Just like Apache, MySQL can be installed directly from default FreeBSD 12 default repositories using the package manager. To install MySQL 8.0, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pkg install mysql80-server<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"start-and-enable-my-sql-service\">Start and Enable MySQL Service<\/h4>\n\n\n\n<p>Enable MySQL as a service so it can start on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sysrc mysql_enable=yes<\/pre>\n\n\n\n<p>The start it;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">service mysql-server start<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"run-my-sql-initial-secure-script\">Run MySQL Initial Secure Script<\/h4>\n\n\n\n<p>Run the normal MySQL security script to remove some default configurations.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql_secure_installation<\/pre>\n\n\n\n<p>The script may prompt you whether to enforce strong password creation. If you need to enforce secure password creation, then press <strong>y <\/strong> to accept and choose the level of password validation policy.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\nVALIDATE PASSWORD COMPONENT can be used to test passwords\nand improve security. It checks the strength of password\nand allows the users to set only those passwords which are\nsecure enough. Would you like to setup VALIDATE PASSWORD component?\n\nPress y|Y for Yes, any other key for No: y\n\nThere are three levels of password validation policy:\n\nLOW    Length >= 8\nMEDIUM Length >= 8, numeric, mixed case, and special characters\nSTRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file\n\nPlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1\nPlease set the password for root here.\n\nNew password: <strong>STRONG PASS<\/strong>\n\nRe-enter new password: <strong>STRONG PASS<\/strong>\n\nEstimated strength of the password: 100 \nDo you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y\n<\/code><\/pre>\n\n\n\n<p>Next;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>remove anonymous users,<\/li>\n\n\n\n<li>disallow remote root login,<\/li>\n\n\n\n<li>remove test databases<\/li>\n\n\n\n<li>reload privilege tables to effect the changes.<\/li>\n<\/ul>\n\n\n\n<pre class=\"scroll-box\"><code>\nBy default, a MySQL installation has an anonymous user,\nallowing anyone to log into MySQL without having to have\na user account created for them. This is intended only for\ntesting, and to make the installation go a bit smoother.\nYou should remove them before moving into a production\nenvironment.\n\nRemove anonymous users? (Press y|Y for Yes, any other key for No) : y\nSuccess.\n\n\nNormally, root should only be allowed to connect from\n'localhost'. This ensures that someone cannot guess at\nthe root password from the network.\n\nDisallow root login remotely? (Press y|Y for Yes, any other key for No) : y\nSuccess.\n\nBy default, MySQL comes with a database named 'test' that\nanyone can access. This is also intended only for testing,\nand should be removed before moving into a production\nenvironment.\n\n\nRemove test database and access to it? (Press y|Y for Yes, any other key for No) : y\n - Dropping test database...\nSuccess.\n\n - Removing privileges on test database...\nSuccess.\n\nReloading the privilege tables will ensure that all changes\nmade so far will take effect immediately.\n\nReload privilege tables now? (Press y|Y for Yes, any other key for No) : y\nSuccess.\n\nAll done!\n<\/code><\/pre>\n\n\n\n<p>You can now login to your MySQL server and create your databases!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-php-on-free-bsd-12\">Install PHP on FreeBSD 12<\/h3>\n\n\n\n<p>PHP works with HTML to generate dynamic web content. In order for PHP to connect to MySQL database to retrieve information for serving to the web server, you need to install PHP Apache and MySQL extensions. The following command installs the most common PHP modules.<\/p>\n\n\n\n<p>Note that as of this writing, PHP 8.2 is the current stable release available on FreeBSD 12 repositories.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pkg install php82 php82-mysqli mod_php82 php82-mbstring php82-zlib php82-curl php82-gd<\/pre>\n\n\n\n<p>If you require other PHP extensions, you can simply search and install them as shown above.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"configure-php\">Configure PHP<\/h4>\n\n\n\n<p>Copy the sample PHP configuration file into place and regenerate system cached information about installed binaries.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cp \/usr\/local\/etc\/php.ini{-production,}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">rehash<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure-apache-web-server\">Configure Apache Web Server<\/h3>\n\n\n\n<p>Configure Apache to process PHP pages by creating a <code>php.conf<\/code> configuration file under <code>\/usr\/local\/etc\/apache24\/Includes\/<\/code> with the following contents;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/usr\/local\/etc\/apache24\/Includes\/php.conf<\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n&lt;IfModule dir_module&gt;\n    DirectoryIndex index.php index.html\n    &lt;FilesMatch \"\\.php$\"&gt;\n        SetHandler application\/x-httpd-php\n    &lt;\/FilesMatch&gt;\n    &lt;FilesMatch \"\\.phps$\"&gt;\n        SetHandler application\/x-httpd-php-source\n    &lt;\/FilesMatch&gt;\n&lt;\/IfModule&gt;\n<\/code><\/pre>\n\n\n\n<p>Save and exit the file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"test-apache-php-processing\">Test Apache PHP Processing<\/h3>\n\n\n\n<p>Create PHP test configuration file under the Apache default document root directory to verify whether PHP is working well with Apache web server. The default document root directory is <code>\/usr\/local\/www\/apache24\/data\/test.php<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/usr\/local\/www\/apache24\/data\/test.php<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php phpinfo(); ?&gt;<\/code><\/pre>\n\n\n\n<p>Save the file and restart Apache for the changes to take effect.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">service apache24 restart<\/pre>\n\n\n\n<p>Navigate to the browser and the address in the format, <code>http:\/\/server_IP_address\/test.php<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1061\" height=\"941\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/freebsd-php-testing.png\" alt=\"Install FAMP Stack on FreeBSD 12\" class=\"wp-image-16966\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/freebsd-php-testing.png?v=1685864251 1061w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/freebsd-php-testing-768x681.png?v=1685864251 768w\" sizes=\"(max-width: 1061px) 100vw, 1061px\" \/><\/figure>\n\n\n\n<p>Beautiful. Now remove the test file from your server to avoid exposing the information about server to the public.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rm -rf \/usr\/local\/www\/apache24\/data\/test.php<\/pre>\n\n\n\n<p>That is all it takes to install FAMP Stack on FreeBSD 12.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p>You can as well check our other articles by following the links below;<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-nginx-mysql-php-femp-stack-on-freebsd-12\/\" target=\"_blank\">Install Nginx, MySQL, PHP (FEMP) Stack on FreeBSD 12<\/a>.<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-and-configure-openvpn-server-freebsd-12\/\" target=\"_blank\">Install and Configure OpenVPN Server FreeBSD 12<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-and-configure-telegraf-on-freebsd-12\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install and Configure Telegraf on FreeBSD 12<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-install-phpmyadmin-on-freebsd-12\/\" target=\"_blank\">How to Install phpMyAdmin on FreeBSD 12<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-install-freebsd-12-on-virtualbox\/\" target=\"_blank\">How to Install FreeBSD 12 on VirtualBox<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-phpmyadmin-with-nginx-on-freebsd-12\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install phpMyAdmin with Nginx on FreeBSD 12<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to our tutorial on how to install FAMB Stack on FreeBSD 12. FAMP Stack is an acronym for FreeBSD, the Operating System, Apache the<\/p>\n","protected":false},"author":1,"featured_media":16964,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,299,280,342,938],"tags":[279,278,6829,6828,6830],"class_list":["post-1815","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-database","category-freebsd","category-php","category-phpmyadmin","tag-famp-stack","tag-freebsd-12","tag-freebsd-12-install-mysql-8","tag-install-famb-stack-on-freebsd","tag-install-php-8-on-freebsd","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/1815"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=1815"}],"version-history":[{"count":10,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/1815\/revisions"}],"predecessor-version":[{"id":21075,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/1815\/revisions\/21075"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/16964"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=1815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=1815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=1815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}