本文介绍了PHPStorm:在浏览器中打开选项:如何设置要打开的默认服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于PHPStorm,我已经在C:\ site位置打开了一个项目/站点.然后,我从菜单栏中在本地主机端口8081处添加了一个内置的PHP Webserver:运行>编辑配置.

For PHPStorm, I have opened a project/site at location C:\site. Then, I went ahead and added a built in PHP Webserver at localhost port 8081 from the Menu Bar: Run > Edit Configurations.

要查看index.php文件,当我单击视图">在浏览器中打开">"Chrome(或任何其他浏览器)"时,它将带我到 http://localhost:63342/site/index.php

To view index.php file, when I click on View > Open in Browser > Chrome (or any other browser), it takes me to http://localhost:63342/site/index.php

那么,看起来它创建了另一个在端口63342运行的服务器吗?另外,它的路径为/site/index.php而不是/index.php.

So, looks like it created another server running at port 63342? Also, it has the path as /site/index.php instead of just /index.php.

有没有一种配置方式,当我单击视图>在浏览器中打开>浏览器名称时,它将带到localhost:8081/index.php?

Is there a way to configure so that when I click view > open in browser > browser_name, it will take to localhost:8081/index.php?

还可以关闭在63342端口运行的服务器吗?

Also, is it possible to turn off that server running at 63342 port?

版本:我正在尝试PHPStorm 8和9,它们都表现出相同的行为.

Version: I am trying on PHPStorm 8 and 9 and both show same behavior.

推荐答案

http://localhost:63342/PROJECT_NAME/ PhpStorm自己的简单内置Web服务器.如果未定义部署"条目(或已定义但该项目中没有一个标记为默认项),则使用该字段.

http://localhost:63342/PROJECT_NAME/ is PhpStorm's own simple built-in web server in action. It is used if no Deployment entries are defined (or defined but non of them is marked as default for this project).

使用Open in Browser动作时,IDE将检查您的部署设置,以查找将用于在浏览器中打开此类文件的基本URL.如果找不到任何此类条目,则将使用其自己的内置Web服务器,而不是使用file://协议打开此文件.

When you use Open in Browser action IDE checks your deployment settings looking for base URL that will be used to open such file in a browser. If it finds no such entries then instead of opening this file using file:// protocol it uses its' own built-in web server.

..要使用您的特定Web服务器/URL,您必须:

So .. to use your specific web server / URL you have to:

  1. Settings (Preferences on Mac) | Build, Execution, Deployment | Deployment
  2. 创建适当类型的新条目(或者,如果已经完成,请完成配置现有条目)
  3. 配置它(提供URL和路径),以使前两个选项卡(连接和映射")不显示警告.
  4. 将此项目标记为默认项目
  1. Settings (Preferences on Mac) | Build, Execution, Deployment | Deployment
  2. Create new entry of appropriate type (or finish configuring already existing one, if you have done it already)
  3. Configure it (provide URL and paths) so that no warnings is shown for first 2 tabs (Connection & Mappings).
  4. Mark such entry as Default for this project

现在,当您使用Open in Browser操作时,IDE将使用这些详细信息.

Now IDE will use those details when you use Open in Browser action.

注意::Open in Browser操作不会启动您的Web服务器(您为端口8081创建的服务器),它只是在浏览器中打开URL.使用此操作之前,您必须确保服务器已在运行.

NOTE: that Open in Browser action will not launch your web server (the one you have created for port 8081) -- it just opens URL in browser. You will have to make sure that your server is already running before using this action.

有用的链接:

  1. 在PhpStorm中的部署
  2. 在PhpStorm中使用内置Web服务器
  1. Deployments in PhpStorm
  2. Using the Built-in Webserver in PhpStorm

这篇关于PHPStorm:在浏览器中打开选项:如何设置要打开的默认服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 22:51