更改localhost网络应用程序的名称? [英] changing the name of localhost web app express?

查看:122
本文介绍了更改localhost网络应用程序的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展一个项目,我需要将项目的名称从localhost:9000更改为另一个名称:9000,这在我的开发环境中,而不是生产。

I'm working on a project, and I NEED to change the name of the project from localhost:9000 to someothername:9000, this is in my development environment, not production.

我被赋予了项目文件,而且这个人(不再在这里)使用了express.js。我搜索并搜索了这个答案,但是我无法弄清楚。

I was given the project files, and the person (who is no longer here) used express.js. I've searched and searched for the answer to this, but I cannot figure it out.

所以,是否可以使用express.js或更新gruntfile将localhost:9000的名称更改为其他名称:9000?我知道我可以更改我的电脑上的本地设置,但是我需要通过Web应用程序发生别名。

So, is it possible to change the name of localhost:9000 to someothername:9000 using express.js or updating the gruntfile? I know that I can change the localhost settings on my computer, but I need for there to be an alias that occurs through the web application.

我准备好了我的头发出来:(

I'm ready to rip my hair out. :(

推荐答案

正如您在开发环境中,足以添加

as you are on development environment, its enough to add

127.0.0.1  testurl.test

在底部的

C:\Windows\System32\drivers\etc\hosts

现在将服务器的端口设置为80(用于http的standartport)
您需要更改

now to set the port of the server to 80 (standartport for http) you need to change

project\bin\www

(ejs standart line 15)

(ejs standart line 15)

var port = normalizePort(process.env.PORT || '3000');

var port = normalizePort(process.env.PORT || '80');

现在,如果您在浏览器中键入testurl.test,它应该会显示你的网站。

now, if you type testurl.test in your browser, it should show you the website.

这适用于Windows,如果你有一个mac或者linux,只是改变您需要的主机文件。

this works for windows, if you have an mac or linux, just change the hosts file as you need.

Marius

这篇关于更改localhost网络应用程序的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆