[6.3] Upgrading PHP5?

Michael Powell nightrecon at verizon.net
Thu Sep 4 11:13:44 UTC 2008

Gilles wrote:

> Hello
> I successfully upgraded the Ports collection with csup and then
> compiled Apache2, but I don't know what to do about PHP5, as it has
> several Ports available:
> php5-5.2.6                          <   needs updating (port has
> 5.2.6_1)
This is the main PHP section.

> php5-bz2-5.2.6                      <   needs updating (port has
> 5.2.6_1)
> php5-ctype-5.2.6                    <   needs updating (port has
> 5.2.6_1)
> php5-curl-5.2.6                     <   needs updating (port has
> 5.2.6_1)
> etc.
These are the extensions.

Not quite sure what you're asking here. I use portupgrade to upgrade. I'm
not sure if you're asking about upgrading, or getting PHP going on the
Apache install for the first time. If it's already there and working but
just needs updating portupgrade can do this.

If you are coming into situation "in the middle" and have Apache up and
running correctly but these above mentioned ports are leftovers from before
you became involved you may consider simply deleting them and starting over
fresh. Either start over or update, both can work.

You can use pkg_delete, make deinstall in the port directory, or (if
portupgrade is installed) pkg_deinstall. The above list may be confusing
because there are two separate sections to a PHP install. The first is PHP
itself. This is /usr/ports/lang/php5 - a make config screen will come up
and in the options list you'll see one to include mod_php. There are a
couple of messages at the end containing a couple of lines you'll need to
add to httpd.conf for php to work.

The extensions are found here: /usr/ports/lang/php5-extensions These contain
all of the different PHP function modules. The most common example is this
is where you would add/activate MySQL access for PHP. When you do make, or
make config, in the port you will get a list to choose. You can install
only what you know you need, or you can install all of them and comment out
the ones you don't need in /usr/local/etc/php/extensions.ini 

As far as the httpd.conf goes you really need two things. One the mod_php
option should have probably installed and just needs checking. Look for a 

LoadModule php5_module    libexec/apache22/libphp5.so

entry at the bottom of the LoadModule list. The other are the two lines
mentioned at the end of the port install. Look for the <IfModule
mime_module> section. I think these are already present but commented out
(it's been a really long time since I've done a virgin install), if not add
(under the <IfModule mime_module> section in the httpd.conf):

        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps

The problem you'll encounter when these aren't present is the web server
will just serve up the contents of the .php script without actually running

A real easy test to see if PHP is working correctly is just create some file
in the root of your web server such as php_test.php containing this:


If everything is fine it'll return all the info on your PHP install. 

Hope this helps.


More information about the freebsd-questions mailing list