PHP has no way to access the IP from the intranet via the extranet mapping

Source: Internet
Author: User
Tags php server php and mysql
This is the case, the server intranet address is: 192.168.28.154,php code and MySQL database are here.

Then PHP needs to link to the database, so it's written in the PHP code:
$dbhost = "192.168.28.154";
...
mysql_connect ("localhost",
...

Now, you may be the PHP code with the MySQL database to deploy to other servers, but I hope that the PHP code can not be modified, then, how to get the current deployment code in PHP server IP address?

Note: An extranet map is set up here: 58.240.33.174:20280, which can be accessed by others via this IP.


Reply to discussion (solution)

If you want to deploy an intranet server, that can not need to change, but if your database is not a LAN or a server to access the intranet, then you have to move the database to the outside network, or you will have to change the database link to the program.

If you want to deploy an intranet server, that can not need to change, but if your database is not a LAN or a server to access the intranet, then you have to move the database to the outside network, or you will have to change the database link to the program.



--------------------------------------------------------------------------------------------------------------- -----------------------------

Hello, assuming I am deploying an intranet server, for example, 192.168.28.151 instead of the original 192.168.28.154, does the code need to be changed now?
$dbhost = "192.168.28.154"; what does this mean?

Both PHP and MySQL are on the same machine.
Then connect MySQL with Locathost rather than IP

Both PHP and MySQL are on the same machine.
Then connect MySQL with Locathost rather than IP



------------------------------------------------------------------------------------

$conn = mysql_connect ("localhost",
I know it's connected to the database,
What's the use of this code?
Why is the current server address assigned directly behind $dbhost?
$dbhost = "192.168.28.154";
$dbuser = "Authpuppy";
$dbpassword = "Authpuppydev";
$dbname = "Authpuppy";
$tbname = "T_node_ad";

That's the initial configuration of the project, you don't have to use it.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.