?
Solved

PHP in Apache -- as an Apache Module -- how to get MySQL working

Posted on 2006-06-01
9
Medium Priority
?
576 Views
Last Modified: 2008-03-17
When I use PHP in Apache as CGI, MySQL works fine (the MySQL info shows up in phpinfo() )

However, when I put PHP as an Apache Module, the MySQL extension info does not show up in PHPINFO()....

1.) Please help.

2.) I've got an extra question: is Apache Module a better option than CGI? some sites say the Module approach has security problems.... what are they?


===================
THESE ARE HOW I'VE MODIFIED THE APACHE httpd.conf
#VERSION1 PHP - FASTCGI
ScriptAlias /php/ "c:/Apache2.0/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"

#VERSION2 PHP - Apache Module
LoadModule php5_module "c:/Apache2.0/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/Windows"

0
Comment
Question by:jtjli
  • 6
  • 3
9 Comments
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16813262
Your apache module wasn't compiled with mysql support.   It's not enabled by default in the windows version of php5
0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16813276
For more information on how to enable it:

http://www.zend.com/manual/ref.mysql.php
0
 

Author Comment

by:jtjli
ID: 16813331
i have enabled mysql extention in php.ini...

and it is working when PHP is used as CGI

only when it is used as an Apache module it doesn't work...

>> Your apache module wasn't compiled with mysql support

Do you mean I have to compile the file "php5apache2.dll" myself?  HOW??? (the link doesn't say anything about that)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Expert Comment

by:ClickCentric
ID: 16813400
---
PHP 5+

MySQL is no longer enabled by default, so the php_mysql.dll DLL must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. See the FAQ titled "How do I add my PHP directory to the PATH on Windows" for information on how to do this. Although copying libmysql.dll to the Windows system directory also works (because the system directory is by default in the system's PATH), it's not recommended.

As with enabling any PHP extension (such as php_mysql.dll), the PHP directive extension_dir should be set to the directory where the PHP extensions are located. See also the Manual Windows Installation Instructions. An example extension_dir value for PHP 5 is c:\php\ext

    Note: If when starting the web server an error similar to the following occurs: "Unable to load dynamic library './php_mysql.dll'", this is because php_mysql.dll and/or libmysql.dll cannot be found by the system.
---

You did all of that and didn't get those errors when restarting the webserver?
0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16813405
Oh, and I didn't mean that YOU had to compile it, just that it wasn't compiled in.  Sorry.
0
 

Author Comment

by:jtjli
ID: 16813517
ClickCentric,
Yes i have set extension_dir and extension=php_mysql.dll  and with no error --- as i said, mySQL is WORKING just fine with the CGI approach...
only when i try to use the Apache Module approach, it doesn't work
0
 
LVL 10

Accepted Solution

by:
ClickCentric earned 1000 total points
ID: 16813552
Have you attempted to actually run a query via a module call to see what kind of error it throws?
0
 

Author Comment

by:jtjli
ID: 16813691
I have solved the problem by copying libmysql.dll to Apache's bin directory...

thanks...you gave me the inspiration
0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16818570
Was it in another directory in the Windows system PATH before?  And is your Apache bin directory in the Windows system PATH?  In case someone else has your same problem and just having it in any directory in the Window system PATH doesn't work, it may be helpful to have it on record.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question