compiling PHP 5.4 and higher with MySQL

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

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.

profilepic.png
manpreet 2 years ago

 

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

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.