如何在localhost上运行文件? [英] How do I run a file on localhost?

查看:271
本文介绍了如何在localhost上运行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在localhost上实际运行文件?
我知道它有效,但我如何在其上运行文件,如何验证该文件实际上是在localhost上运行?

How do I actually run a file on localhost? I know it is working, but how do I run a file on it, and how do I verify that the file is in fact running on localhost?

服务器新手在这里,其他问题(我有运行Apache 2.2的xampp):
从你的回复中我觉得我必须在浏览器中键入路径才能打开文件本地主机。所以,如果我想将文件放在子目录中,我必须输入包括目录在内的完整路径?

Server newbie here, additional questions (I have xampp running Apache 2.2): From your responses it sounds like I have to type in the path in the browser in order to open the file on the localhost. So, if I want to have the file in a subdirectory, I would have to type the full path including the directory?

当我处理html时,有没有办法让浏览器指向localhost,而不是必须一直输入路径?

Is there a way to have the browser point to the localhost while I am working on my html, instead of having to type in the path all the time?

我在Dreamweaver CS3中工作,想要使用 include 命令(SSI或PHP),但不必继续将我的文件放在HostGator上为了看看它们是否正常工作。

I am working in Dreamweaver CS3, and want to use include commands (either SSI or PHP), but not have to keep putting my files up on HostGator in order to see if they are working.

这样做的最佳方法是什么(具体来说,我什么都不知道)。如果在任何地方都有详细的教程,非常感谢链接。

What is the best way to do this (please be specific, I know nothing). If there is a detailed tutorial anywhere, really appreciate a link.

谢谢

推荐答案

好的,感谢更具体的信息,人们现在可以删除他们的downvotes ...

Ok, thanks for the more specific info, ppl may remove their downvotes now...

你提出的建议是非常普遍的事情!您希望在本地运行Web应用程序,而无需将其上载到主机。这完全没问题,这就是你的Apache的用途。您的Apache是​​一个Web服务器,意味着它的主要目的是提供HTML,PHP,ASP等文件。有些像PHP;它首先发送给解释器,然后将呈现的文件发送到浏览器。总而言之:它只是为您的浏览器(客户端)提供页面。

What you are proposing is a very common thing to do! You want to run your web application locally without uploading it to your host yet. That's totally fine and that's what your Apache is there for. Your Apache is a web server meaning its main purpose is to serve HTML, PHP, ASP, etc. files. Some like PHP; it first sends to the interpreter and then sends the rendered file to the browser. All in all: it's just serving pages to your browser (the client).

您的Web服务器有一个根目录,即wwwroot(IIS)或htdocs(apache,xampp)或其他类似public_html,www或html等。这取决于您的操作系统和Web服务器。

Your web server has a root directory which is wwwroot (IIS) or htdocs (apache, xampp) or something else like public_html, www or html, etc. It depends on your OS and web server.

现在,如果您在浏览器中输入 http:// localhost ,您的浏览器将会被定向到这个webroot,服务器将提供任何 index.html index.php 等,它可以找到那里(以可定制的顺序)。

Now if you type http://localhost into your browser, your browser will be directed to this webroot and the server will serve any index.html, index.php, etc. it can find there (in a customizable order).

如果您有一个名为mytutorial的项目,您可以输入 http:// localhost / mytutorial 和服务器将向您显示教程的索引文件等。如果您查看此教程文件夹的绝对路径,那么它只是您的webroot的子文件夹,它本身位于您的硬盘上的某个位置,但这对您来说无关紧要localhost。

If you have a project called "mytutorial" you can enter http://localhost/mytutorial and the server will show you the index-file of your tutorial, etc. If you look at the absolute path of this tutorial folder then it's just a subfolder of your webroot, which is itself located somewhere on your harddrive, but that doesn't matter for your localhost.

所以相对路径是

http://localhost/mytutorial

,而绝对路径可能是

c:/webservices/apache/www

c:/xampp/htdocs

如果您正在使用Dreamweaver,则可以通过在项目设置中将本地服务器设置为测试服务器来简化测试过程。尝试一下!这很容易。完成后,您只需按下任何文件的浏览器图标,它就会在localhost上打开。

If you're working with Dreamweaver you can simplify the testing process by setting up your local server as a testing server in your project settings. Try it! It's easy. Once it's done, you can just press the browser icon with any of your files and it will open on localhost.

这篇关于如何在localhost上运行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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