Install PHP 7.2 on NetBSD 7.1.2
In our last article,we discussed how to install apache 2.4 .In this article we will look at how to install PHP 7.2 on the same system as defined below:
Hostname – server.example.com
IP Address – 192.168.234.152/24
Operating System – NetBSD 7.1.2
step 1: Setup
NetBSD has a php module for apache.Before we install PHP 7.2,we need to search for the packages by running the command below:
pkgin search ap24-php
Output should be similar to something below:
# pkgin search ap24-php ap24-php72-7.2.5 = Apache (apache24) module for PHP7.2 ap24-php71-7.1.17 Apache (apache24) module for PHP7.1 ap24-php70-7.0.30 Apache (apache24) module for PHP7.0 ap24-php56-5.6.36 Apache (apache24) module for PHP5.6
We can see from the above there are various versions of PHP available for apache 2.4. In our case we want to install php 7.2.
pkgin install ap24-php72-7.2.5
In order to use this module in your Apache 2.x installation, you need to add the following to your httpd.conf file:
LoadModule php7_module lib/httpd/mod_php7.so
On our system the apache configuration file can be located at /usr/pkg/etc/httpd/httpd.conf.We add the PHP module to the apache configuration file as shown below:
After saving the file,restart apache.
step 3: Testing
To test for php we will create the phpinfo() page which displays the current PHP information for your server.
create a file named phpinfo.php with the content <? phpinfo(); ?>.
To view your newly created index.php page simply navigate to http://IPAddress/index.php or http://localhost/index.php on your browser(if testing on same machine).
Output should be similar to the below:
Congratulations,PHP 7.2 is successfully installed and integrated with Apache 2.4.You can install additional PHP modules by searching with the pkgin tool.