views:

4615

answers:

7

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?

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?

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?

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.

Thank you

+4  A: 

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

What you are proposing is a very common thing todo! You want to run your web application locally without uploading it to your hosting yet. That's totally fine and that's what the your Apache is there fore. 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 but all in all it's just serving pages to your browser (the client).

Now your webserver 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.

Now if you type in 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).

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.

So the relative path is

http://localhost/mytutorial

while the absolute path may be

c:/webservices/apache/www

or

c:/xampp/htdocs

Now if you're working with Dreamweaver you can simplify the testing process by seting up your local server as 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.

tharkun
A: 

What do you mean by running a file on localhost? What kind of file is this? If this is a web document then you, at the minimum, need some sort of web server setup, perhaps IIS or Apache.

BobbyShaftoe
+1  A: 

Localhost is the computer you're using right now. You run things by typing commands at the command prompt and pressing Enter. If you're asking how to run things from your programming environment, then the answer depends on which environment you're using. Most languages have commands with names like system or exec for running external programs. You need to be more specific about what you're actually looking to do, and what obstacles you've encountered while trying to achieve it.

Rob Kennedy
+2  A: 

I'm not really sure what you mean, so I'll start simply:

If the file you're trying to "run" is static content, like HTML or even Javascript, you don't need to run it on "localhost"... you should just be able to open it from wherever it is on your machine in your browser.

If it is a piece of server-side code (ASP[.NET], php, whatever else, uou need to be running either a web server, or if you're using Visual Studio, start the development server for your application (F5 to debug, or CTRL+F5 to start without debugging).

If you're using a web server, you'll need to have a web site configured with the home directory set to the directory the file is in (or, just put the file in whatever home directory is configured).

If you're using Visual Studio, the file just needs to be in your project.

Daniel Schaffer
A: 

Looking at your other question I assume you are trying to run a php or asp file or something on your webserver and this is your first attempt in webdesign.

Once you have installed php correctly (which you probably did when you got XAMPP) just place whatever file you want under your localhost (/www/var/html perhaps?) and it should run. You can check this of course at localhost/file.php in your browser.

caglarozdag
A: 

i am using joomla,once time press (block image from localhost)all my picture disappear and all menu doesn't work...idon't know why please help me and tell me what can i do. please send me your answer in my mail ([email protected])

mohamed