Built-in Webserver in PhpStorm

Ever since PhpStorm 6, we’ve had a built-in webserver which could serve up static content like HTML, JavaScript and CSS. With the latest version of the PhpStorm 7 EAP we have now added support for serving PHP from this webserver as well!

How does this work? It’s pretty easy! After opening a project in PhpStorm, navigate to http://localhost:63342/<projectname>. For example when working in a project called HelloWorld, navigate to http://localhost:63342/HelloWorld/. This URL will serve our project files using the project root as the webserver’s content root.

We have a short tutorial available with some more details on this feature.

Give PhpStorm 7 EAP a try. And as always, let us hear your thoughts in the issue tracker, through the comments below or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

This entry was posted in Cool Feature, Early Access Program and tagged , , , . Bookmark the permalink.

34 Responses to Built-in Webserver in PhpStorm

  1. Michal Suski says:

    How do I turn it off?

  2. Jannik says:

    I just tried it for fun with a symfony2 project: http://localhost:63342/Liim/web/app_dev.php (Liim is the name of the project).

    Result: 502 Bad Gateway

  3. Clint says:

    What, then, is the use of also creating a run configuration utilizing PHP 5.4+’s built in web-server if this is now available? Is it not redundant to setup a run configuration with PHP’s built in webserver if the fast-cgi version of PHP is running anyways and can’t be disabled? What are the pros/cons of each method? The documentation doesn’t cover the differences.

    • Maarten Balliauw says:

      Setting up a run configuration allows you to specify additional options your application may need. The built-in server uses the current PHP.ini but does not allow specifying additional runtime options. It also hosts your app under a directory and not at the root as opposed to the PHP-provided server.

  4. Clint says:

    What is the purpose of keeping the Fast-CGI executable running at all times without the ability to stop it?

    The run configuration PHP built-in webserver method allows us to easily stop the server between runs. So, why do we have an ability in one instance that we don’t have in the other? It seems a lot of people want it.

  5. Shahid says:

    Hi Jannik, i have figured out why are you having that problem. Well, all you need to do is to figure out your php interpreter. This could be done by following these simple steps:
    1- Open phpStorm.
    2- Go to File -> Settings -> php

    There you will have dialog, where on the very top of it, you can see the php language level (installed on your system will automatically be configured by phpStorm).

    3- In the next Interpreter combo list, you will look for the directory where your php folder resides like in my case it was: C:\xampp\php

    What it does is that it fetches the php.exe file from it which works as an interpreter for all the php code you write in your IDE.

    4- Press Apply button.

    Enjoy;-)

  6. Stophe says:

    Is it possible to change the port?

  7. John McCann says:

    How do I turn off the built in php server if I manage to get it stuck in an infinite loop!!!?

    The stop button doesn’t seem to work, I still get masses of output scrolling past.

  8. Sam says:

    I get the error:

    php-cgi not found
    Please ensure that configured PHP Interpreter built as CGI program (–enable-fastcgi was specified)

    Is there some easy way to do this? (I’m on Ubuntu)

    • Mikhail Vink says:

      phpinfo(); function, there is “Configure Command” to check that.

      • howdy says:

        I have also run into this same issue —

        php-cgi not found
        Please ensure that configured PHP Interpreter built as CGI program (–enable-fastcgi was specified)

        I do not have any enable fastcgi entries in my php.ini. What is the “Configure Command” you’re referring to?

      • howdy says:

        I’m also running on Ubuntu 12.04 and compared the phpinfo() listed on the page and my own. I don’t have a Configure Command field as listed above. Also, my “Server API” is “Apache 2.0 Handler” and not “CGI/Fast CGI” as listed in the Windows phpinfo() file at the top of the page.

        • tornodo says:

          just do this :sudo apt-get install php-cgi

          • Timid says:

            Noob here.

            I am on a Mac; where can I find the files to install and how do I do that Please.
            I tried installing with brew and located a fcgi package. But that doesn’t seem te work :-(

  9. rearndt says:

    Let’s try asking Mr. Suski’s original question again :

    How do you turn this built-in server OFF?

    The operative word here is “OFF”. I did not purchase a license for this product to be dictated to about how to serve my pages.

    I hope this is not too difficult.

    Thanks.

    • Maarten Balliauw says:

      See http://youtrack.jetbrains.com/issue/WEB-9144 – it is not possible at the moment but you do not have to sue it. Working with your own prefered server is fine too.

      • Robert Arndt says:

        Thanks, Maarten. This was absolutely ZERO help. I really appreciate it.

        • Maarten Balliauw says:

          Hi Robert,

          You can still work with PHP’s built-in server, Apache, IIS or any other webserver. You do not have to use the built-in server, you are free to use whichever webserver you prefer.

          As for turning it off, that indeed is not possible at the moment. It is locked down to only accept connections from localhost by default, and not from the internal network.

          If you do feel turning it off completely, please continue the discussion at http://youtrack.jetbrains.com/issue/WEB-9144.

          Best regards,
          Maarten

  10. Bob Spero says:

    I tested this also and get 502 error as well on ubuntu 13.10

  11. Phil says:

    just got it working.

    Bad Gateways, and how do I use my own server.

    1. Make sure php5-cgi is installed (sudo apt-get install)
    2. Meditate over this sentence: “LiveEdit Since version 0.5 LiveEdit works as part of JavaScript debug session”.

    I overread this several times. Then I remembered to ponder twice, whatever is printed fat.

    3. After having setup a Javascript “Debug-Session in JB it worked. ;)

    4. If you’re using your own server just make sure you configure the path in the script-debug session (theres a field for “path” you type the URL you want to debug)

    5. Last but not least – the JB-Chrome plugin will state that it is: “connected to JetBrains IDE” if it finds a running instance on your computer but as long as you didn’t install the LiveEdit Plugin in your IDE, this wont be of much help.

    Have Fun

    Phil

  12. Ryan Sheehy says:

    Hi,

    When using this built-in server to test html, js, or css code with domain root reference it doesn’t link properly to the asset (no doubt happening due to the project’s folder being placed one directory level up on the localhost domain).

    eg. if we had within a html file . Instead of referencing http://localhost:63342/project/img/1.png it instead references http://localhost:63342/img/1.png

    Would it be possible to set the project at the localhost domain?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">