1

I'm running a pile of mediawiki instances on Oracle enterprise Linux and I'm trying to upgrade from 1.19.x to the latest LTS version, 1.23.x. I'm currently using PHP 5.3 and due to some odd issues with special pages and thumbnails, it has been recommended that I upgrade PHP to 5.4 or higher.

./configure --prefix=$PRE --with-config-file-path=$CONFIG_FILE_PATH --with-mysql=/usr/include/mysql --with-apxs2=$PRE/apache/bin/apxs --with-zlib --with-jpeg-dir --with-gd --with-iconv-dir --with-libxml-dir=/usr/local/bin --enable-mbstring

the issue I have is that my compile of PHP keeps failing with error:

error: Cannot find MySQL header files under /usr/include/mysql.

here is where it gets odd:

$ cd /usr/include/mysql
$ ll | grep mysql.h
-rw-r--r-- 1 root root 28148 May 11 2011 mysql.h

clearly the header files are present.

here is where it gets even more odd: if I pull a copy of the PHP 5.3 tar, extract it and run the exact same compile command it succeeds.

I know that between PHP 5.3 and 5.4 PHP moved from libmysqlslient to mysqlnd [whatever that means], but according to their manual the compile arguments have not changed.

http://php.net/manual/en/mysql.installation.php

so I thought it must be the change to mysqlnd. so I tested that by compiling 5.3 with mysqlnd, and that succeeds!

--with-mysql=mysqlnd --with-mysql=/usr/include/mysql

I've also tried PHP 5.6 in case something broken was fixed, but that also fails with the cannot find header files error.

I'm at a loss of where to go from here.

  • What is your OS/distribution? Why not use a backport, or build one yourself? – Faheem Mitha Dec 10 '14 at 17:10
  • added os version, oracle enterprise linux. not sure how a backport would be of any use, since i haven't identified the problem definitively yet. – zee Dec 10 '14 at 17:22
  • well backports just means using existing packaging. usually the packager has taken care of configuration problems, so you don't have to. This is a guarantee the packaging will build on a version it was not designed for, of course, but it often does, possibly with a little tweaking. – Faheem Mitha Dec 10 '14 at 17:30
  • Two more specific comments. (a) configure isn't a black box - it is just a shell script. Check and see how it is testing for header files. You should be able to run the test separately yourself. (b) even if you don't want to use more recent packaging, you can check and see what configure arguments it is using. – Faheem Mitha Dec 10 '14 at 17:33
  • oddly, the first 256 lines of the 5.3 configure are empty! it actually makes it look like it's a black box when you're right, it's not. – zee Dec 10 '14 at 21:09
2

from the php 5.3 configure file:

if test "$PHP_MYSQL" = "mysqlnd"; then
    PHP_MYSQLND_ENABLED=yes

elif test "$PHP_MYSQL" != "no"; then
    MYSQL_DIR=
    MYSQL_INC_DIR=

    for i in $PHP_MYSQL /usr/local /usr; do
        if test -r $i/include/mysql/mysql.h; then
            MYSQL_DIR=$i
            MYSQL_INC_DIR=$i/include/mysql
            break
        elif test -r $i/include/mysql.h; then
            MYSQL_DIR=$i
            MYSQL_INC_DIR=$i/include
            break
        fi
    done

    if test -z "$MYSQL_DIR"; then
        { echo "configure: error: Cannot find MySQL header files under $PHP_MYSQL.
Note that the MySQL client library is not bundled anymore!" 1>&2; exit 1; }
    fi

from php 5.4 and 5.6 configure:

if test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL" = "mysqlnd"; then
    PHP_MYSQLND_ENABLED=yes

elif test "$PHP_MYSQL" != "no"; then
  MYSQL_DIR=
  MYSQL_INC_DIR=

  if test -r $PHP_MYSQL/include/mysql/mysql.h; then
    MYSQL_DIR=$PHP_MYSQL
    MYSQL_INC_DIR=$PHP_MYSQL/include/mysql
    break
  elif test -r $PHP_MYSQL/include/mysql.h; then
    MYSQL_DIR=$PHP_MYSQL
    MYSQL_INC_DIR=$PHP_MYSQL/include
    break
  fi

  if test -z "$MYSQL_DIR"; then
    as_fn_error $? "Cannot find MySQL header files under $PHP_MYSQL.
Note that the MySQL client library is not bundled anymore!" "$LINENO" 5
  fi

the error is misleading in that it simply prints what you entered; $PHP_MYSQL and doesn't tell you that it's actually looking in $PHP_MYSQL/include/mysql/mysql.h and $PHP_MYSQL/include/mysql.h, which in my case translates to /usr/include/mysql/include/mysql/mysql.h and /usr/include/mysql/include/mysql.h

needless to say, the answer is:

./configure --prefix=$PRE --with-config-file-path=$CONFIG_FILE_PATH --with-mysql=/usr --with-apxs2=$PRE/apache/bin/apxs --with-zlib --with-jpeg-dir --with-gd --with-iconv-dir --with-libxml-dir=/usr/local/bin --enable-mbstring
  • thanks much to faheem for helping me reach this solution. – zee Dec 10 '14 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.