How would I broadcast a http website over WiFi?
Solution 1
The website is listening on a port, usually 80, on you laptop. Assuming you can connect to "localhost" with a browser (on the laptop) and connect to the website, then all is well.
Your laptop has an ip address, such as 192.168.0.100
for example. You should be able to use that address instead of localhost on your laptop, and you should also be able to use that same address from any computer on your LAN; ie, http://192.168.0.100
, or whatever the actual address is. For other computers that run linux, windows, or OSX, you can enter an alias in the hosts files so you can type a name, instead of the numbers, such as http://laptop
.
If you want to connect from both inside and outside your LAN, you can use a dynamic IP address service that can direct requests to the website.
You can actually have multiple virtual websites running on the laptop either way. I use dyndns, for which I pay a small amount each year. I can access my server by using something like http://myname.homelinux.net
, or many other URLs.
Solution 2
Have you bound your httpd/apache2 to the correct IP address for your WiFi connection? I know on my computer it defaults to my ethernet card and I must manually bind it to the IP address for my WiFi card.
Make sure you've added Listen 192.168.X.X:80
to your apache2.conf or httpd.conf file using whatever the IP address for your WiFi card is. Older versions of Apache on Ubuntu will use httpd.conf, newer use apache2.conf which is located in /etc/apache2
.
Check here: http://httpd.apache.org/docs/2.2/bind.html
or here: https://help.ubuntu.com/14.04/serverguide/httpd.html for more information.
If you want to do this without being connected to another wireless access point or router, you can probably use hostapd to set a static wireless access point on your WiFi interface, still pointing apache2.conf to that IP address.
As far as how to "host the page," take a look at your apache2.conf file about a third of the way down you'll see a line that's commented out with #. It should look like #ServerRoot "/etc/apache2"
This is how you'll point apache to the folder for the root of the site. You should probably have a look at the second link I posted, it'll give you a better idea of how to set up what you want, and be much more informative than me rewriting what they have posted there. There are many ways to set up a properly working site, depending on what you are planning on serving. Essentially, you could drop your 'index.html' file in the /var/www/html
directory, uncomment the line and it will work. But you then need to symlink to the media files you want to serve or move them to the /var/www/html
directory in the same manner in which you're referencing them in your html files.
Once you edit the apache2.conf file, run: sudo apache2ctl graceful
from the command line to restart apache with your new settings.
user3351262
Updated on September 18, 2022Comments
-
user3351262 over 1 year
I am trying to braodcast a http website over wifi using my laptop to enable my smartphone to connect to this website just by using wifi connection and a web browser. The goal is to create my private network so I can brodcast websites containing media that I can access using my smartphone with no configuration or app and of course without any need for an internet connection for both the smartphone and laptop.
Does anyone have an idea?
And Thanks.
-
user3351262 over 9 yearsis there any configuration needed in the server? And can I do this using ubuntu desktop or do I need ubuntu server?
-
hatterman over 9 yearsThis can be done on both desktop or server. I presume you have your web page(s) up and running ? Or are you also asking how to host a web page, not just access it on a private LAN ?
-
user3351262 over 9 yearsI have have prepared the web page but it is not hosted yet, If you don't mind would you explain to me how to host a web page and Thanks.
-
hatterman over 9 yearsIm not big on hosting web pages, but I suggest you install apache and configure that to host your site(s). Do a search on here for apache server. Good luck.
-
Admin over 5 yearsWelcome to Ask Ubuntu; please edit your answer and provide more details.