Search code examples
phphtmlweb-applicationslocalhostserver-side-scripting

Can't connect to localhost using Chrome with Uniform Server


I'm trying to run a .php web application on Google Chrome, using Uniform Server. I thought that just having that installed would make PHP run, but clearly there's a lot I don't know. First off, when I opened the file from file:///C:/Users/... etc the PHP didn't execute properly. Here's the code:

<html>
    <body>
        Hello to you, good sir.
        <?php
            echo "</br> Hello there yourself.";
        ?>
    </body>
</html>

Here's the output on the website:

Hello to you, good sir. Hello there yourself."; ?>

And here's how the <body> code looks from Chrome:

Hello to you, good sir.
<!--?php
    echo "</br-->
Hello there yourself.";

Then, when I tried accessing the file from localhost, Chrome wouldn't even connect, saying:

Oops! Google Chrome could not connect to localhost

I'm aware of this question, but the OP didn't appear to have software needed to run PHP. I'm pretty sure I have the right software, but I don't know how to use it. How do I get Uniform Server to run PHP, and how do I connect to localhost from Chrome?


Solution

  • PHP wont work if opened directly in browser, thats not how PHP works, it needs to be run through the PHP parser.

    A Step by step:

    1. Download the Latest package
    2. Unpack it onto desktop or C:, (somewhere your find it)
    3. Open up the UniServerZ folder, where you unpacked it
    4. Double click UniController.exe
    5. Click Start Apache button - it should go green like below

    enter image description here

    1. Remove the junk files in UniServerZ/www
    2. Put your PHP files inside that www folder.
    3. Visit http://localhost to view your PHP files