Score:0

Installing PHP 7.3 on RHEL 7 - Angular/PHP files don't process

sd flag

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>
vn flag
"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 <!DOCTYPE html> 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.
GirlCoder avatar
sd flag
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.
vn flag
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.
GirlCoder avatar
sd flag
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 avatar
sd flag
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?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.