AngularJS下载PHP文件而不是显示它们,缺少什么?

I'm trying to develop an AngularJS app but I have this problem. I want to access a database through the app but instead of loading the php file, it downloads it. Even if I access directly to the file (mydomain.com:8000/app/file.php), it's being downloaded.

If I try to access from outside Angular, that same file (mydomain.com/appname/app/file.php), loads correctly: it access a database and retrieves data.

So, what am I missing? do I need anything aditional? I was firstly basing this test project from the Angular Phonecatt App that AngularJs has as basic tutorial, then I read other tutorials about database access.

This is the controller code:

'use strict';

var cashewApp = angular.module('cashewApp', []);

cashewApp.controller('categoriesCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('file.php').
    success(function(data) {
        $scope.categories = data;
    });
}]);

And my php file code:

<?php
    $db_name  = 'db_name';
    $hostname = 'localhost';
    $username = 'user';
    $password = 'pass';

    $dbh = new PDO("mysql:host=$hostname;dbname=$db_name", $username, $password);

    $sql = 'SELECT * FROM Categories';

    $stmt = $dbh->prepare( $sql );
    $stmt->execute();
    $result = $stmt->fetchAll( PDO::FETCH_ASSOC );
    echo json_encode( $result );
?>

I've tried this locally and remotely, both setups work fine without the php part, I see no errors when starting the server, so I have no clue.

Thanks in advance!


After modifying the ports.conf file like this and restarting apache:

# /etc/apache2/sites-enabled/000-default.conf

Listen 80
Listen 8000

<IfModule ssl_module>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Angular doesn't work.