CakeFest 2024: The Official CakePHP Conference

Notas de instalação para o OpenBSD

Essa seção contém notas e dicas específicas para a instalação do PHP no » OpenBSD.

Usando Pacotes Binários

Usando pacotes binários para instalar o PHP no OpenBSD é o método recomendado e o mais simples. O pacote núcleo foi separado dos vários módulos, e cada um pode ser instalado e removido independentemente dos outros. Os arquivos necessários podem ser encontrados no CD do OpenBSD ou no FTP do site.

O pacote principal que você precisa instalar é o php, que contém o engine básico (mais gettext e iconv), e pode estar disponível dentre várias versões a escolher. Depois, olhe os pacotes com módulos, como o php-mysqli ou php-imap. Você precisa usar o comando phpxs para ativar e desativar esses módulos no seu arquivo php.ini.

Exemplo #1 Exemplo de instalação de pacote no OpenBSD

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

Siga as instruções de cada pacote!

  (to remove packages)
# pkg_delete php
# pkg_delete php-apache
# pkg_delete php-mysqli
# pkg_delete pear

Leia o manual de » packages(7) para mais informações sobre pacotes binários no OpenBSD.

Usando Ports

Você também pode compilar o PHP a partir dos fontes usando a » árvore ports. No entanto, isso só é recomendado para usuários familiarizados com OpenBSD. O port do PHP é dividido em núcleo e extensões. As extensões geram sub-pacotes para todos os módulos suportados pelo PHP. Se você achar que não quer criar alguns dos módulos, use o comando no_* FLAVOR. Por exemplo, se você quiser que o módulo imap seja ignorado, atribua à FLAVOR o valor no_imap.

Problemas Comuns

  • Apache e Nginx não são mais os servidores padrão no OpenBSD, mas eles podem ser facilmente encontrados em ports e pacotes. O novo servidor é chamado 'httpd'.
  • A instalação padrão do Apache roda dentro de uma » prisão de chroot(2), que restringe os scripts PHP a acessar arquivos abaixo de /var/www. Você irá, portanto, precisar criar um diretório /var/www/tmp para que os arquivos de sessão do PHP sejam guardados, ou usar um backend alternativo para sessões. Além disso, sockets de bancos de dados devem ser colocados dentro da prisão ou escutar na interface localhost. Se você usar funções de rede, alguns arquivos do diretório /etc como /etc/resolv.conf e /etc/services precisarão ser movidos para /var/www/etc. O pacote OpenBSD PEAR se instala automaticamente nos diretórios chroot corretos.
  • Os pacotes do OpenBSD package para a extensão » gd requer o Xorg para instalação. Isso é realizado na instalação com o acréscimo de o file set xbase.tgz, ou pode ser instalado posteriormente (veja » OpenBSD FAQ#4).
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