PHP 8.3.4 Released!

Notas de instalación para OpenBSD

Esta sección contiene notas y consejos específicos a la instalación de PHP sobre » OpenBSD 3.6.

Utilizando paquetes binarios

Utilizar paquetes binarios para instalar PHP sobre OpenBSD es el método más simple y recomendado. El paquete principal ha sido separado de los distintos módulos, y cada uno puede ser instalado removido independientemente de los otros. Los ficheros que se necesitan pueden ser encontrados en el CD de OpenBSD o en el sitio FTP.

El paquete principal que se necesita instalar es php4-core-4.3.8.tgz, que contiene el motor básico (además de gettext e iconv). Seguido, tómese un vistazo a los paquetes de módulos, tales como php4-mysql-4.3.8.tgz o php4-imap-4.3.8.tgz. Se necesita emplear el comando phpxs para activar y desactivar estos módulos en el fichero php.ini.

Ejemplo #1 Ejemplo de instalación de paquete de OpenBSD

# pkg_add php4-core-4.3.8.tgz
# /usr/local/sbin/phpxs -s
# cp /usr/local/share/doc/php4/php.ini-recommended /var/www/conf/php.ini
  (agregar mysql)
# pkg_add php4-mysql-4.3.8.tgz
# /usr/local/sbin/phpxs -a mysql
  (agregar imap)
# pkg_add php4-imap-4.3.8.tgz
# /usr/local/sbin/phpxs -a imap
  (quitar mysql a manera de prueba)
# pkg_delete php4-mysql-4.3.8
# /usr/local/sbin/phpxs -r mysql
  (instalar las librerías de PEAR)
# pkg_add php4-pear-4.3.8.tgz

Leer la página del manual » packages(7) para mas información sobre paquetes binarios en OpenBSD.

Utilizando portes

También se puede compilar PHP a partir de fuentes utilizando el » árbol de portes. Sin embargo, esto sólo se recomienda para usuarios familiarizados con OpenBSD. El porte de PHP 4 está dividido en dos subdirectorios: core y extensions. El directorio extensions genera subpaquetes para todos los módulos soportados de PHP. Si se encuentra que no se desea crear alguno de estos módulos, utilice el sabor o FLAVOR no_*. Por ejemplo, para evitar compilar el módulo imap, fijar el sabor o FLAVOR a no_imap.

Problemas comunes

  • La instalación por omisión de Apache se ejecuta dentro de una » jaula chroot(2), que habrá de restringir a los script PHP el acceso a ficheros debajo de /var/www. Por lo tanto se requiere crear un directorio /var/www/tmp para que los ficheros de sesión de PHP sean almacenados, o utilizar un medio alternativo de almacenamiento de sesiones. Además, los sockets de base de datos necesitan colocarse dentro de la jaula o escuchar en la interfaz de localhost. Se se hace uso de funciones de red, algunos ficheros de /etc tales como /etc/resolv.conf y /etc/services tendrán que ser movidos a /var/www/etc. El paquete PEAR de OpenBSD automáticamente se instala dentro de los directorios correctos del chroot, así que no hace falta ninguna modificación especial ahí. Más información sobre el Apache de OpenBSD está disponible en las preguntas frecuentes OpenBSD.
  • El paquete de OpenBSD 3.6 para la extensión » gd requiere que XFree86 sea instalado. Si no se desea utilizar algunas de las características de fuentes tipográficas que requieren de X11, es mejor instalar el paquete php4-gd-4.3.8-no_x11.tgz.

Ediciones antiguas

Ediciones antiguas de OpenBSD utilizaban el sistema FLAVORS para compilar un PHP enlazado estáticamente. Dado que es difícil generar paquetes binarios utilizando este método, ahora es depreciado. Aún es posible utilizar los viejos árboles estables de ports si así se desea, pero carecen de soporte por parte del equipo de OpenBSD. Si se tiene algún comentario al respecto, el responsable actual del port es Anil Madhavapeddy (avsm arroba openbsd punto org).

add a note

User Contributed Notes 6 notes

up
18
Anonymous
2 years ago
UPDATE: OpenBSD 6.9:

- The package "php-fpm" no longer 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 versions. pkg_add will ask you which version to install.
up
20
pete att shitnami.net
8 years ago
A brief update: As of OpenBSD 5.7 (2015) the installation process is extremely easy. Apache httpd was replaced by Nginx, which has since been further replaced by OpenBSD's own server, aptly named 'httpd'.

'httpd' is installed by default, everything else you can still get from packages, with a couple name changes (including Apache and Nginx.) You will be asked which version to install - at the time of writing, versions 5.3.29p1 thru 5.6.5 are available.

#pkg_add php
#pkg_add php-fpm
#pkg_add pear

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

httpd_flags=
pkg_scripts=php_fpm

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

----
For date, timezone 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
up
7
ameen(at)dausha(dot)net
20 years ago
I just finished spinning my wheels with PHP/Apache on OpenBSD 3.3, and it took a Google to fix my problem. I followed the instructions by (0429196301 at netcabo dot pt) written on Sep 19, 2003 and kept being fed a segmentation fault when I tried to start httpd.

Then I read the page cited below that suggested playing with the order of the LoadModules, and put the PHP first. I followed that recommendation and httpd started without problems!

Page that saved me:
http://archives.neohapsis.com/archives/openbsd/2002-04/3074.html

"Change around the order of the Apache modules, this is one of the
drawbacks to the module API for Apache 1.3 is that the order is very
important. I would try making the PHP 4 module first, Perl module second
and FP module last. "
up
6
openbsd-fanatic
18 years ago
I am user that is just migrating to open source and thought I would take openbsd for a spin. This article, by Gregory L. Magnusson, really helped me to get a working apache-php-mysql server going on openbsd.
http://www.devx.com/security/Article/28059/0/page/1
up
3
sanchero [at] gvsu [dot] edu
20 years ago
On OpenBSD 3.2, given the steps outlined above using pre-built packages you will get a new "/var/www/conf/httpd.conf" that contains a section like this:

<IfDefine SSL>
AddModule mod_ssl.c
AddModule mod_php4.c
</IfDefine>

This causes mod_php4 to load only when starting Apache w/SSL, so if this isn't what you want add the mod_php4 line again above (or below) this section, like so:

AddModule mod_php4.c <<------ SEE? - now should load normally.
<IfDefine SSL>
AddModule mod_ssl.c
AddModule mod_php4.c
</IfDefine>

I also added this for good measure:

<IfModule mod_php4.c>
AddType application/x-httpd-php .php [blah blah]
</IfModule>

Seems to work.
up
-2
hg at ostc dot de
18 years ago
Also you should add "-a /var/www/dev/log" to the syslogd_flags
for propper logging of php-extensions like imap.so and create
a /var/www/etc/master.passwd with an www-user-entry and run
pwd_mkdb -d /var/www/etc /var/www/etc/master.passwd for propper
use of libc-client.a functions in imap.so.
To Top