如何在 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 时让浏览器指向本地主机,而不必一直输入路径?
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.
谢谢
推荐答案
好的,感谢您提供更具体的信息,人们现在可以删除他们的反对票...
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).
您的网络服务器有一个根目录,即 wwwroot (IIS) 或 htdocs(apache、xampp)或其他类似 public_html、www 或 html 等的目录.这取决于您的操作系统和网络服务器.
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 的一个子文件夹,它本身位于你的硬盘驱动器的某个地方,但这对你的本地主机无关紧要.
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.
相关文章