Failed to execute php curl request with port number

I cannot execute php curl request with port number, without port number. I get the answer correctly.

Through the terminal, when I do curl http://www.sample.com:8088 , I get the answer back properly. But not through php curl when doing curl_inf () I get

Array ( [url] => http://www.sample.com:8088/ [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => 0 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [certinfo] => Array ( ) ) 

My code

 $url = "http://www.sample.com:8088/"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_TIMEOUT, 400); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, True); curl_setopt($ch, CURLOPT_RETURNTRANSFER, True); $report=curl_getinfo($ch); print_r($report); $result = curl_exec($ch); curl_close($ch); echo $result; 

this code gives me a response from ubuntu but does not give a response from cent os if a port number is specified.

Please let me know how to fix this.

Extremely important.

+7
source share
6 answers

I went to the server administrator with this problem, and he changed the configuration in centos

in the folder / etc / sysconfig /

he edited the selinux file and changed SELINUX = disabled and recounted it.

 # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled 

and my problem is resolved.

+3
source

Try setting the port as follows:

 curl_setopt($ch, CURLOPT_PORT, $_SERVER['SERVER_PORT']); 

or

 curl_setopt($ch, CURLOPT_PORT, 8088); 
+16
source

Try to install

 curl_setopt($ch,CURLOPT_PORT, 8088); 

Additional information http://php.net/manual/en/function.curl-setopt.php

+7
source

Add

 curl_setopt($ch, CURLOPT_PORT, 8088); 

Curl_setopt link

+3
source

Verify that port 8080 is enabled on Cent OS

and try curl_setopt($ch, CURLOPT_PORT, 8088);

+2
source

"setsebool httpd_can_network_connect on" solves the problem for me

+1
source

All Articles