1

I am building a VM to develop an existing PHP 5.6 application using Vagrant 2.1.2. My VM operating system is Ubuntu/Bionic64. This app requires the mysqli extension with mysqlnd, among other packages as described in the attached Vagrantfile.

The problem I am having is PHP reports in the error log when Apache2 starts and continues to report this with every script executed.

[14-Jan-2019 21:48:24 UTC] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/mysql.so' - /usr/lib/php/20131226/mysql.so: undefined symbol: mysqlnd_connect in Unknown on line 0

[14-Jan-2019 21:48:24 UTC] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/mysqli.so' - /usr/lib/php/20131226/mysqli.so: undefined symbol: mysqlnd_connect in Unknown on line 0

I have tried:

  • Checking the .ini files in /etc/php/5.6/cli directory to ensure mysqlnd has lower priority (and thus loads before mysql and mysqli)
  • Renaming the mysqli.so file in the /usr/lib/php/20131226 directory to ensure mysqli loads last
  • Restarting Apache service between all of the above

VAGRANTFILE

# -*- mode: ruby -*- # vi: set ft=ruby : VAGRANTFILE_API_VERSION = '2' APP_NAME = 'app' @script = <<-SCRIPT apt-get update && apt-get upgrade apt-get install -y software-properties-common add-apt-repository ppa:ondrej/php apt-get update #################### PHP 5.6 #################### apt-get install -y apt-utils php5.6 a2dismod php7.0 a2dismod php7.2 a2enmod php5.6 #################### APACHE2 #################### apt-get install -y apache2 libapache2-mod-php # Add ServerName to httpd.conf echo "ServerName localhost" > /etc/apache2/httpd.conf # Setup hosts file VHOST=$(cat <<EOF <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /home/#{APP_NAME}/public_html ServerName localhost ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /> Options Indexes FollowSymLinks MultiViews Includes ExecCGI AllowOverride All Require all granted </Directory> </VirtualHost> EOF ) echo "${VHOST}" > /etc/apache2/sites-enabled/000-default.conf # Enable mod_rewrite a2enmod rewrite # Put PHP into development configuration mv /etc/php/5.6/apache2/php.ini /etc/php/5.6/apache2/php.ini.back cp /usr/lib/php/5.6/php.ini-development /etc/php/5.6/apache2/php.ini # Adjust php.ini file sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 100M/' /etc/php/5.6/apache2/php.ini # Enable PHP extensions in php.ini ###sed -i 's/;extension=php_curl.dll/extension=curl.so/' /etc/php/5.6/apache2/php.ini sed -i 's/;extension=php_mysql.dll/extension=mysql.so/' /etc/php/5.6/apache2/php.ini sed -i 's/;extension=php_mysqli.dll/extension=mysqli.so/' /etc/php/5.6/apache2/php.ini # PHP will log errors here sed -i 's:;error_log = php_errors.log:error_log = /home/#{APP_NAME}/public_html/log/error_log:' /etc/php/5.6/apache2/php.ini #################### PHP Extensions #################### apt-get install -y php5.6-mysql php5.6-mysqli php5.6-bz2 php5.6-cli php5.6-curl php5.6-intl php5.6-json php5.6-mbstring php5.6-opcache php5.6-soap php5.6-sqlite3 php5.6-xml php5.6-zip unzip php5.6-gd # Restart apache systemctl restart apache2.service #################### MYSQL #################### apt-get install -y mysql-server mysql-client-core-5.7 systemctl start mysql.service # Reset root password #/usr/bin/mysqladmin -u root password 'root' mysqladmin -u root password 'root' # Setup database from root user and setup the application user mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS app" mysql -uroot -proot app < /home/#{APP_NAME}/public_html/db/schema.sql mysql -uroot -proot app < /home/#{APP_NAME}/public_html/db/seed.sql mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* to 'vagrant'@'localhost' IDENTIFIED BY '*****'" mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* to 'vagrant'@'%' IDENTIFIED BY '*****'" mysql -uroot -proot -e "FLUSH PRIVILEGES" # Allow remote connections to mysql (don't do it like this in production) MYSQLCONF=$(cat <<EOF [mysqld] bind-address = 0.0.0.0 EOF ) echo "${MYSQLCONF}" >> /etc/mysql/my.cnf # Restart mysql /etc/init.d/mysql restart SCRIPT Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = 'ubuntu/bionic64' config.ssh.insert_key = false config.vm.network "forwarded_port", guest: 80, host: 8080 config.vm.network "forwarded_port", guest: 443, host: 8081 config.vm.network "forwarded_port", guest: 3306, host: 3307 # We do not want Vagrant picking the root directory config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.synced_folder ".", "/home/#{APP_NAME}/public_html" # Provision runs only on the first "Vagrant up" command config.vm.provision 'shell', privileged: true, inline: @script config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] vb.customize ['modifyvm', :id, "--natdnshostresolver1", "on"] #vb.customize ["modifyvm", :id, "--name", "domain.com"] end end 

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.