第 31 章 構築時の問題

本節では、構築時に発生する多くの一般的なエラーを集めたものです。

1. anonymous CVSサービスにより最新版のPHPを入手しましたが、 configureスクリプトがありません!
2. PHPをApacheと組みあわせて動作するようにconfigureを行う際に問題が あります。httpd.hが見付からないといわれますが、指定した場所にこ のファイルはあるのです!
3. configureを実行した際、GD、gdbmまたは他のパッケージのファイルま たはライブラリを見つけることができないと言われます。
4. ファイルlanguage-parser.tab.cをコンパイルする際、 'yytname undeclared'というエラーが発生します。
5. 'make'を実行する際、実行には成功しているようですがコンパイルする 最終的なアプリケーションをリンクしようとした際に何かファイルが見 つからないというエラーが発生します。
6. PHPをリンクする際、未定義の参照があるというエラーが複数発生しま す。
7. PHPをApache 1.3と組み合わせて構築する手法が分かりません。
8. インストール手順に完全に基づきUNIX上でApacheモジュール版をインス トールしましたが、ブラウザでアクセスするとPHPスクリプトが表示さ れ、ファイルを保存しますかときかれます。
9. --activate-module=src/modules/php4/libphp4.a と書いてありますが、ファイルがありません。このため、 --activate-module=src/modules/php4/libmodphp4.aに 変更しましたが、やはりだめです。何が起きているのでしょう?
10. --activate-module=src/modules/php4/libphp4.a を指定し、PHPを静的モジュールとして組み込んでApacheを構築しよう とした際に、システムがANSI対応ではないというエラーを発生します。
11. --with-apxsを指定してPHPを構築しようとした際、 奇妙なエラーメッセージが出力されます。
12. 'make'の間、microtimeおよび'RUSAGE_'関連で多くのエラーを発生しま す。

1. anonymous CVSサービスにより最新版のPHPを入手しましたが、 configureスクリプトがありません!

configure.inからconfigureスクリプトを生成するためには、GNU autoconfパッケージが必要です。CVSサーバからソースを入手した後、 最上位のディレクトリで./buildconfを実行して下 さい。(また、configureに --enable-maintainer-modeオプションを付けて実 行した場合以外は、configureスクリプトはconfigure.inファイルが更 新された際に自動的に再構築を行いません。このため、configure.inが 変更された場合には忘れずに手動で再構築を行う必要があります。 再構築の際に行われることの1つは、configureまたはconfig.statusを 実行した後、Makefileの中の@VARIABLE@のような物を見つけることです。)

2. PHPをApacheと組みあわせて動作するようにconfigureを行う際に問題が あります。httpd.hが見付からないといわれますが、指定した場所にこ のファイルはあるのです!

configure/setupスクリプトにApacheソースツリーの最上位の場所を指 定する必要があります。これは、' --with-apache=/path/to/apache'を指定するので あって、'--with-apache=/path/to/apache/src'で はないということです。

3. configureを実行した際、GD、gdbmまたは他のパッケージのファイルま たはライブラリを見つけることができないと言われます。

Cプリプロセッサおよびリンカに次のように追加でフラグを指定するこ とにより、configureスクリプトがヘッダファイルまたはライブラリを 標準以外の場所で探すことが可能となります。

    CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
      
ログインシェルとしてcsh系のシェルを使用している場合、次のように なります。

    env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
      

4. ファイルlanguage-parser.tab.cをコンパイルする際、 'yytname undeclared'というエラーが発生します。

bisonのバージョンを更新する必要があります。最新版は、 ftp://ftp.gnu.org/pub/gnu/bison/にあります。

5. 'make'を実行する際、実行には成功しているようですがコンパイルする 最終的なアプリケーションをリンクしようとした際に何かファイルが見 つからないというエラーが発生します。

古いバージョンのmakeには、functionsディレクトリにあるファイルの コンパイルされたものを同じディレクトリに正しく入れないものがあり ます。"cp *.o functions"を試しに実行してから 'make' を再度実行し、解決されるか確認して下さ い。解決される場合には、GNU makeの最近のバージョンに更新するべき です。

6. PHPをリンクする際、未定義の参照があるというエラーが複数発生しま す。

Take a look at the link line and make sure that all of the appropriate libraries are being included at the end. Common ones that you might have missed are '-ldl' and any libraries required for any database support you included.

If you're linking with Apache 1.2.x, did you remember to add the appropriate information to the EXTRA_LIBS line of the Configuration file and re-rerun Apache's Configure script? See the INSTALL file that comes with the distribution for more information.

Some people have also reported that they had to add '-ldl' immediately following 'libphp3.a' when linking with Apache.

7. PHPをApache 1.3と組み合わせて構築する手法が分かりません。

This is actually quite easy. Follow these steps carefully:

  • Grab the latest Apache 1.3 distribution from http://www.apache.org/dist/.

  • Ungzip and untar it somewhere, for example /usr/local/src/apache-1.3.

  • Compile PHP by first running ./configure --with-apache=/<path>/apache-1.3 (substitute <path> for the actual path to your apache-1.3 directory.

  • Type 'make' followed by 'make install' to build PHP and copy the necessary files to the Apache distribution tree.

  • Change directories into to your /<path>/apache-1.3/src directory and edit the Configuration file. At the end of the file, add: AddModule modules/php3/libphp3.a.

  • Type: './Configure' followed by 'make'.

  • You should now have a PHP-enabled httpd binary!

Note: : You can also use the new Apache ./configure script. See the instructions in the README.configure file which is part of your Apache distribution. Also have a look at the INSTALL file in the PHP distribution.

8. インストール手順に完全に基づきUNIX上でApacheモジュール版をインス トールしましたが、ブラウザでアクセスするとPHPスクリプトが表示さ れ、ファイルを保存しますかときかれます。

This means that the PHP module is not getting invoked for some reason. Three things to check before asking for further help:

  • Make sure that the httpd binary you are running is the actual new httpd binary you just built. To do this, try running: /path/to/binary/httpd -l

    If you don't see mod_php3.c listed then you are not running the right binary. Find and install the correct binary.

  • Make sure you have added the correct Mime Type to one of your Apache .conf files. It should be: AddType application/x-httpd-php3 .php3 (for PHP 3)

    or AddType application/x-httpd-php .php (for PHP 4)

    Also make sure that this AddType line is not hidden away inside a <Virtualhost> or <Directory> block which would prevent it from applying to the location of your test script.

  • Finally, the default location of the Apache configuration files changed between Apache 1.2 and Apache 1.3. You should check to make sure that the configuration file you are adding the AddType line to is actually being read. You can put an obvious syntax error into your httpd.conf file or some other obvious change that will tell you if the file is being read correctly.

9. --activate-module=src/modules/php4/libphp4.a と書いてありますが、ファイルがありません。このため、 --activate-module=src/modules/php4/libmodphp4.aに 変更しましたが、やはりだめです。何が起きているのでしょう?

Well, you decided to try to outsmart the people who wrote those nice step-by-step instructions for you and you have now discovered that these people cannot be outsmarted. The libphp4.a file is not supposed to exist. The Apache build process will create it.

10. --activate-module=src/modules/php4/libphp4.a を指定し、PHPを静的モジュールとして組み込んでApacheを構築しよう とした際に、システムがANSI対応ではないというエラーを発生します。

Apacheのこのエラーメッセージは紛らわしく、より新しいバージョンで は修整されています。

11. --with-apxsを指定してPHPを構築しようとした際、 奇妙なエラーメッセージが出力されます。

There are three things to check here. First, for some reason when Apache builds the apxs Perl script, it sometimes ends up getting built without the proper compiler and flags variables. Edit your apxs (sometimes found in /usr/local/apache/bin/apxs or /usr/sbin/apxs) and check for these lines:

my $CFG_CFLAGS_SHLIB  = ' ';      # substituted via Makefile.tmpl
my $CFG_LD_SHLIB      = ' ';          # substituted via Makefile.tmpl
my $CFG_LDFLAGS_SHLIB = ' ';      # substituted via Makefile.tmpl
      
If this is what you see, you have found your problem. Change these lines to say:

my $CFG_CFLAGS_SHLIB  = '-fpic -DSHARED_MODULE';      # substituted via Makefile.tmpl
my $CFG_LD_SHLIB      = 'gcc';          # substituted via Makefile.tmpl
my $CFG_LDFLAGS_SHLIB = q(-shared);# substituted via Makefile.tmpl 
      
The second possible problem should only be an issue on RedHat-6.1/6.2. The apxs script RedHat ships is broken. Look for this line:

my $CFG_LIBEXECDIR    = 'modules';        # substituted via APACI install
      
If you see the above line, change it to this:

my $CFG_LIBEXECDIR    = '/usr/lib/apache';        # substituted via APACI install
      
Last, if you reconfigure/reinstall Apache, add a 'make clean' to the process after './configure' and before 'make'.

12. 'make'の間、microtimeおよび'RUSAGE_'関連で多くのエラーを発生しま す。

During the 'make' portion of installation, if you encounter problems that look similar to this:

    microtime.c: In function `php_if_getrusage':
    microtime.c:94: storage size of `usg' isn't known
    microtime.c:97: `RUSAGE_SELF' undeclared (first use in this function)
    microtime.c:97: (Each undeclared identifier is reported only once
    microtime.c:97: for each function it appears in.)
    microtime.c:103: `RUSAGE_CHILDREN' undeclared (first use in this function)
    make[3]: *** [microtime.lo] Error 1
    make[3]: Leaving directory `/home/master/php-4.0.1/ext/standard'
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/home/master/php-4.0.1/ext/standard'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/master/php-4.0.1/ext'
    make: *** [all-recursive] Error 1
      

Your system is broken. You need to fix your /usr/include files either by making sure your /usr/include/linux symlink is pointing to the right place in your kernel sources or by installing a glibc-devel package that matches your glibc. This has absolutely nothing to do with PHP. To prove this to yourself, try this simple test:

    $ cat >test.c <<X
    #include <sys/resource.h>
    X
    $ gcc -E test.c >/dev/null
      
If that spews out errors, you know your include files are messed up.