seanocaster
Posts: 10
Joined: Mon Sep 30, 2019 2:32 pm

Apache web server on pi

Mon Oct 07, 2019 10:12 am

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?

User avatar
topguy
Posts: 5934
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Apache web server on pi

Mon Oct 07, 2019 10:25 am

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. )

User avatar
neilgl
Posts: 1178
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Apache web server on pi

Mon Oct 07, 2019 10:32 am

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)

seanocaster
Posts: 10
Joined: Mon Sep 30, 2019 2:32 pm

Re: Apache web server on pi

Mon Oct 07, 2019 2:15 pm

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?

User avatar
topguy
Posts: 5934
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Apache web server on pi

Mon Oct 07, 2019 2:27 pm

- 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.

seanocaster
Posts: 10
Joined: Mon Sep 30, 2019 2:32 pm

Re: Apache web server on pi

Mon Oct 07, 2019 3:18 pm

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

seanocaster
Posts: 10
Joined: Mon Sep 30, 2019 2:32 pm

Re: Apache web server on pi

Mon Oct 07, 2019 3:23 pm

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

User avatar
topguy
Posts: 5934
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Apache web server on pi

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.

User avatar
DougieLawson
Posts: 36511
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Apache web server on pi

Mon Oct 07, 2019 7:53 pm

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
topguy
Posts: 5934
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Apache web server on pi

Mon Oct 07, 2019 7:58 pm

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....

User avatar
neilgl
Posts: 1178
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Apache web server on pi

Mon Oct 07, 2019 8:07 pm

Looks like I got confused again - are we trying to access apache2 or get to a wordpress site (that is running under apache2)?

seanocaster
Posts: 10
Joined: Mon Sep 30, 2019 2:32 pm

Re: Apache web server on pi

Tue Oct 08, 2019 1:35 pm

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.

User avatar
topguy
Posts: 5934
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Apache web server on pi

Tue Oct 08, 2019 1:52 pm

- Then disable motion temporarily and try again.
- or reconfigure apache to use port 8080 and update the portforwarding in the router.

Lxw2015
Posts: 33
Joined: Fri Feb 12, 2016 4:05 am

Re: Apache web server on pi

Tue Oct 08, 2019 10:50 pm

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

Return to “Beginners”