0

I am setting up a new website.

I am hosting it by myself in a linode node. The site is already up and running.

I installed nginx running on the port 80, and apache running on the port 8001.

My problem is that when I do the AJAX call, the response (responseText) is the whole php code. I don't understand how to make it run through Apache.

I haven't done any configuration to apache other than changing the port to not collide with the nginx.

apache2 installed, nginx installed.

function getSuccessOutput() {
$.ajax({
    method: 'get',
    url:'test.php',
    complete: function (response) {
    console.log(response.responseText);
        $('#output').html(response.responseText);
    },
    error: function () {
        $('#output').html('Bummer: there was an error!');
    },
});
return false;

}

In the console I get the full php script.

The PHP finishes with an echo $result. If I run it with php -f in the server outputs the result OK.

I just need the result in the responseText, I will see how to handle it later.

I am not understanding how to make the code run on apache, I understand it needs to get interpreted by someone, but I don't know how to do it.

Thanks!

TiraULTI
  • 199
  • 1
  • 2
  • 15
  • Possible duplicate of [Apache shows php code instead of executing](https://stackoverflow.com/questions/12142172/apache-shows-php-code-instead-of-executing) – BadPiggie Jan 06 '19 at 08:56
  • if you point the browser directly at `test.php` on Apache does it work? The request should include the non-standard port - something like `http://localhost:8001/test.php` ?? – Professor Abronsius Jan 06 '19 at 09:20

1 Answers1

1

Check your php file, if there is an open tag in the beginning of the file:

<?php

Do not use short open tags because it is only available if enabled using the short_open_tag in the php.ini configuration file.

<?
hlorand
  • 1,070
  • 10
  • 8