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!

2
  • Possible duplicate of Apache shows php code instead of executing Commented Jan 6, 2019 at 8: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 ?? Commented Jan 6, 2019 at 9:20

1 Answer 1

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.

<?
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.