• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Raspberry Pi 3 & Web Server

ronsimpson

Well-Known Member
Most Helpful Member
Thread starter #1
I am trying to replace my home control computer with a Raspberry Pi.
The 16 to 18 year old computer has internet connections so I need the Pi to also have a web server functions.
http://readwrite.com/2014/06/27/raspberry-pi-web-server-website-hosting/
Went to the above link:
Installed Apache:
All very easy.
Problem is I can't get to the Pi from any PC running FireFox or Internet Explorer.
I can see the Pi from any Android running Chrome.

So it is some what working.
More when I get this problem solved.
--edited--
https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
 
Last edited:

ronsimpson

Well-Known Member
Most Helpful Member
Thread starter #2
More:
Just found out that the web server dose not work when the screen saver is on. LOL That is probably easy to fix.

Also:
A PC can 'ping' the raspberry at 127.0.0.1 but not at 192.168.123.15.
A PC finds nothing at 192.168.123.15 but a Android finds a web page.
I have a feeling I need to know more about networks.
 

dougy83

Well-Known Member
#3
A PC can 'ping' the raspberry at 127.0.0.1 but not at 192.168.123.15.
A PC finds nothing at 192.168.123.15 but a Android finds a web page.
I have a feeling I need to know more about networks.
How can a PC ping the Pi at 127.0.0.1? The PC would be pinging itself ;).
Have you tried http://192.168.123.15 as well as https://192.168.123.15? Or 192.168.123.15:80, 192.168.123.15:8080, 192.168.123.15:443?
 

ronsimpson

Well-Known Member
Most Helpful Member
Thread starter #4
When I ask the Raspberry its address it said: (sudo hostname -a)
127.0.0.1
192.168.123.255
192.168.123.15
I did not under stand 127.0.0.1 thank you.
http://http//192.168.123.15 (with or with out a port number :80 or :8080 or 43)
Not Found
The requested URL /192.168.123.15 was not found on this server.
Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny16 with Suhosin-Patch Server at http Port 81
With out the "http://" I get:
The connection has timed out

The server at 192.168.123.15 is taking too long to respond.

The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
----edited----
From a Android; I get a ping back:
192.168.123.15-WORKGROUP/RASPBERRYPI-0 b8:27:eb:27:f9:e0
Using a program called ¨Ping & DNS
----edited----
On the Raspberry Pi in a terminal window "sudo ping 192.168.123.10 -c 10"
This pinged my PC.
On the PC ping 192.168.123.15
This pinged my Pi.
Now from the PC I can see the web page on the Pi.
I do not know why but pinging from the Pi to the PC started it working.
 
Last edited:

dougy83

Well-Known Member
#5
Sorry, I'm not sure what the problem is. By "Android", are you meaning mobile devices connecting to your router via wifi?

What is the IP of your PC? 192.168.1.xxx? If so, try changing the IP of the pi to 192.168.1.yyy, so that they're on the same subnet (assumed mask of 255.255.255.0).
 

ronsimpson

Well-Known Member
Most Helpful Member
Thread starter #6
I have the router handing out addresses. It assigned the PC at 192.168.123.10 and the Pi at 192.168.123.15.
For some reason, every time the Pi is reset or goes into screen saver, I have to ping from the Pi to get a connection again.

By Android I am using phones and tablet. All the Androids are addressed in the 192.168.123.1 through .20 range.
---more---
I have to ping each PC before I can make a connection to that PC.
 
Last edited:

large_ghostman

Well-Known Member
Most Helpful Member
#7
You can set a static address to the PI, I have only used the PI2 though. I would seriously recommend putting the main OS on the sd card and using a USB stick as 'main drive', I got through loads of sd cards on my pi.

What linux you using on the PI? I got a load of notes on the pi somewhere, I found alot of useless info on the pi and brought a ton of useless books! But slowly built up a reasonable file on them, not sure how dissimilar the Pi3 is to the pi2. it should be easy to turn the screen off, I run the pi headless or normally using something like VNC.
 

large_ghostman

Well-Known Member
Most Helpful Member
#8
127.0.0.1 is the same thing as 'local host' its just the ip address of the machine you are using. You need to find out what port the apache server running from and make sure that the router is port forwarded for that port. OR change the port of the apache server to one that is open.

Also sounds like the pi is trying to set the Ip addresses as well, I tether to the internet via android as we cant get broad band in my area. I get all kinds of network issues with tethering, I have to make sure that only one device is handing out the IP's, in your case I think you have both the router and pi trying to set addresses.
 

large_ghostman

Well-Known Member
Most Helpful Member
#9
Are you running the pi wireless? If so there is a known problem with reconnection, its in one of the books I sent you a pm about. There is several scripts to get around it and a fix offered in the book, I think it applies to wireless systems only. the book says the following........

"The allow-hotplug command will do as the name suggests; it allows you to plug in
and out wireless adapters assigned to the wlan0 interface. Auto wlan0 tells Raspbian
to confgure the interface automatically based on the settings you provide.
We need to replace the SSID and password with the details of your router, keeping
the text enclosed with quotation marks. This is the most basic confguration that
can be used.
There is one problem with this confguration though; if the wireless network is
disconnected, the interface will not be brought back automatically. There are many
scripts that try to solve this problem. The confguration requires that you know extra
details about the wireless confguration. The next section offers a fully automatic
way of doing this though. "


It then gives alot of information on how to configure things to get around these problems.
 

large_ghostman

Well-Known Member
Most Helpful Member
#10
Ron I am having mares sending the books!! let me know when your ready, i will try and stuff them on a google drive thingy. But I cant keep then on long as I use the space.
 
#11
Hi if I understood it correctly , you need to set up your pi as a server, by server I mean you have to give it a static IP so you can know which IP to connect to and you will probably need to set up a bunch of other settings in the router and in the pi to make it work.
It all depends on which OS you have in your pi.
 

alec_t

Well-Known Member
Most Helpful Member
#12
saxa
You are posting to old threads. The thread starters have probably moved on.
 

DerStrom8

Super Moderator
Most Helpful Member
#14
saxa
You are posting to old threads. The thread starters have probably moved on.
Ron is still around, but I agree, this is an old thread and the original question may no longer be applicable.
 

ronsimpson

Well-Known Member
Most Helpful Member
Thread starter #18
just let me know if you have any issues and I will try to help out.
I need some help getting started. or making a plan.

This is what I have working now. Also see "page 2"
http://gradllc.com/internet.HTM
Page 2 is a simple text version where in HTML there are simple windows where the server and the client can read or write and the other can see the changes.
In Page 1 the "data" is tied to files. 1="red_LED_ON.jpg" or 0="red_LED_OFF.jpg".
This is what I got going 20 years ago when my head was better.

What I found on the Pi is this: https://www.raspberrypistarterkits.com/projects/raspberry-pi-home-automation/
It appears that you make buttons that call out Python scrips.
button_1 call out "IO_pin3=1.py"
button_2 calls out "IO_pin3=0.py"
This is simply a one way human drive IO pins.

The one piece I just can't do is make a window where the Pi can talk to a human via the network. I think there is a way. On the Pi there is a HTML file with windows. Python or C can write into the windows and a human with a phone or a computer can read the windows. "Time=4:23" "Temperature= 24C" "water zone 4 = 23 minutes" (update every minute)
 

be80be

Well-Known Member
#19
You start with the router
You set a fixed IP for the the PI you then set the router to let the PI be a web server you can give it a name.
The router handles the name server most can do that

Then you set the PI up with the name and IP your setup on the router
You set Apache up to the same.
You add what you need to Apache and then to start the road to coding the stuff you need mutt php database
https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md

You can do anything you like once you get the hang of it
mutt is a powerful thing I really look at it

Here something to play with
 

Attachments

Last edited:
#20
I need some help getting started. or making a plan.

This is what I have working now. Also see "page 2"
http://gradllc.com/internet.HTM
Page 2 is a simple text version where in HTML there are simple windows where the server and the client can read or write and the other can see the changes.
In Page 1 the "data" is tied to files. 1="red_LED_ON.jpg" or 0="red_LED_OFF.jpg".
This is what I got going 20 years ago when my head was better.
Nice one :)

What I found on the Pi is this: https://www.raspberrypistarterkits.com/projects/raspberry-pi-home-automation/
It appears that you make buttons that call out Python scrips.
button_1 call out "IO_pin3=1.py"
button_2 calls out "IO_pin3=0.py"
This is simply a one way human drive IO pins.
Yes it is not a big deal make a html page which calls the python or any other script, you can use CGI interface, etc....

The one piece I just can't do is make a window where the Pi can talk to a human via the network. I think there is a way. On the Pi there is a HTML file with windows. Python or C can write into the windows and a human with a phone or a computer can read the windows. "Time=4:23" "Temperature= 24C" "water zone 4 = 23 minutes" (update every minute)
If I get you right here, you need to set up your Pi as a server, then when you connect to your Pi the correct web page will show up and eventually logging in you will have access to the controls which will call the python scripts.
You have to set up your RPi with a fixed IP address , to do that you have to tell what OS are you running on that RPi.
After you set up the fixed IP you then make sure your apache server is configured to serve the correct location.
Then you put on those html or php pages which will make you show up the interface you need for controlling your house.
 

Latest threads

EE World Online Articles

Loading

 
Top