amazon ec2 - 500 Internal Server Error php code ec2 instance
Get the solution ↓↓↓I have a PHP file with a post API call (refer below).
<html>
<head>
<Title>Temp</Title>
<link rel="icon" href="logo.png" type="image/x-icon">
<script>
<?php
// $tranData = "hello world";
$tranData = $_REQUEST['trandata'];
$status = 'ERROR_PAGE';
// $tranData = '22120070AE5D3475A66502266511A34F5691A46962B2A83C34C93C45A43DA9D7335946B521A60E588312EBFCF60791C100F4990A09CA527936FC9B0F39552848BB7B119269A665080A20EA66ECD2802D64ACBEC4B6A9A57AC34A73EF0A81FD9A27878DCFE5A545A56FDFA34D82879B8DE833989E2125ED011D4CCE78C3698D8C83D2F4616C0D9461167BA97DC4788B5E4D8B2B142B6DAAAC639699C1C25221022C05D08C9ACD90A129E2CB5CFA7F40CE60BA3758AFCA0AED1E47FD2CDAA07B248D5AB14E2C08AD4BD27471C77957D663ED6B7F562E8F0FD1B845D051B2DC9A51';
if ($tranData != '') {
$data = array(
'action' => 'decrypt',
'type' => 'knet',
'trandata' => $tranData
);
$url = '<api_url>';
$ch = curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
CURLOPT_POSTFIELDS => json_encode($data)
));
$response = curl_exec($ch);
if ($response === FALSE) {
die(curl_error($ch));
}
$responseData = json_decode($response, TRUE);
$responses;
$paymentId;
if ($responseData['statusCode'] == 200) {
$responses = explode("&", $responseData['decrypt_trandata']);
$paymentId = explode("=", $responses[0])[1];
$status = explode("=", $responses[1])[1];
} else {
$status = 'decryption error';
}
} else {
$status = 'ERROR PAGE';
}
?>
</script>
</head>
<body>
<div id='normalView' class="successView">Hello World <?php echo ($status);
echo ($paymentId); ?></div>
</body>
</html>
In the localhost, it is working as expected.
Now I have uploaded this file to my ec2 instance. When I opened the page with ec2 url, the following error appeared,
If I removed the POST API call code, the page is rendering fine. Normal PHP variables also working as expected.
I'm sure there is some problem while doing this API call in ec2 instance.
Thanks for any suggestions!
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: apache/2.4.52 (win64) openssl/1.1.1m php/8.1.2 server at localhost port 80
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.