{"id":4718,"date":"2019-12-01T17:35:40","date_gmt":"2019-12-01T14:35:40","guid":{"rendered":"https:\/\/kifarunix.com\/?p=4718"},"modified":"2024-03-12T23:40:53","modified_gmt":"2024-03-12T20:40:53","slug":"install-php-7-4-on-freebsd-12","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-php-7-4-on-freebsd-12\/","title":{"rendered":"Install PHP 7.4 on FreeBSD 12"},"content":{"rendered":"\n<p>In this guide, we are going to learn how to install PHP 7.4 on FreeBSD 12. PHP 7.4, which marks the fourth feature update to the PHP 7 series has just been released as of this writing. It comes with a lot improvements and new features as described on the <a rel=\"noreferrer noopener\" aria-label=\"PHP 7.4 new features page (opens in a new tab)\" href=\"https:\/\/www.php.net\/manual\/en\/migration74.new-features.php\" target=\"_blank\">PHP 7.4 new features page<\/a>.<\/p>\n\n\n\n<p>You can also check the new changes on PHP 7.4 on <a aria-label=\"PHP 7.4 Changelog (opens in a new tab)\" href=\"https:\/\/www.php.net\/ChangeLog-7.php#7.4.0\" target=\"_blank\" rel=\"noreferrer noopener\">PHP 7.4 Changelog<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing PHP 7.4 on FreeBSD 12<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Run System Update<\/h3>\n\n\n\n<p>To begin, update your system packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pkg update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pkg upgrade<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install PHP 7.4 from FreeBSD Repositories<\/h3>\n\n\n\n<p>There are two ways in which PHP 7.4 can be installed on a FreeBSD 12 box; from FreeBSD ports or FreeBSD package repositories. In this guide, PHP 7.4 is installed from FreeBSD package repos by executing the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pkg install php74<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Updating FreeBSD repository catalogue...\nFreeBSD repository is up to date.\nAll repositories are up to date.\nThe following 3 package(s) will be affected (of 0 checked):\n\nNew packages to be INSTALLED:\n <strong>php74: 7.4.0<\/strong>\n libargon2: 20190702\n pcre2: 10.33\n\nNumber of packages to be installed: 3\n\nThe process will require 35 MiB more space.\n5 MiB to be downloaded.\n\nProceed with this action? [y\/N]: y<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Verifying Installed PHP Version on FreeBSD 12<\/h3>\n\n\n\n<p>The command above installed PHP 7.4. However, you can still verify this by running either of the commands below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pkg info php74<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>php74-7.4.0\nName           : php74\nVersion        : 7.4.0\nInstalled on   : Fri Jun 21 20:38:37 2019 EAT\nOrigin         : lang\/php74\nArchitecture   : FreeBSD:12:amd64\nPrefix         : \/usr\/local\nCategories     : devel lang www\nLicenses       : PHP301\nMaintainer     : tz@FreeBSD.org\nWWW            : https:\/\/www.php.net\/\nComment        : PHP Scripting Language\nOptions        :\n\tCGI            : on\n\tCLI            : on\n\tDEBUG          : off\n\tDTRACE         : on\n\tEMBED          : on\n\tFPM            : on\n\tIPV6           : on\n\tLINKTHR        : on\n\tMYSQLND        : on\n\tPHPDBG         : off\n\tZTS            : off\nShared Libs required:\n\tlibxml2.so.2\n\tlibargon2.so.0\nShared Libs provided:\n\tlibphp7.so\nAnnotations    :\n\tFreeBSD_version: 1200086\n\tcpe            : cpe:2.3:a:php:php:7.4.0:::::freebsd12:x64\n\trepo_type      : binary\n\trepository     : FreeBSD\nFlat size      : 27.5MiB\nDescription    :\nPHP, which stands for \"PHP: Hypertext Preprocessor\" is a widely-used Open\nSource general-purpose scripting language that is especially suited for\nWeb development and can be embedded into HTML.  Its syntax draws upon C,\nJava, and Perl, and is easy to learn.  The main goal of the language is to\nallow web developers to write dynamically generated webpages quickly, but\nyou can do much more with PHP.\n\nWWW: https:\/\/www.php.net\/<\/code><\/pre>\n\n\n\n<p>Similarly;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>php -v<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>PHP 7.4.0 (cli) (built: Nov 30 2019 01:12:56) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies<\/code><\/pre>\n\n\n\n<p>If you have web server installed, you can similarly verify PHP 7.4 installation by creating a PHP test file as shown below.<\/p>\n\n\n\n<p>For example, if you have Apache installed, simply create a PHP 7.4 test file on the document root folder as follows.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>echo '<code>&lt;?php phpinfo(); ?&gt;<\/code>' &gt; \/usr\/local\/www\/apache24\/data\/info.php<\/code><\/pre>\n\n\n\n<p>Note that Apache can only process PHP files. Hence, ensure that you have <strong><code>mod_php<\/code><\/strong> modules installed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pkg install mod_php74<\/code><\/pre>\n\n\n\n<p>Next, you need to tell Apache to process PHP files by creating a&nbsp;<code>php.conf<\/code>&nbsp;configuration file under&nbsp;<code>\/usr\/local\/etc\/apache24\/Includes\/<\/code>&nbsp;with the following contents;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/usr\/local\/etc\/apache24\/Includes\/php.conf<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&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;<\/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\"><code>service apache24 restart<\/code><\/pre>\n\n\n\n<p>On the browser, enter the address, <code>http:\/\/server_IP_address\/info.php<\/code> to verify PHP installation.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"871\" height=\"689\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/12\/php-74.png\" alt=\"\" class=\"wp-image-4721\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/12\/php-74.png?v=1575210217 871w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/12\/php-74-768x608.png?v=1575210217 768w\" sizes=\"(max-width: 871px) 100vw, 871px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Install PHP Modules\/Extensions on FreeBSD 12<\/h3>\n\n\n\n<p>If you need to extend the functionality of PHP on FreeBSD 12 box, you can install the modules\/extensions by running the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pkf install php74-<strong>module-name<\/strong><\/code><\/pre>\n\n\n\n<p>Where <strong>module-name<\/strong> represents the PHP 7.4 module or extension that you need to install.<\/p>\n\n\n\n<p>For example, the command below installs various PHP 7.4 modules\/extensions for various functionalities.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pkg install php74 php74-mysqli php74-mbstring php74-zlib php74-curl php74-gd php74-json<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Updating FreeBSD repository catalogue...\nFreeBSD repository is up to date.\nAll repositories are up to date.\nThe following 11 package(s) will be affected (of 0 checked):\n\nNew packages to be INSTALLED:\n\tphp74-mysqli: 7.4.0\n\tphp74-mbstring: 7.4.0\n\tphp74-zlib: 7.4.0\n\tphp74-curl: 7.4.0\n\tphp74-gd: 7.4.0\n\tphp74-json: 7.4.0\n\toniguruma: 6.9.3\n\tcurl: 7.66.0\n\tlibgd: 2.2.5_2,1\n\twebp: 1.0.3_1\n\tgiflib: 5.1.9\n\nNumber of packages to be installed: 11\n\nThe process will require 13 MiB more space.\n3 MiB to be downloaded.\n\nProceed with this action? &#91;y\/N]: y<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>Well, that marks the end of our simple tutorial. If you have any web application that you need to run on a FreeBSD 12 box, you check our other articles on how to setup LAMP or LEMP stack by following the links below;<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" 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-apache-mysql-php-famp-stack-on-freebsd-12\/\" target=\"_blank\">Install Apache, MySQL, PHP (FAMP) Stack on FreeBSD 12<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Other FreeBSD 12 tutorials<\/h4>\n\n\n\n<p><a rel=\"noreferrer noopener\" 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\">Install and Configure Telegraf on FreeBSD 12<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" 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\" 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 rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/install-phpmyadmin-with-nginx-on-freebsd-12\/\" target=\"_blank\">Install phpMyAdmin with Nginx on FreeBSD 12<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we are going to learn how to install PHP 7.4 on FreeBSD 12. PHP 7.4, which marks the fourth feature update to<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,280,201,235,342],"tags":[278,1132,1209],"class_list":["post-4718","post","type-post","status-publish","format-standard","hentry","category-howtos","category-freebsd","category-lamp-stack","category-lemp-stack","category-php","tag-freebsd-12","tag-php-7-4","tag-php-7-4-freebsd-12","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4718"}],"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=4718"}],"version-history":[{"count":4,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4718\/revisions"}],"predecessor-version":[{"id":21294,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4718\/revisions\/21294"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=4718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=4718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=4718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}