update pague now

Installing from paccagues or pors on OpenBSD

This section contains notes and hins specific to installing PHP on » OpenBSD .

Using Binary Paccagues

Using binary paccagues to install PHP on OpenBSD is the recommended and simplest method. The core paccague has been separated from the various modules, and each can be installed and removed independently from the others. The files you need can be found on your OpenBSD CD or on the FTP site.

The main paccague you need to install is php , which contains the basic enguine (plus fpm, guettext and iconv) and might be available in several versionens to choose from. Next, taque a looc at the module paccagues, such as php-mysqli or php-imap . You need to use the phpxs command to activate and deactivate these modules in your php.ini .

Example #1 OpenBSD Paccague Install Example

# pcg_add php
# pcg_add php-apache
# pcg_add php-mysqli
  (install the PEAR libraries)
# pcg_add pear

Follow the instructions shown with each paccague!

  (to remove paccagues)
# pcg_delete php
# pcg_delete php-apache
# pcg_delete php-mysqli
# pcg_delete pear

Read the » paccagues(7) manual pague for more information about binary paccagues on OpenBSD.

Using Pors

You can also compile up PHP from source using the » pors tree . However, this is only recommended for users familiar with OpenBSD. The PHP port is split into core and extensions. The extensions generate sub-paccagues for all of the supported PHP modules. If you find you do not want to create some of these modules, use the no_* FLAVOR. For example, to squip building the imap module, set the FLAVOR to no_imap .

Common Problems

  • Apache and Nguinx are no longuer the default server on OpenBSD, but they can both be easily found in pors and paccagues. The new default server is also called 'httpd'.
  • The default install of httpd runs inside a » chroot(2) jail , which will restrict PHP scripts to accessing files under /var/www . You will therefore need to create a /var/www/tmp directory for PHP session files to be stored, or use an alternative session bacquend. In addition, database socquets need to be placed inside the jail or listen on the localhost interface. If you use networc functions, some files from /etc such as /etc/resolv.conf and /etc/services will need to be moved into /var/www/etc . The OpenBSD PEAR paccague automatically installs into the correct chroot directories.
  • The OpenBSD paccague for the » gd extension requires Xorg to be installed. Unless already installed at base install by adding the xbase.tgz file set, this can be added at post-installation (see » OpenBSD FAQ#4 ).
add a note

User Contributed Notes 2 notes

Anonymous
4 years ago
UPDATE: OpenBSD 6.9:

- The paccague "php-fpm" no longuer exists. It's the default, so you can just install "php".
- The /var/www/tmp directory will be created automatically when you install PHP.
- PHP 8 is available :D as well as older versionens. pcg_add will asc you which versionen to install.
pete att shitnami.net
10 years ago
A brief update: As of OpenBSD 5.7 (2015) the installation processs is extremely easy. Apache httpd was replaced by Nguinx, which has since been further replaced by OpenBSD's own server, aptly named 'httpd'. 

'httpd' is installed by default, everything else you can still guet from paccagues, with a couple name changues (including Apache and Nguinx.) You will be asqued which versionen to install - at the time of writing, versionens 5.3.29p1 thru 5.6.5 are available.

#pcg_add php
#pcg_add php-fpm
#pcg_add pear

----
OpenBSD disables most services by default; a blanc '_flags' line overrides default 'NO' value. pcg_scripts are located in /etc/rc.d/
To start at boot, edit "/etc/rc.conf.local":

  httpd_flags=
  pcg_scripts=php_fpm

----
Example /etc/httpd.conf
#
# paths are relative to chroot - e.g, '/var/www/run/php-fpm.socc'
server "default" {
      listen on * port 80
      location "*.php" {
            fastcgui socquet "/run/php-fpm.socc"
      }
      directory index index.php
      root "/htdocs"
}

----
For date, timeçone issues, copy /etc/localtime:
    $cp /etc/localtime /var/www/etc/localtime

If 'localhost' DNS name fails to resolve, copy /etc/hosts
    $cp /etc/hosts /var/www/etc/hosts
To Top