1

I have installed PHPstorm 10.0.3 Trial, and PHP in my Apache folder on Windows machine, however when I use PHP interpreter I'm getting error 502 Bad Gateway around 50-90% of time.
When this is only HTML page, it works 100%of time.

Edit: What I do is 'run' my template.php(or any other)file which then appears in browser with url: http://localhost:63342/htdocs/template.php

I have tested: PHP 7.0.2, PHP 5.3(ISS), first one thread safe, second one thread safe disabled, same results. In Webstorm my path is pointing to PHP-CGI.exe which was problem in different topics.

Only hint about what is going on I was able to find out by clicking: PHPstorm/Help/Show Log in Explorer. So anytime I get Error 502 something along these lines comes up:

2016-01-14 09:57:21,510 [1084784]  ERROR - ins.io.ChannelExceptionHandler - PhpStorm 10.0.3  Build #PS-143.1770 
2016-01-14 09:57:21,510 [1084784]  ERROR - ins.io.ChannelExceptionHandler - JDK: 1.8.0_51 
2016-01-14 09:57:21,510 [1084784]  ERROR - ins.io.ChannelExceptionHandler - VM: Java HotSpot(TM) Server VM 
2016-01-14 09:57:21,510 [1084784]  ERROR - ins.io.ChannelExceptionHandler - Vendor: Oracle Corporation 
2016-01-14 09:57:21,510 [1084784]  ERROR - ins.io.ChannelExceptionHandler - OS: Windows 7 
2016-01-14 09:57:21,511 [1084785]   INFO - ins.io.ChannelExceptionHandler - Channel will be closed due to error 
2016-01-14 09:57:24,273 [1087547]  ERROR - ins.io.ChannelExceptionHandler - minimumReadableBytes: -2815 (expected: >= 0) 
java.lang.IllegalArgumentException: minimumReadableBytes: -2815 (expected: >= 0)
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1143)
    at io.netty.buffer.AbstractByteBuf.skipBytes(AbstractByteBuf.java:731)
    at org.jetbrains.io.Decoder.getBufferIfSufficient(Decoder.java:131)
    at org.jetbrains.io.fastCgi.FastCgiDecoder.messageReceived(FastCgiDecoder.kt:56)
    at org.jetbrains.io.Decoder.channelRead(Decoder.java:38)
    at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
    at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:950)
    at io.netty.channel.oio.AbstractOioByteChannel.doRead(AbstractOioByteChannel.java:166)
    at io.netty.channel.oio.AbstractOioChannel$1.run(AbstractOioChannel.java:38)
    at io.netty.channel.ThreadPerChannelEventLoop.run(ThreadPerChannelEventLoop.java:52)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:55)

minimumReadableBytes is changing from record to record.

Juraj
  • 53
  • 1
  • 7
  • How do you use it (your PHP Interpreter)? What WebStorm has to do with PHP? Screenshots please -- it's not clear at all. – LazyOne Jan 14 '16 at 09:45
  • Sorry, I have fixed that now, its PhpStorm. Additionally any php file triggers the error, does not even need to contain any PHP code. – Juraj Jan 14 '16 at 09:51
  • You fixed the issue? Great. It's not about presence or absence of PHP code -- my question was about "what do you do that you have such issue". If it's happening when you running CLI script -- how do you do this? If you executing something in a browser -- how do you do this, what the URL etc? There is NO information about this at all in your question .. just generic (and *very helpful* -- pun intended) "it does not work". – LazyOne Jan 14 '16 at 10:00
  • No, I haven't. What I meant is that I changed WebStorm description to PHP Storm. Now I have edited my question to add details you were requesting. Basically to reproduce what I get is to simply run any PHP file trough the application and I get most of the time above mentioned error. If you think there is anything I can be more exact about please tell me so, I'm the one asking for help. – Juraj Jan 14 '16 at 10:20
  • You are using PhpStorm's own built-in web server, which has issues right now (especially with POST requests). The solution is to use your own proper web server (Apache/IIS/nginx/whatever) -- just define Deployment entry ("In place" type should be fine, as long as your Apache/IIS can serve files from that location), configure it (provide desired URL) and mark as Default for this project -- now IDE will use that URL when you are choosing to Run or Debug (but it will NOT affect any existing Run/Debug Configurations -- only future ones; current configs you will have to update manually) – LazyOne Jan 14 '16 at 10:25
  • Yes, this seems to work now. Thank you for this workaround. – Juraj Jan 14 '16 at 10:47

2 Answers2

6

You are using PhpStorm's own built-in web server, which has some issues right now (especially with POST requests, e.g. WEB-17317).

The solution is to use your own proper web server (Apache/IIS/nginx/whatever).

  1. Define Deployment entry. In place type should be fine, as long as your Apache/IIS can serve files from that location; otherwise either configure web server to be able to do that .. or use another type of deployment (e.g. Local or Mounted Folders for IDE to copy files to another location for you)
  2. Configure it (provide desired URL etc)
  3. Mark it as Default for this project

Now IDE will use that base URL when you will use Open in Browser or Run/Debug actions (NOTE: it will not affect any existing Run/Debug Configurations -- only future ones; you will have to update your current Run/Debug Configurations manually).

LazyOne
  • 158,824
  • 45
  • 388
  • 391
1

This is what worked for me.

I opened XAMPP control panel v3.2.2, I went into Apache->Config->httpd.conf and changed the below code

Listen 12.34.56.78:80

Listen 80

to

Listen 12.34.56.78:8080

Listen 8080

Also, ServerName localhost:80

to ServerName localhost:8080

saved the file httpd.conf and then started the apache below action from the main screen of XAMPP Control Panel v3.2.2 and it started the apache.

After that I opened the browser and MANUALLY typed the address for example:

If previous address was: http:// localhost:63342/htdocs/template.php (no space inbetween)

the new one would be:http:// localhost:8080/template.php (no space inbetween)

It should run just fine. Refresh the page and you shouldn't get 502 Bad Gateway error.

Remember: If you run your application later it may go back to previous location, All you need to do is, use the new location on address bar which would be (in this case) http:// localhost:8080/template.php. (no space inbetween) In your case: http:// localhost:8080/yourfilename.php (no space inbetween)

Community
  • 1
  • 1