flightisfun2001
Posts: 27
Joined: Tue Dec 29, 2015 1:10 am

RPI Web Server

Mon Feb 15, 2016 1:04 am

Hello,

I'm having trouble with my Raspberry Pi as a web server. I followed the instructions given in the Raspberry PI user guide:

Sudo apt-get update

Sudo apt-get install apache2 php5 php5-mysql mysql-server

[Enter and confirm MySQL password]

Sudo sh -c 'echo "<?php phpinfo(); ?>" >/var/www/phptest.php'

So then I tried this both on my Raspbian Jessie Raspberry PI 2 on the Netsurf Web Browser and Safari on a Mac OS X Yosemite computer:

On Mac: http://ipaddress/phptest.php (ipaddress filled with actual ip address)
Results: Random Xfinity page showing all the computers on the network.

On Raspbian: http://localhost/phptest.php
Results: Page not found.

Can any web server expert help with this?

Thanks a lot,
Nathan Jones

flightisfun2001
Posts: 27
Joined: Tue Dec 29, 2015 1:10 am

Re: RPI Web Server

Mon Feb 15, 2016 1:15 am

See previous message.
Also, I Googled my IP address on a Mac on the same network and got the same answer. Perhaps it was the router's IP address? But still, if the localhost one didn't work, that means that something isn't right, correct? :?

Heater
Posts: 15790
Joined: Tue Jul 17, 2012 3:02 pm

Re: RPI Web Server

Mon Feb 15, 2016 2:52 am

I presume you meant "sudo" not "Sudo".

Are you using Jessie on your Pi?

I think the apache server root has changed recently. On the jessie on my PC it's /var/www/html

So the command:

Code: Select all

sudo sh -c 'echo "<?php phpinfo(); ?>" >/var/www/html/phptest.php'
Gets that info page working nicely here on http://localhost/phptest.php
Memory in C++ is a leaky abstraction .

flightisfun2001
Posts: 27
Joined: Tue Dec 29, 2015 1:10 am

Re: RPI Web Server

Tue Feb 16, 2016 11:01 pm

Yes, I did mean "sudo" rather than "Sudo". I am using Jessie.

Thanks!

Heater
Posts: 15790
Joined: Tue Jul 17, 2012 3:02 pm

Re: RPI Web Server

Tue Feb 16, 2016 11:02 pm

So, did my suggestion work or not ?

Others might like to know.
Memory in C++ is a leaky abstraction .

asandford
Posts: 1998
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: RPI Web Server

Tue Feb 16, 2016 11:21 pm

What are the permissions of the folder /var/www/? What user is Apache running as? Has Apache got permission to execute (via php) /var/www/phptest.php?

Running every command as root with sudo may overcome some problems, but can create many more (much like someone I used to work with who would chmod everything as 777 as permissions 'got in the way' :roll: ).

flightisfun2001
Posts: 27
Joined: Tue Dec 29, 2015 1:10 am

Re: RPI Web Server

Thu Mar 03, 2016 2:41 am

The terminal command made it so that when I went to http://localhost/phptest.php I got this message: 403 - Forbidden. :!:

Dutch_Master
Posts: 362
Joined: Sat Jul 27, 2013 11:36 am

Re: RPI Web Server

Thu Mar 03, 2016 3:18 am

I've answered your question here: viewtopic.php?f=63&t=138410 Why did you start a new thread?

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: RPI Web Server

Thu Mar 03, 2016 8:02 am

Locking as new thread created here :
viewtopic.php?f=63&t=138410

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Return to “General discussion”