Reputation: 59238
I ran into issues with PHPStorm not delivering the website, but returns HTTP 404. I need to setup PHPStorm in a way that it does not serve files from a subdirectory. I know, numerous questions like this have been asked before, so I'll make quite clear what I have configured and tried.
I'm on Windows 10 1903 and I'm using PHPStorm 2019.3 (latest version at the time asking this question)
I have added an entry in C:\Windows\system32\drivers\etc\hosts
to get a name mapped to localhost
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 eigener-prozessor
I can ping it
C:\Users\T>ping eigener-prozessor
Pinging eigener-prozessor [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Ping statistics for 127.0.0.1:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
In PHPStorm, the debugger is set to port 63342. And I allow unsigned requests (not sure if that really has an effect). I can't check "external connections".
In PHPStorm, I have set up an in-place deployment as default, using the host and debugger port
I made sure the mapping is on the root path
I have renamed my project to match the host name (File / Rename Project ...)
I have configured a PHP CLI interpreter and made a php.ini
available
I have marked the source and resource directory
I do make sure that I do not open a local file in a browser but use the buttons for that
It brings me to the correct URL but with HTTP 404. You can see that it serves from PHPStorm 2019.3.1, which is basically correct
In the web developer tools, I see that the IP address is 127.0.0.1
I have used the following SO questions as input:
I have also tried:
If I add eigener-prozessor
as a subdirectory, the website can be accessed - but the resources cannot be loaded, because they point to /css/something.css
, which is exactly why I went through all these steps.
I'm out of ideas. How do I configure the built-in webserver to serve its stuff on the root (/
)?
Please do not suggest a workaround like "use Apache" or "change the path to your resources". I have paid for the software and I expect the built-in webserver to work.
Upvotes: 2
Views: 6549
Reputation: 93728
The trick with hosts
file doesn't work anymore, please follow WEB-38141 for updates. So there is currently no way to set up the built-in web server to serve files from root
Upvotes: 1
Reputation: 14927
Unless I misunderstood something, a simple way to achieve what you need would be to create a custom Run Configuration of type PHP Built-in Web Server
:
Edit Configurations...
+
button on the top left to add a new onePHP Built-in Web Server
Host
to "eigener-prozessor", Port
to 63342.Document Root
field should default to the root of the project, otherwise set it to thatYou should then simply be able to run said configuration with the green triangle/associated hotkey and access the project files directly under http://eigener-prozessor:63342/.
Upvotes: 1