I moved my mysql database to a box that was recently installed with the Redhat 7 Installation CDs. I set the machine up as a server and selected virtually every PHP and MySQL option available in the installation process. Yet now when I access my database through the web I get:

Call to undefined function: mysql_connect()

... which for me would normally mean MySQL capabilities weren't compiled in to PHP. This seems very odd to me given that I ran the "vanilla" Redhat server install with everything turned on.

My question - is there a way for me to verify whether MySQL awareness is compiled in? Is my only recourse to compile from source? If so, is there anything to watch out for given that I'm installing over an existing PHP4?

Thanks much in advance,
Tiggy

    If you have PHP already installed, copy and paste the following into a new .php file:

    <?php
    phpinfo();
    ?>

    Run this file through your browser and you will get a document that will tell you about all the server variables etc that you can use. Also, it will tell you what PHP extensions you have running on your computer. Simple scroll down and if you see one that says "MySQL" (and if it's there you wont miss it, trust me) then you do have the MySQL module installed. If it's not there then you havent.

      Thanks a bunch - sure enough, I found the "without-mysql" configure flag. How brain-dead is that for a default setting? Oh well... is my only option to compile the source? I have it available and see there are about 10 dependency items missing on my system - I'm not really interested in installing the development environment for tons of different packages if I can help it. Are you aware of any binaries with MySQL awareness already compiled in?

      Thanks again,
      Al


        Compiling from source is probably the only way to go for you giving the extremely stupid default setting. It's not as hard as it seems, though. First, use phpinfo() to find all the other configure options that you may still want to use. Then, my recommendation would be to first remove the PHP RPM that came with RedHat. If it complains about dependencies, use --nodeps like so:

        rpm -e --nodeps php-x.x.x-xx

        or whatever the exact name of the package is (you don't need the .i386.rpm part because that's part of the filename, not the package name). To find the package name, do something like "rpm -qa | grep php" what this does is query all installed pacakges (q for query, a for all) and then pipe those results to grep and only show the ones that contain "php". Then you can erase the package.

        Then, download the source and build it. It's not too hard. Usually you'll want something like this:

        ./configure --with-apxs=/path/to/apxs --with-mysql=/path/to/mysql

        You'll also want to include anything else from the original list of configure options that you may want to use. If you don't use --with-mysql, the builtin client libraries will be used. However, I put it there so I know it's always the newest version of the clients being used since I always have the newest version of MySQL installed. Then:

        make
        (become root)
        make install

        Then read the INSTALL file for any additional instructions.

          Thanks for the generous and helpful reply. Looks like I'll need to set a chunk of time aside - I evidently have to install the following dependencies first:

          error: failed build dependencies:
          httpd-devel is needed by php-4.2.2-7
          imap-devel >= 2000-9 is needed by php-4.2.2-7
          mysql-devel is needed by php-4.2.2-7
          pspell-devel is needed by php-4.2.2-7
          curl-devel >= 7.9 is needed by php-4.2.2-7
          net-snmp-devel is needed by php-4.2.2-7
          libxml2-devel >= 2.4 is needed by php-4.2.2-7
          imap-devel is needed by php-4.2.2-7

          Well, that's one minute whining that I could have been installing... :-) Thanks again,
          Al


            Wait a sec, are you getting those errors when you try to take the PHP RPM off? Because if you are, just use --nodeps since you will be putting PHP right back on again (building it from source) it shouldn't be a problem.

            Otherwise, I don't see how you could get these kinds of errors while installing PHP because a) the dependencies should be satisfied by the installation process and b) where did you get a PHP RPM to use that you know has MySQL support? I thought you were going to have to build from source.

            Please enlighten me 😃.

              Actually I'm much more familiar with the conventional build process, but as a relative linux newbie I thought I'd try the RPM gizmo. What I'm working with is a source RPM, and I get those dependency flags when I'm runing the spec file (rpm -ba .spec if memory serves.) If this is unecessarily muddying the waters for what I'm trying to accomplish I certainly have no problem just working with the tar.Z version or whatever - what do you think?

              Thanks again,
              Al

                Write a Reply...