0xburned
0xburned

Reputation: 2655

how to setup built-in webserver in PhpStorm

Set up:

1) OS - Win 8.1
2) WAMP
3) PhpStorm 7.1.3

I have been working on Dreamweaver for quite a long time and recently I ditched it because of its limited features. Setting up a local env using Dreamweaver is fairly simple and I had no problem with it. So I installed PhpStorm thinking it would quite easy to run my PHP web app in the same way when I was using DW, but When I try to run my web app in PhpStorm using its built-in webserver I get 502 Bad Gateway error, What I did is simply import the folder (which is in www directory) in PhpStorm and try to run it on browser, but I couldn't get it to work locally. I believe I have to set up Interpreter under settings, but how do I go ahead and what should I include?

When I run my webapp using WAMP the URL looks like

http://localhost/appname/trunk/public/

When I run it using PhpStorm built-in webserver the URL looks like

http://localhost:63342/appname/trunk/public/

Error: 502 bad gateway.

I am quite stuck now.

Upvotes: 24

Views: 84666

Answers (9)

It’s just happened to me. To overcome it, you can follow the steps in the below picture.

enter image description here

Upvotes: 1

Harrison Steward
Harrison Steward

Reputation: 184

I recently came across a similar problem when attempting to run on a different localhost on my computer.

One easy work around I found was by editing your run/debug configurations.

Before you do this, save a simple batch file to where ever you'd like on your hard drive and name it 'init.bat'.(eg. mine is 'C:\wamp64\www\myhost\init.bat'). Inside this batch file use this code to open your desired website:

start "" http://localhost/appname/trunk/public/

So head over to the run/debug configurations and then choose the php script you want to run. For example mine was called "index.php". When there, at the bottom of the window there should be a section that says, "Before launch: External tool, Activate tool window".

Click 'Run external tool' and from there add your batch file location into the program box.

Now every time you press the green play button, it will open up a the desired website in your default browser.

Upvotes: 1

Jger
Jger

Reputation: 99

sudo apt-get install php-cgi

Maybe will help too.

Upvotes: 10

Hossein Mansouri
Hossein Mansouri

Reputation: 752

if you install wamp server or any other local server in your pc... as i showed in below photos you can set the default localhost to wamp server

enter image description here

enter image description here

Upvotes: 7

shirin niki
shirin niki

Reputation: 823

if you see "PHP interpreter is not configure " warning when you run your projects in phpstrom, do what Mina Fawzy explains in above. But if you want change the port number, you should go to File > Settings > Build, execution and deployment > debuger

and in right site and below of built-in server change your port number. the default port number that wamp uses (if you don't change it manually), is 8080.

Upvotes: 0

Mina Fawzy
Mina Fawzy

Reputation: 21452

First (check your interpreter)

1- From File choose Setting

2- In setting navigate to PHP

3- In Interpreter (if you don't have interpreter you will see message like that )

enter image description here

Second (Add new interpreter)

1-Add new interpreter From Add sign (green plus +) --> choose (other)local if you work in your local pc

2-write any name you want refer to (default PHP)

3- navigate to your PHP directory file From PHP home*

I hope this help you

enter image description here

*If you use wamp you will find it in c:\wamp\bin\php(your php version)

If you use xamp you will find it C:\xampp\php

Upvotes: 34

Thomas Weller
Thomas Weller

Reputation: 59290

After running the PHP site in the browser and getting the 502 bad gateway error, when you switch back to PHPStorm you should see the following message:

PHP Interpreter is not configured

You must have PHP installed on your machine. To do that, you can follow the PHP installation on Windows manual or if you have Chocolatey installed, just type

choco install php

Then, click the configure PHP Interpreter link or go to File / Settings / PHP and choose the PHP installation for the current project. You may also want to go to File / Default Settings / PHP and do the same so that new project benefit from these settings as well.

Note that PHPStorm recognizes the PHP version but does not automatically choose the according language level. Maybe that's by intention for backward-compatible projects.

Upvotes: 3

Sid
Sid

Reputation: 4502

SETTINGS->PHP->Interpreter

You must select interpreter for your PHP storm to run build-in webserver.

Go to Settings->PHP->Interpreter and select one you have. If you don't have, go and download latest PHP interpreter, then come back to phpstorm menu and add Interpreter as shown at picture above.

Upvotes: 1

shahab
shahab

Reputation: 11

go to phpstorm>setting>php onthe right side (assuming you have installed wamp 5.5) choose the php version 5.5 then click the browsing buttion to choose interpreter and then choose the route (assuming you have instaled Wamp on c:/wamp) "C:\wamp\bin\php\php5.5.12" then give a name and apply ,, choose the same route on the interpreter window and add the route , now it should work fine , you can check the video on "http://www.youtube.com/watch?v=953mNQ5KuBI"

Upvotes: 1

Related Questions