0

I've been tasked with setting up an old application on a RHEL 7 server. It has an Angular front-end (I'm unsure of the version, but it's old) with a PHP backend. However, in the browser console I can see the Angular files such as angular.min.js and angular-route.min.js all return an error on line 1, column one: "Unexpected token", referring to the <!DOCTYPE html> directive. Then the last message is "angular is not defined".

I suspect this is a problem with PHP? Apache serves the pages (Apache 2.4) but all I get are the text and basic html elements - no css and components & such. So my first question is this PHP or an Angular problem? We have another server with the same setup. I compared our custom configuration files and everything is the same. What else should I be looking for? After enabling PHP and httpd, we use the old apachectl command to start the server (I know it's deprecated, but that's what my reference implementation is using). When I run my phpInfo.php script, all I get is the homepage again.

Here are some portions of my custom configuration. Note that I cannot find the mod_php7.c file on the server (probably the problem, but I don't know what to do instead):

AddType text/html .php
DirectoryIndex index.php
# I cannot find mod_php7.c on my server
<IfModule  mod_php7.c>
    # snip
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
    # snip
</IfModule>
  • "I can see the Angular files such as angular.min.js and angular-route.min.js all return an error on line 1 referring to the directive" Those files shouldn't have a doctype at the top; you're probably seeing a 404 error page. Figure out where those files are, and why they are 404ing. – ceejayoz Aug 30 '23 at 16:32
  • Thanks, but I can’t alter the source. As I mentioned, it all works on the other server. I’m not getting 404, I get 200 when it loads the files. – GirlCoder Aug 30 '23 at 16:47
  • I'm not asking you to alter the source. Look in your browser's network panel at the requests to `angular.min.js`. See what's being returned. It should **not** be HTML. – ceejayoz Aug 30 '23 at 17:04
  • Ok, I'm looking at the response, and it is text/html. The reference application has a `Content-Type` application/javascript. I'm sure this is an important clue, but I don't know what to make of it. The Initiator also shows .php files for the good server, but mine only has .js files... – GirlCoder Aug 30 '23 at 17:33
  • Ah, you lead me right to the problem! My directory structure is incorrect, so the scripts aren't being found. I can't thank you enough! Can you please answer as a question so I can accept? – GirlCoder Aug 30 '23 at 17:38

0 Answers0