Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed apache and php from source and got them working together a month ago. Because I'm learning both of them this term.
Now I need mysql to do more works. And I installed mysql from source just now. However I don't know how to let it work with php.
I looked around and found some topics on setting up LAMP environment. Most of them install mysql first and use command options --with-mysql=/usr/local/mysql and --with-mysqli=/usr/local/mysql/bin/mysql_config when installing php. But in my case, I installed php first.
Is there any way to let php know that I have installed mysql? Or should I reinstall php ?

share|improve this question
Try enabling the mysql options on the php.ini file and see if that works. But you may need to re-compile php with the --with-mysql option rewardless. – Martín Canaval Jan 19 '13 at 9:39
@MartínCanaval could u tell me how to recompile php ? my source is still there. – Ggicci Jan 19 '13 at 9:43
It's the same as I suppose you did except this part ./configure --with-mysql && make Previous and next steps are the same. Oh and maybe pointing to wherever mysql is, like --with-mysql=/usr/bin/mysql_config --with-mysqli=mysqlnd – Martín Canaval Jan 19 '13 at 9:53
@MartínCanaval thanx, I know what to do now... – Ggicci Jan 19 '13 at 9:57
If everything works out, post an answer to your question and accept it with details of that you did, for others with the same problem. – Martín Canaval Jan 19 '13 at 10:43
up vote 1 down vote accepted

Finally I recompiled my php source with appending --with-mysql=/opt/mysql, --with-mysqli=/opt/mysql/bin/mysql_config and --with-pdo-mysql three configure options to let my php support the modules of mysql. Steps taken as follows:
1> stop apache and mysql services
2> backup php.ini
3> remove php
4> reconfigure php source
./configure --prefix=/opt/php --with-apxs2=/opt/apache/bin/apxs --with-mysql=/opt/mysql --with-mysqli=/opt/mysql/bin/mysql_config --with-pdo-mysql --...and other options
5> make and then make install
6> copy php.ini back and uncomment the corresponding directs on mysql modules

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .