简体   繁体   中英

Changing HTTP Port from 80 to another

I am trying to make HTTP calls to my server but it is my understanding that HTTP calls are made from port 80. But my server is port 7430. How can I write a php script to change it so I can make the HTTP calls? I am new to this and trying to figure it out thanks

EDIT: this is the php script called test.php I wrote and it doesnt seem to be working

<?php 
   $file = fopen ("http://localhost:7430/herp/derp.json", "r");
   if (!$file) {
   echo "<p>Unable to open remote file.\n";
   exit;
   }
?>

Its suppose to get a JSON response. and from Javascript I make the http get request http://localhost:7430/herp/test.php . Could someone tell me what I am doing wrong?

To make HTTP calls from PHP you would use the URLs directly for simple stuff or CURL for more advanced stuff. When accessing those URLs simply specify the port after domain.

On the other hand, to change the ports your server is listening to cannot be done from PHP, it will require changing webserver (such as apache ) configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM