1

After compiling php typing

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql

I could succesfully connect to the database, but then I enabled the openssl and mbstring extensions

I typed

./configure --with-openssl --with-apxs2=/usr/local/apache2/bin/apxs

and

./configure --with-apxs2=/usr/local/apache2/bin/apxs --enable--mbstring --with-libmbfl

Now I'm unabled to connect php with mysql.

This is the code I'm using:

?php
$username = "phptest";
$servername = "localhost";
$password = "cucaramacara";
$dbname = "phpsampledb";


try{
  $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password$
  //set the PDO
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  echo "Connected succesfully";
}
catch(PDOException $e){
        echo "Connection failed:".$e->getMessage();
}

?>

When I type php on the terminal it displays:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20131226/pdo_mysql.so' - /usr/local/lib/php/extensions/no-debug-zts-20131226/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

1
  • You're doing it wrong. ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql --with-openssl --enable--mbstring --with-libmbfl It should be one command, not 3. Commented Jun 24, 2015 at 22:25

1 Answer 1

2

As yoonix noted, you are Doing It Wrong: the configure script should be run ONCE with ALL of the options you want to specify:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql \
             --with-openssl --enable--mbstring --with-libmbfl

Calls to configure are not cumulative - they overwrite each other. The last one wins.

Each option to configure specifies a change from whatever the vendor's defaults are, so what you are doing in your description is telling configure the following:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql

Please prepare to build PHP. Use all of the default settings, except I want to use the PDO MySQL driver.

so configure prepares a build with the PDO MySQL driver. Then you tell it
./configure --with-openssl --with-apxs2=/usr/local/apache2/bin/apxs

Please prepare to build PHP. Use all of the default settings, except I want OpenSSL enabled.

so configure prepares a build with OpenSSL enabled, and all the other defaults (goodbye PDO MySQL driver, since that's not default behavior).

Then you tell it
./configure --with-apxs2=/usr/local/apache2/bin/apxs --enable--mbstring --with-libmbfl

Please prepare to build PHP. Use all of the default settings except enable multibyte strings and libmfl.

so configure prepares a build with those options - No PDO (since that's not a default), and I think no OpenSSL (because I don't think that's a default either).

When you run make each time you're building with only the options specified the last time you ran configure.

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.