使用MySQL 5.6版从源代码编译PHP

I am trying to compile PHP from source to get ZTS working. I have the source for PHP and I try to install the dependencies with

apt-get build-dep php5

I also have MySQL 5.6 installed for Ubuntu 14.04LTS and I am getting this error after the command:

The following packages have unmet dependencies: mysql-server : Depends: mysql-server-5.5 but it is not going to be installed E: Build-dependencies for php5 could not be satisfied.

Is there anyway to bypass this dependency as MySQL 5.6 works ok with prebuilt PHP5 but I cannot start compiling as the dependency is missing? Thanks!

Although not the same issue this MySQL bug report hints at a solution. Try the following steps:

  1. Uninstall mysql-client-5.6 and mysql-server-5.6: [sudo] apt-get remove mysql-client-5.6 mysql-server-5.6.

  2. Initiate your [sudo] apt-get build-dep php5 command. Allow necessary dependencies to be built automatically prior to upgrading again.

  3. Reinstall mysql-5.6. This should replace all references to mysql-5.5. Use the command [sudo] apt-get install mysql-client-5.6 mysql-server-5.6.

This is just a shot in the darkness, but can you try installing the mysql 5.5 first with the required php builds and once you are done, upgrade the mysql to 5.6

As this question is about installing PHP5 from source:
apt-get build-dep is questionable.
The dependencies detection should correspond to the same definitions as in
the provided php5 - debian - package.
As I understand it, you want to have a different build configuration
for your php5 installation, though.
So this is normaly a process of ./configure --your-configure-options
and make clean compile install.
The dependencies definitions that are generated by the call to configure
won't be exported nor visible to apt.
So you will have to resolve the dependecies by yourself, installing the
right version of the software needed to build your php5 - installation
and maybe the development - packages to provide the right headers needed for building.

Why do you use apt-get build-dep instead of install? According to man page of apt-get, "build-deps" will try to remove the installed package to resolve the dependency which here is mysql-server-5.6 . I simply used install and it works.

apt-get install php5

To test if php is using mysql-5.6 I installed PhpMyadmin using apt-get and it works fine with 5.6, you can do the same thing and in the Variables page check for the variable named "Version".

Just as an FYI apt-get build-dep is different from building from source.

PHP can't be compiled from a Git checkout on Ubuntu 14.04 out-of-the-box.

Welcome to dependency hell.

Try compiling from a pre-compiled download.

The reason a Git checkout won't compile is because of dependency issues with Bison. Ubuntu 14.04 has Bison ~3.0.0 and Bison ~2.0.0 is required to compile PHP.

checking for bison... bison -y
checking for bison version... invalid
configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: 3.0, min: 204, excluded: 3.0).
configure: error: bison is required to build PHP/Zend when building a GIT checkout!

Workaround

Here is a workaround to make apt-get build-dep php5 run successfully.

  1. Fully remove MySQL (not just the relevant 5.6 packages)

    It's very important that any and all MySQL packages and any configuration files are fully removed. You can check what mysql packages are installed by running dpkg -l | grep mysql, see What do the various dpkg flags like 'ii' 'rc' mean?

    Uninstall the packages with a purge option: apt-get remove --purge <package name>

    You might also need to manually remove some files. Read the message that the apt-get remove --purge prints and it will tell you if it isn't removing certain files and why it isn't removing them. You need to manually remove those files that apt-get doesn't remove. They will most probably be files somewhere inside the /etc/mysql directory.

  2. Run apt-get build-dep php5

    This makes apt-get build-dep php5 run successfully and will install MySQL 5.5!

  3. Ensure libmcrypt-dev is installed.

    Later when you try compile you will get errors complaining about readline or mcrypt e.g.:

    configure: error: Please reinstall readline - I cannot find readline.h
    

    All of these errors are solved by installing libmcrypt-dev. :) Took me way too long to figure this issue out.

    apt-get install libmcrypt-dev
    
  4. Fully remove MySQL again

    Go through the process as you did in step 1 except this time it's 5.5 you're removing.

  5. Install MySQL 5.6

Troubleshooting: When you try to compile you still get errors?

Ensure that libmcrypt-dev is installed.