在 HP-UX 系统下的安装

本章节的内容和提示仅限于将 PHP 安装到 HP-UX 系统上(此文章是由 paul_mckay at clearwater-it dot co dot uk 编写的)。

注: 本文涉及的技巧适用于 PHP 4.0.4 和 Apache 1.3.9。

  1. 安装 PHP 需要一个 gzip,可以从如下地址得到该软件的二进制版本的发行包 http://hpux.connect.org.uk/ftp/hpux/Gnu/gzip-1.2.4a/gzip-1.2.4a-sd-10.20.depot.Z,下载后解压缩,并且使用 swinstall 安装。

  2. 安装 PHP 需要 gcc,可以从如下地址得到该软件的二进制版本的发行包 http://gatekeep.cs.utah.edu/ftp/hpux/Gnu/gcc-2.95.2/gcc-2.95.2-sd-10.20.depot.gz,解压缩这个文件,使用 swinstall 安装 gcc。

  3. 安装 PHP 需要 GNU binutils,可以从如下地址得到该软件的二进制版本的发行包 http://hpux.connect.org.uk/ftp/hpux/Gnu/binutils-2.9.1/binutils-2.9.1-sd-10.20.depot.gz,解压缩这个文件,使用 swinstall 安装 binutils。

  4. 安装 PHP 需要 bison,可以从如下地址得到该软件的二进制版本的发行包 http://hpux.connect.org.uk/ftp/hpux/Gnu/bison-1.28/bison-1.28-sd-10.20.depot.gz,安装方式同上。

  5. 安装 PHP 需要 flex,需要从 http://www.gnu.org 的镜像站点下载一个该软件的源代码。它被放置于一个 非 gnu 目录的 ftp 服务器上。下载这个文件,并且使用 gunzip 解压缩,然后执行 tar -xvf。进入新创建的 flex 目录并运行 ./configure,再执行 make 以及 make install

    如果这里出现了错误,很可能是由于 gcc 等工具不在路径中,应将其添加到环境变量 PATH 中。

  6. 下载 PHP 和 apache 的源代码。

  7. 下载后对他们分别执行 gunziptar -xvf。在开始编译他们之前我们需要修改一些文件。

  8. 首先 configure 文件需要被修改,因为它似乎忘记自己是在 hpux 系统下了,有更好的方法解决此问题,但最省事的是在配置脚本的第 47286 行加入 lt_target=hpux10.20

  9. 其次是修改 Apache GuessOS 文件。在文件 apache_1.3.9/src/helpers 的第 89 行,将参数 echo "hp${HPUXMACH}-hpux${HPUXVER}"; exit 0 替换为 echo "hp${HPUXMACH}-hp-hpux${HPUXVER}"; exit 0

  10. 不能把 PHP 作为共享对象方式安装到 HP-UX, 因此你必须将其编译成为一个静态方式,参照 Apache 站点的指导就可以完成。

  11. 这样就完成了 PHP 和 Apache 的 安装编译,然而 Apache 将仍然不能启动,必须为 Apache 配置一个新的用户名,例如 www 或 apache。然后修改 Apache 配置文件 conf/httpd.conf 的 252 和 253 行,由原来的

    User nobody
    Group nogroup

    替换为类似如下的内容

    User www
    Group sys

    这是因为在 hp-ux 系统下, Apache 不能作为 nobody 用户运行。按照上面的方式配置 Apache 和 PHP 就应该可以正常工作了。


add a note add a note User Contributed Notes
Vinayak
23-Mar-2006 08:14
Installing PHP 5.x with Apache 2.x on HP UX 11i and configuring
PHP 5.x with Oracle 9i

I am very glad to share this information to configure PHP 5.x work
with Apache 2.x and Oracle 9i on HP UX 11i.

Step 1: Install Apache 2.x with DSO support:
--------------------------------------------

This is a stratight forward Apache installation with
--enable-so option

gzip -d httpd-2_0_NN.tar.gz
tar xvf httpd-2_0_NN.tar
cd httpd-2_0_NN

./configure \
--prefix=/var/apps/apache2 \
--enable-so \
--enable-mods-shared=most \
--libexecdir=/var/apps/apache2/libexec

You can add other options as required.

make

make install

Step 2: Install and configure PHP 5.x with Oracle 9i
----------------------------------------------------

Edit the ./configure file to change "$OCI8_DIR/lib" as "$OCI8_DIR/lib32"

By default, with Oracle 9i, "$OCI8_DIR/lib" will be poiting to
Oracle 64 bit libraries in "$OCI8_DIR/lib64" directory.
Unfortunately, PHP 5.x does not work with 64 bit oracle shared libraries.

Run configure..
 
$ ./configure \
--prefix=/var/apps/php \
--with-apxs2=/var/apps/apache2/bin/apxs \
--with-oci8=/oracle/app/product/9.0.2 \
--disable-libxml \
--enable-libgcc \
--enable-ftp \
--enable-calendar \
--enable-track-vars \
--enable-trans-sid \
--enable-sigchild \
--libexecdir=/var/apps/apache2/libexec \
--with-config-file-path=/var/apps/apache2/conf

--enable-libgcc \
--enable-sigchild \
 
You can add other options as required. You can use the --help
option to configure to get a complete list.
 
After configure runs, you must edit the file libtool.
 
$ vi ./libtool
 
At line 184, you should change the line from:
 
deplibs_check_method="unknown"
to
deplibs_check_method="pass_all"
 
so that PHP and mod_php are properly compiled.
 
3. Compile and install the files.
 
Run make. This should complete normally.
 
$ make
 
Run make install. This will fail when it attempts to call apxs.
 
$ make install

Step 3: Configure Apache 2.x
----------------------------

Edit httpd.conf file to include

For PHP 5:
  
LoadModule php5_module modules/libphp5.so
    
AddType application/x-httpd-php .php .phtml
    

Set environment variables in $APACHE_ROOT/bin/envvars file

SHLIB_PATH="/var/apps/apache2/lib:$SHLIB_PATH"
export SHLIB_PATH

LD_LIBRARY_PATH=$ORACLE_HOME/app/product/9.0.2
/lib32
export LD_LIBRARY_PATH

LD_PRELOAD=/usr/lib/libpthread.sl:$ORACLE_HOME/app/
product/9.0.2/JRE/lib/PA_RISC/native_threads/libjava.sl
export LD_PRELOAD

After lot of hard work, by following the above procedure,
we were able to make PHP 5.x is work with Apache 2.x
and Oracle 9i on HP UX 11i OS.

Hope this will save your time!!
flconseil at yahoo dot fr
23-Jan-2006 10:47
If hpws is not an option for you, or if you want to build Apache and PHP with your own options and extensions, I have written a step by step tutorial.

It explains how to build Apache 2.0 and PHP 5 from scratch on HP-UX 11i (11.11), including most modules and extensions (zlib, SSL, LDAP, iconv, expat, xml, xslt, gd, png, Xpm, jpeg, freetype, bzip2, curl, MySQL, PostgreSQL, Oracle, AdoDB) :

http://flaupretre.free.fr/redir.php?key=build_apa_php
Marcus dot Reimann at reimann-systemberatung dot de
29-Aug-2003 10:50
If you need an Apache2-Server with PHP4 under HP-UX 11.x, it's a good way to download the HP-WebServer from the HP-Website (http://software.hp.com). The HP-Webserver comes with numerous moduls. First install the HP-Webserver (swinstall -s /absolute_path_to_depot_file/name_of_depot_file). After that, download the newest PHP-Version from http://www.php.net (HP ships the HP-Webserver with an old PHP-Version) and unpack the tar-file in a working-directory.

Use the following parameters for configure PHP:
./configure --with-apxs2=/opt/hpws/apache/bin/apxs --prefix=/opt/hpws/apache/php [and so on...]

If configure prints the error "expr: An integer value was expected.", than you have to edit the Script "configure". Replace the line:
APACHE_VERSION=`expr $4 \* 1000000 + $5 \* 1000 + $6`
with the following (correct and very long) line:
APACHE_VERSION=`$APXS_HTTPD -v | head -1 | cut -f3 -d' ' | cut -f2 -d'/' | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`

Why? The output of "httpd -v" prints the following string:
Server version: HP-UX_Apache-based_Web_Server/2.0.46
Server built:  Jun 26 2003 04:41:28
But the configure-Script can't deal with this string.
jason dot sheets at hp dot com
28-Feb-2003 06:45
In order to use PHP 4.3.0 on HP-UX 11 I've found I must compile it statically with Apache, it does not build as a module.
jsheets at shadotech dot com
01-Oct-2002 02:42
To clarify the my $dso_ext = "so"; comment, you can find my $dso_ext = "so";  in your apxs script you need to change that line to my $dso_ext = "sl"; otherwise make install will fail.
nikrou at ifrance dot com
08-Aug-2002 07:32
On HP-UX 11.00, there's a problem to compiling PHP as a DSO module. The script apxs is looking fot libphp4.so instead of libphp4.sl. Change the line  in the script (search "extension").
Write : my $dso_ext = "sl";
instead of : my $dso_ext = "so"; // old line

Nicolas
ichoudhury007 at yahoo dot com
31-May-2002 12:11
On HP-UX 11 ... When you are compiling PHP as DSO, you will encounter an error during "make install"

       /usr/local/apache/bin/apxs -i -a -n php4 libs/libphp4.sl
apxs:Error: file libs/libphp4.sl is not a DSO
*** Error exit code 1

---- This is because installation is looking for libphp4.so instead of sl.  You can rename or link as libphp4.so and run
james at nospam dot hp dot com
29-Jan-2002 11:46
To build for HP-UX 10.X/11.X (and some other UNIX variants) with '--enable-sockets', you'll get an error about 'u_int' being redefined in /usr/include/netinet/in.h and ext/sockets/sockets.c will fail to compile.  The problem is this line from main/php_config.h:
#define in_addr_t u_int

The above define is a problem because HP-UX (and some other UNIXs) typedef in_addr_t.  A good workaround is to replace this define in main/php_config.h with the lines from the HP-UX 11.X netinet/in.h header file (which will work for 10.X as well):
#ifndef _IN_ADDR_T
#define _IN_ADDR_T
#ifdef  __LP64__
   typedef unsigned int  in_addr_t;
#else
   typedef unsigned long  in_addr_t;
#endif
#endif
spam at adhocinc dot com
12-Oct-2001 05:35
For PHP 4.0.6 under HP-UX 11.00, I ran into errors during the compilation related to "LC_CTYPE" and other "LC_" vars.  The compilation complained that "LC_" such and such first used in such and such function.  (I think the error first came up in php_pcre.c, then in basic_functions.c).  The solution was to add "#include <locale.h>" to the php.h file.  Compilation was successful after that was added, with no other issues.  Used gcc 2.95.3, apache 1.3.20, bison 1.28, flex 2.5.4.a.
steven at oakleafconsultancy dot com
23-Jul-2001 11:28
Just a quick point to those of you (like me!) who might not be sharp enough to notice this: If you want to install PHP on an HP-UX 11.x box then you'll need to download and install the 11.x (not 10.20) versions of the software (like gcc and bison).  I didn't notice this and spent a large proportion of a day trying to figure out why the software wouldn't install!
Steve
marshalm at ebrd dot com
18-May-2001 01:58
HP-UX 11.X PA-RISC installation with oracle (oci8). You need to install the HP-UX patch PHSS_22514 patch (updated libdld.sl), otherwise you will get errors with dlopen() and dlclose() not found during the apache integration stage.
jonas__linden at hotmail dot com
23-Jan-2001 01:05
Building under HP-UX11
If you are using HP ANSI C you have to add +e i.e -Aa -D_HPUX_SOURCE +e