Page 1 of 1

Apache web server on pi

Posted: Mon Oct 07, 2019 10:12 am
by seanocaster
I have installed Apache, mqsql, PHP and wordpress on my pi4. It's all working well.

Along with ddns I am able to access the pi for SSH from outside the network.

I am also able to access motion eye camera stream from outside the network.

How to I access the Apache server? When I input the ddns address I either get an error or a sign in window (coming from motion eye I presume)

I'm guessing this problem is with port forwarding. What should my external -> internal ports be set up as?

Any suggestions?

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 10:25 am
by topguy
I am also able to access motion eye camera stream from outside the network.
Tell us how the portforwarding is set up now..

You can not forward external port 80 to two different devices in your router, so the easiest is to either move Apache or the camera to another internal ( and external ) port.

( There is probably also a way to have apache forward a request to the camera based on domain name in request, but its a bit more complicated. )

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 10:32 am
by neilgl
Probably if apache2 is running on the default port 80, then port 80 (HTTP) needs to be forwarded to the ip address of your pi and port 80.
(I usually also set a reserved ip address for the pi in the router)

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 2:15 pm
by seanocaster
Thanks for the replies.

Currently my port forwarding is:

External: 1049
Internal: 80

The ip address is 192.168.1.150. If i put this address into the browser of a computer on the LAN, i see the samples wordpress page.

However, if i go outside my local area network and put

Code: Select all

 http://<ddns address>:1049
into the address bar then just get an address not reachable error on the Chrome browser.

I've checked with the open port checker tool and if i enter port 1049 and my dynamic IP address then it tells me the port is open. Thoughts?

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 2:27 pm
by topguy
- ping your ddns name to doubelcheck that you get correct IP on dns lookup.
- Are you sure that http ( port 80 ) and not only https (port 443 ) are enabled in Apache ?
- command "netstat -lp" should list ports and processes.

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 3:18 pm
by seanocaster
Thanks, i'm feeling like port 80 is not open? Although i did check the apache.conf and it says that the listening port is port 80.

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 localhost:mysql 0.0.0.0:* LISTEN 8187/mysqld
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 462/vncserver-x11-c
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 482/sshd
tcp 0 0 0.0.0.0:8765 0.0.0.0:* LISTEN 346/python
tcp 0 0 localhost:8766 0.0.0.0:* LISTEN 28696/motion
tcp 0 0 localhost:7999 0.0.0.0:* LISTEN 28696/motion
tcp6 0 0 [::]:5900 [::]:* LISTEN 462/vncserver-x11-c
tcp6 0 0 [::]:http [::]:* LISTEN 7800/apache2
tcp6 0 0 [::]:ssh [::]:* LISTEN 482/sshd
udp 0 0 0.0.0.0:bootpc 0.0.0.0:* 411/dhcpcd
udp 0 0 0.0.0.0:mdns 0.0.0.0:* 348/avahi-daemon: r
udp 0 0 0.0.0.0:37739 0.0.0.0:* 348/avahi-daemon: r
udp6 0 0 [::]:dhcpv6-client [::]:* 411/dhcpcd
udp6 0 0 [::]:mdns [::]:* 348/avahi-daemon: r
udp6 0 0 [::]:37702 [::]:* 348/avahi-daemon: r
raw6 0 0 [::]:ipv6-icmp [::]:* 7 411/dhcpcd

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 3:23 pm
by seanocaster
In addition, if i run

Code: Select all

sudo netstat -lptn
This is what i get

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 8187/mysqld
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 462/vncserver-x11-c
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 482/sshd
tcp 0 0 0.0.0.0:8765 0.0.0.0:* LISTEN 346/python
tcp 0 0 127.0.0.1:8766 0.0.0.0:* LISTEN 28696/motion
tcp 0 0 127.0.0.1:7999 0.0.0.0:* LISTEN 28696/motion
tcp6 0 0 :::5900 :::* LISTEN 462/vncserver-x11-c
tcp6 0 0 :::80 :::* LISTEN 7800/apache2
tcp6 0 0 :::22 :::* LISTEN 482/sshd

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 6:38 pm
by topguy

Code: Select all

tcp6 0 0 [::]:http [::]:* LISTEN 7800/apache2 
It does listen, but not on IPv4 only on IPv6.

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 7:53 pm
by DougieLawson
topguy wrote:
Mon Oct 07, 2019 6:38 pm

Code: Select all

tcp6 0 0 [::]:http [::]:* LISTEN 7800/apache2 
It does listen, but not on IPv4 only on IPv6.
That's normal for all my systems running Apache2 which are all accessible with a LAN IPv4 address.

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 7:58 pm
by topguy
OP said that he see his WP site on LAN so then I guess its as to be expected, but does it matter if the request is not from LAN ?

I know Wordpress behaves a bit strange if its not configured correctly with the domain name, maybe that is the case here ??

I'm at the edge of my experience here so someone else can chime in....

Re: Apache web server on pi

Posted: Mon Oct 07, 2019 8:07 pm
by neilgl
Looks like I got confused again - are we trying to access apache2 or get to a wordpress site (that is running under apache2)?

Re: Apache web server on pi

Posted: Tue Oct 08, 2019 1:35 pm
by seanocaster
Thanks for the replies. I tried and tried but then gave up.

Just couldn't get it working - my only guess is that motion or some other process is interfering with the wordpress on port 80.

Re: Apache web server on pi

Posted: Tue Oct 08, 2019 1:52 pm
by topguy
- Then disable motion temporarily and try again.
- or reconfigure apache to use port 8080 and update the portforwarding in the router.

Re: Apache web server on pi

Posted: Tue Oct 08, 2019 10:50 pm
by Lxw2015
seanocaster,
would you share the steps of how you did to set wordpress on pi4? I just tried 2019-07-10-raspbian-buster.img
I could browse localhost on pi, but when browse from another computer in the LAN, I only see text of the page, rather than the normal page with pictures.

thanks
Xian