1
votes

I'm running Apache 2.4 on FreeBSD (FAMP stack) and had Wordpress successfully hosting a website. However I recently tried to install phpLDAPadmin in order to manage an LDAP server and now whenever Apache is running, any page on my site displays the following:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /usr/local/www/apache24/data/wp-includes/wp-db.php:1643 Stack trace: #0 /usr/local/www/apache24/data/wp-includes/wp-db.php(639): wpdb->db_connect() #1 /usr/local/www/apache24/data/wp-includes/load.php(427): wpdb->__construct('user', 'pass', 'wordpressdb', 'localhost') #2 /usr/local/www/apache24/data/wp-settings.php(120): require_wp_db() #3 /usr/local/www/apache24/data/wp-config.php(92): require_once('/usr/local/www/...') #4 /usr/local/www/apache24/data/wp-load.php(37): require_once('/usr/local/www/...') #5 /usr/local/www/apache24/data/wp-blog-header.php(13): require_once('/usr/local/www/...') #6 /usr/local/www/apache24/data/index.php(17): require('/usr/local/www/...') #7 {main} thrown in /usr/local/www/apache24/data/wp-includes/wp-db.php on line 1643

The site is experiencing technical difficulties.

Furthermore, when I went to check the version of php, this happens:

# php --version
Segmentation fault (core dumped)

I read that it can happen when upgrading php from 5.x to 7.x, but unless installing phpLDAPadmin performed an upgrade, I believe I have had php 7.2 all along. I was able to see that the man page for php shows version 7.2.21. While the problem does seem to be related to php, I haven't been able to figure out exactly what is going on. It seems extremely odd that I can't even check the php version in the command line.

I have tried restarting, as well as updating via freebsd-update and portsnap followed by a reinstall, not to mention various configuration changes to php.ini, wp-config.php and httpd.conf.

====Edit====

I ran pkg upgrade -f which made the following changes:

Installed packages to be UPGRADED:
  py27-openssl: 18.0.0 - 19.0.0
  openldap-server: 2.4.47_1 - 2.4.48
  openldap-client: 2.4.47 - 2.4.48
  mysql56-server: 5.6.44 - 5.6.45
  mysql56-client: 5.6.44 - 5.6.45
  libnghttp2: 1.39.1 - 1.39.2
  apache24: 2.4.39_1 - 2.4.41

Installed packages to be DOWNGRADED:
  postgresql95-client: 9.5.18_1 - 9.5.18
  postfix: 3.4.6,1 - 3.4.5,1

Installed packages to be REINSTALLED:
  pkg-1.11.1
  zstd-1.4.0
  zip-3.0_1
  xtrans-1.4.0
  xorgproto-2019.1
  xorg-macros-1.19.2
  xmlcharent-0.3_2
  xmlcatmgr-2.2_2
  xcb-proto-1.13_1
  xauth-1.0.10
  tor-0.4.0.5_1
  texinfo-6.6_1,1
  swig30-3.0.12
  sdocbook-xml-1.1_2,2
  scons-3.0.1
  rhash-1.3.5
  readline-8.0.0
  python36-3.6.9
  python27-2.7.16_1
  py27-zope.interface-4.6.0
  py27-zope.event-4.1.0
  py27-zope.component-4.2.2
  py27-urllib3-1.22,1
  py27-typing-3.6.6
  py27-sphinxcontrib-websupport-1.1.2
  py27-sphinx_rtd_theme-0.4.3
  py27-sphinx-1.6.5_2,1
  py27-snowballstemmer-1.2.0_1
  py27-six-1.12.0
  py27-setuptools_scm-3.3.3
  py27-setuptools-41.0.1
  py27-requests-toolbelt-0.8.0
  py27-requests-2.21.0
  py27-pytz-2019.1,1
  py27-pytest-runner-2.11.1
  py27-pystemmer-1.3.0_2
  py27-pysocks-1.7.0
  py27-pyrfc3339-1.1
  py27-pygments-2.4.1
  py27-pycparser-2.19
  py27-parsedatetime-2.4_1
  py27-josepy-1.2.0
  py27-ipaddress-1.0.22
  py27-imagesize-0.7.1
  py27-idna-2.8
  py27-enum34-1.1.6
  py27-docutils-0.14_4
  py27-cryptography-2.6.1
  py27-configobj-5.0.6_1
  py27-configargparse-0.14.0
  py27-chardet-3.0.4_1
  py27-cffi-1.12.3
  py27-certifi-2019.6.16
  py27-certbot-0.35.1,1
  py27-asn1crypto-0.24.0
  py27-alabaster-0.7.6
  py27-acme-0.35.1,1
  py27-MarkupSafe-1.1.1
  py27-Jinja2-2.10.1
  py27-Babel-2.7.0
  portmaster-3.19_18
  png-1.6.37
  pkgconf-1.6.1,1
  phpldapadmin-php72-1.2.3_10,1
  php72-xml-7.2.21
  php72-session-7.2.21
  php72-openssl-7.2.21
  php72-ldap-7.2.21
  php72-iconv-7.2.21
  php72-hash-7.2.21
  php72-gettext-7.2.21
  php72-7.2.21
  perl5-5.28.2
  pcre-8.43_1
  p5-Unicode-EastAsianWidth-1.40
  p5-Text-Unidecode-1.30
  p5-Locale-libintl-1.31
  p5-Locale-gettext-1.07
  openvpn-2.4.7
  openssl-1.0.2s,1
  openjdk8-8.212.4.1
  ninja-1.9.0,2
  nasm-2.14.02,1
  nano-4.2
  mpfr-4.0.2
  mkfontscale-1.2.1
  minixmlto-0.0.2_1
  maven-wrapper-1_2
  maven-3.6.1
  m4-1.4.18_1,1
  lzo2-2.10_1
  lua52-5.2.4
  libzip-1.5.2
  libxslt-1.1.32_1
  libxml2-2.9.9
  libxcb-1.13.1
  libuv-1.30.1
  libunwind-20170615
  libtool-2.4.6_1
  libtextstyle-0.20.1
  libpthread-stubs-0.4
  liblz4-1.9.1,1
  libltdl-2.4.6
  libinotify-20180201_1
  libiconv-1.14_11
  libgpg-error-1.36
  libgcrypt-1.8.4_1
  libfontenc-1.1.4
  libffi-3.2.1_3
  libevent-2.1.10
  libedit-3.1.20190324,1
  libargon2-20171227_1
  libarchive-3.3.3,1
  libXtst-1.2.3_2
  libXt-1.2.0,1
  libXrender-0.9.10_2
  libXpm-3.5.12_2
  libXmu-1.1.3,1
  libXi-1.7.10,1
  libXfixes-5.0.3_2
  libXext-1.3.4,1
  libXdmcp-1.1.3
  libXau-1.0.9
  libX11-1.6.8,1
  libSM-1.2.3,1
  libICE-1.0.9_3,1
  jsoncpp-1.8.1_6
  jpeg-turbo-2.0.2
  javavmwrapper-2.6
  java-zoneinfo-2019.a
  jakarta-commons-logging-1.2
  jakarta-commons-codec-1.10
  jakarta-commons-cli-1.4,1
  iso8879-1986_3
  indexinfo-0.3.1
  icu-64.2,1
  httpcore-4.4.11
  httpclient-4.5.7
  html2text-1.3.2a
  help2man-1.47.10
  gperf-3.0.3_2
  gmp-6.1.2_1
  gmake-4.2.1_3
  glib-2.56.3_5,1
  giflib-5.1.9
  gettext-tools-0.20.1
  gettext-runtime-0.20.1
  gdbm-1.18.1_1
  freetype2-2.10.0
  fontconfig-2.12.6,1
  expat-2.2.6_1
  easy-rsa-3.0.6
  docbook-xsl-1.79.1_1,1
  docbook-xml-5.0_3
  docbook-sgml-4.5_1
  docbook-1.5
  dialog4ports-0.1.6
  dejavu-2.37_1
  dbus-glib-0.110
  dbus-1.12.12
  db5-5.3.28_7
  curl-7.65.1
  cmake-3.14.5
  check-0.12.0_1
  ca_root_nss-3.45
  bison-3.4.1,1
  binutils-2.32_1,1
  automake-1.16.1_1
  autoconf-wrapper-20131203
  autoconf-2.69_2
  apr-1.6.5.1.6.1_1
  alsa-lib-1.1.2_2

Number of packages to be upgraded: 7
Number of packages to be reinstalled: 172
Number of packages to be downgraded: 2

After that finished, php --version works:

# php --version
PHP 7.2.21 (cli) (built: Aug  8 2019 01:27:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

However, I'm still getting the same Fatal error from Apache/Wordpress.

1
what does phpinfo give you? - Moses Schwartz
You can debug with GDB but this is a HELL, and man this is php --version that gives the segfault! , I recommend reinstalling things from your distribution repository. - Accountant م
If you upgraded from 5.x to 7.x, you really need to upgrade each and every dependency you're relying on, too, because if your php.ini includes links to drivers that were compiled against PHP 5.x, those are almost guaranteed to segfault now. - Mike 'Pomax' Kamermans
I'm not even able to access the admin page for Wordpress. Do you know of a way to make the phpinfo page via command line? - Joey Dodson
@JoeyDodson forget about WordPress now, it's build on PHP and your PHP installation is down, you need to reinstall a clean PHP. - Accountant م

1 Answers

0
votes

Ok, I finally fixed this!

The problem must have been related to upgrading PHP, probably from PHP 7.1 to PHP 7.2. I'm assuming this happened when I installed phpLDAPadmin, which is what triggered the issue.

Firstly, I was able to solve the segmentation fault/core dump issue by running the following:

pkg upgrade -f

This allowed me to use the PHP terminal commands again. However WordPress still wasn't working and showed the same fatal error above.

After checking through a FAMP stack install guide for FreeBSD 12 and PHP 7.2, I realized that I didn't have all of the necessary PHP modules installed anymore.

php -m
PHP Warning:  PHP Startup: Unable to load dynamic library 'php_nd_mysqls.dll' (tried: /usr/local/lib/php/20170718/php_nd_mysqls.dll (Cannot open "/usr/local/lib/php/20170718/php_nd_mysqls.dll"), /usr/local/lib/php/20170718/php_nd_mysqls.dll.so (Cannot open "/usr/local/lib/php/20170718/php_nd_mysqls.dll.so")) in Unknown on line 0
[PHP Modules]
Core
date
gettext
hash
iconv
ldap
libxml
mysqlnd
openssl
pcre
Reflection
session
SPL
standard
xml

Whereas the installation guide here shows the php install command as follows:

pkg install php72 php72-mysqli mod_php72 php72-mbstring php72-zlib php72-curl php72-gd php72-json

I believe, based on reading this page earlier, that it was the lack of MySQLI that was causing WordPress to throw the fatal error. When I installed the missing PHP modules everything worked again!