简体   繁体   中英

How to run my html file with apache2

Maybe it is not a right channel to ask this question but I donot know where to ask.

I want to know how to run html file with apache on my ubuntu. I have written program with javascript and a html file and I want to run it via apache. I could not find htdocs folder in to copy my files there beside that I do not have permission to do that in ubuntu. My apache is installed in /usr/share/apache2. When I write http://localhost it says:

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

but I do not know where to add the contents.

any help.

The default folder that it serves the HTML files from is /var/www .

For example, /var/www/test.html would be http://localhost/test.html .

In my case where I have installed and running the Apache 2 and if I type localhost/ into the browser it opens the Apache 2 Ubuntu default Page.

Now what I did was: Suppose your HTML webpage Demo.html is located in the Website directory then copy the HTML page using one of the commands:

:~$ cp ~/Website/Demo.html /var/www/html

If this command does not work then try with the following command:

:~$ sudo cp ~/Website/Demo.html /var/www/html

And then open your browser and type this the browser search bar: localhost/Demo.html

It will open the copied Demo.html.

Also if you want to access this hosted webpage from the outside of the machine where Apache 2 is running then use it's external IP address instead of localhost as follows:

ExternalIP/Demo.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM