<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="howdid.xsl"?> 

<articles>
  <article date="11 Aug 2023">
    <pagetitle>Putting the 'gAd' into 'phpPgAdmin'</pagetitle>
    <articleheader>Installing phpPgAdmin on Freebsd 13.</articleheader>
    <articleabstract>I installed phpPgAdmin, then I wrote down my notes so I wouldn't forget what I did. And now you're reading them</articleabstract>
    <articlebody>
<p class="articledisclaimer">I got some of this info from linuxhint.com<sup class="inlinefootnote">1</sup> and linuxhelp.com<sup class="inlinefootnote">2</sup> tutorials. Neither one was complete. This also assumes that you already have postgreSQL installed.</p>

<p>Start by installing the <code>databases/phppgadmin</code>. Your favorite package manager should install <code>www/apache24</code> and <code>lang/php81</code>, but it will not install <code>www/mod_php81</code>, so you should install that as well.</p>

<p>I'm using the default unmodified <code>php.ini</code>, which you can install by going to <code>/usr/local/etc</code> and copying <code>php.ini-production</code> to <code>php.ini</code> (you will need superuser powers to do this).</p>

<code><pre># cd /usr/local/etc
# cp php.ini-production php.ini
</pre></code>

<p>Test that PHP works by starting the php_fpm service. <code>service php-fpm onestart</code>. If there are no errors, continue configuring Apache by telling it what to do with php files. Create a file in <code>/usr/local/etc/apache24/modules.d</code>. You can call this file anything you want as long as it starts with three digits and an underscore. I called mine <code>001_mod-php.conf</code> and filled it with the following</p>

<code><pre>/usr/local/etc/apache24/modules.d/001_mod-php.conf 

&lt;IfModule dir_module&gt;
DirectoryIndex index.php index.html

&lt;FilesMatch "\.php$"&gt;
SetHandler application/x-httpd-php
&lt;/FilesMatch&gt;

&lt;FilesMatch "\.phps$"&gt;
SetHandler application/x-httpd-php-source
&lt;/FilesMatch&gt;

&lt;/IfModule&gt;

</pre></code>

<p>Test that Apache works by starting the <code>apache24</code> service. <code>service apache24 onestart</code>. You can also test if Apache is properly interpreting PHP files by creating one in the Apache's <code>DocumentRoot</code> folder, which is <code>/usr/local/www/apache24/data</code> by default. This file can have any PHP commands you want in it, but the classic test is by using <code>phpinfo</code>.</p>

<code><pre>/usr/local/www/apache24/data/test.php
&lt;?php phpinfo(); ?&gt;
</pre></code>

<p>If you open up your favorite web browser and go to <code>http://localhost/test.php</code> you should see a lot of info that you probably don't care about. If you just see the contents of the php file, then Apache is not actually processing php files correctly.</p>
 
<p>Next we need to tell Apache where the <code>phpPgAdmin</code> application is. To do this, we can make a <a href="https://man.freebsd.org/cgi/man.cgi?query=ln&amp;manpath=FreeBSD+13.2-RELEASE+and+Ports">symbolic link</a> in our <code>data</code> folder.</p>

<code># ln -s /usr/local/www/phpPgAdmin /usr/local/www/apache24/data</code>

<p>Now we can point our web browser to <code>http://localhost/phpPgAdmin</code>. If you see the phpPgAdmin page, then you're ready to go. You probably want to enable the <code>apache24</code> and <code>php_fpm</code> services so that they start up on reboot. You also probably want to add a user to <code>PostgreSQL</code> so you can log in to <code>phpPgAdmin</code>. You also probably want to secure your server if you're using this in a production environment. But that's another article.</p>

</articlebody>
    <footnotes>
      <footnote><a href="https://linuxhint.com/install-apache-php-mysql-on-freebsd/">https://linuxhint.com/install-apache-php-mysql-on-freebsd/</a></footnote>
      <footnote><a href="https://www.linuxhelp.com/how-to-install-phppgadmin-in-freebsd">https://www.linuxhelp.com/how-to-install-phppgadmin-in-freebsd</a></footnote>
    </footnotes>
  </article>
</articles>
