Search code examples
phpurlservervscode-extensionsliveserver

bad php URL with VS-code project live view from Raspberry server on Windows - extra difficult I think


I'm on Windows and I had the php server and live view server in VS-code running perfectly. Now I have my php webserver running on a Raspberry pi 5, I got my project workspace on my Windows computer, but the Website files on the Raspberry pi5 as well. In my VS-code workspace (Windows) I have imported/linked the folder with the website files from the Raspberry.

And guess what, it doesn't work... smoothly. I can get it to work with some handmade changes in the URL, but that's a drag.

I run the server, and this is what I get:

http://192.168.178.130:3000///192.168.178.85/html/aTotz/root_Directory/index.php

But it works when I remove the first part:

http://192.168.178.130/html/aTotz/root_Directory/index.php

So it can work. What can I do to get the right URL?

Info:

Windows IP: 192.168.1.120

Raspberry IP: 192.168.1.130

Project path on Windows: F:\Andre\Website\01_totZ_website

Website-files path on Raspberry: /var/www/html/Totz

Live server chrome extension (Windows):

Actual Server Address: http://192.168.1.130:3000

Live Server Address: http://192.168.1.130:5500

The folder "Totz" with the website content/files from the Raspberry added in my Windows Workspace has the path:

\\192.168.1.130\html\Totz

The path in my .code-workspace is: "path": "\\\\192.168.178.130\\html\\aTotz"

My settings.json looks like this:

> "phpserver.phpPath": "",
> "liveServer.settings.donotShowInfoMsg": true,
>     "security.allowedUNCHosts": [
>         "192.168.178.130",
>         "wsl.192.168.178.130"
>     ],
>     "remote.SSH.remotePlatform": {
>         "192.168.178.130": "linux"
>     },
>     "phpserver.phpConfigPath": "/etc/php/8.2/apache2/php.ini",
>     "phpserver.relativePath": "/var/www/html",
>     "phpserver.ip": "192.168.178.130",
>     "workbench.colorCustomizations": {
>
>     },
>     "liveServer.settings.host": "192.168.178.130",
>     "liveServer.settings.useLocalIp": true,

I reckon that the problem is the Path of the "Totz" folder in my workspace. This \\192.168.1.130\html\Totz needs to go somehow. But I don't know how to "change" that.

I'd used a ssh tunnel at first, but than it runs the VS-code from the Raspberry and I had to copy all my settings and extensions over which I didn't want. I want to run the project from my Windows pc, preferably with the files on my Raspberry, and with the php server on my Raspberry.

Is there any solution to this?

thank you so much sincerely!

I've tried to replace several ip's with either "localhost" or "0.0.0.0", but it didn't change anything to the URL. The php server itself is being reached. That part works fine as it appears.

If I change the folder path in .code-workspace, the "Totz" folder is not being propperly loaded.


Solution

  • Ensure the configuration between Windows and Raspberry Pi is consistent. In settings.json, change the path to be relative to the web server on the Raspberry Pi, not the absolute Windows path.

    "phpserver.relativePath": "/html/aTotz/root_Directory"
    

    This will guarantee that the URLs generated by VS Code match the Raspberry Pi's server structure correctly.