?
Solved

How to configure PHP & MySQL so that Apache+PHP in one Linux server can work with MySQP at another Linux server

Posted on 2003-03-17
5
Medium Priority
?
249 Views
Last Modified: 2008-02-26
Hi,

Assumed that Apache+PHP are installed in a server (private IP Address: 192.168.0.3) and MySQL is installed in another Linux server (private IP address: 192.168.2.5). What I should do to configure PHP and MySQL so that they can work with each other (the same as when we install all of them in only Linux server)?

Thanks a lot for your help,

rfr1tz
0
Comment
Question by:rfr1tz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:VGR
ID: 8157937
nothing.

Just make sure your MySql server (mysqld) accepts commands and requests from host#1 (Apache+PHP)

And set up your MySql connections to use IP@ of the MySql server, like this :

$linkID=mysql_connect('192.168.1.2',"$dbLogin","$dbPassword") or die ("bad connect".mysql_error());

mysql_select_db($dbName,$linkID) or die ("bad select DB ".mysql_error());

$query=" [snip]

basically, it's just a rights/IP@/login/password thing to check. Should be easy.
0
 
LVL 3

Author Comment

by:rfr1tz
ID: 8159990
Hi VGR,

Thanks a lot for your reply. I think you've put out very good details on MySQL sides. For Apache+PHP side, I've a question: how Apache+PHP knows that it should send any communication with MySQL to the server with IP address: 182.168.2.5 and don't look to anywhere else? Should I need to set something about IP Address and port number for database connection on Apache+PHP?

Thanks,

rfr1tz
0
 
LVL 15

Expert Comment

by:VGR
ID: 8160960
yes, that exactly what "$linkID=mysql_connect('192.168.1.2',"$dbLogin","$dbPassword") or die ("bad connect".mysql_error());" is about 8-)
It is the PHP (as an Apache module or not) code to access a remote MySql DB on the host '192.*' with user/pw

with a simple GRANT *.* ON ... on the MySql side (flush privileges too, see dox) you should be on in a minute 8-)
0
 
LVL 3

Author Comment

by:rfr1tz
ID: 8167642
Hi VGR,

Thanks a lot for details you've put out. Because I'm pretty new to both Apache+PHP and MySQL, may you give more details about how to set $linkID; for example, which system file I need to set this or can I do it via GUI (KDE). The same for mysql_select_db, $query="[snip].
For $query=..., I see only 1 quote, do we need another quote at the end?
On MySQL side, do I need to do anything else besides successfully starting MySQL so that MySQL accepts commands and requests from Server #1? For example, do I need to set MySQL needs to listen to any port or any connection, etc?

Thanks  a lot for your help and sorry if the questions are trivial,

rfr1tz

0
 
LVL 15

Accepted Solution

by:
VGR earned 400 total points
ID: 8168336
the (pseudo, $query is not erminated, right :D ) code I posted is PHP code.

I suppose you've some front-end language to MySql

Look in its 'MySql functions'.

I may help for PHP though
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

765 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