2

I just installed apache2, php, mysql, phpmyadmin, and vftpd (to add files via filezilla) on my raspberry pi, which is used as a local web server.

I created a simple index.php page with Brackets (a php file editor). I uploaded it to the /var/www/index directory, but when I go open a web browser, the file is a white page! It seems it doesn't recognize the php file.

However php is working well, because I create this file via the terminal (Mac) to be sure php was activated : echo "<?php phpinfo(); ?>" > /var/www/index.php

enter image description here

When I add an html file it shows me that:

enter image description here

pi@192:~ $ ls -la /var/www/
total 16
drwxr-xr-x  3 pi   root 4096 nov.  29 16:56 .
drwxr-xr-x 12 root root 4096 nov.  29 15:32 ..
-rw-r--r--  1 pi   pi    126 nov.  29 16:41 essay.php
drwxr-xr-x  2 pi   root 4096 nov.  29 16:56 html

pi@192:~ $ tail /var/log/apache2/access.log
192.168.1.76 - - [29/Nov/2015:16:43:59 +0100] "GET / HTTP/1.1" 200 23783 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"
192.168.1.76 - - [29/Nov/2015:16:44:03 +0100] "GET / HTTP/1.1" 200 23783 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"
192.168.1.76 - - [29/Nov/2015:16:44:04 +0100] "GET /mysql.php HTTP/1.1" 404 505 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"
192.168.1.76 - - [29/Nov/2015:16:44:05 +0100] "GET /mysql.php HTTP/1.1" 404 506 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"
192.168.1.76 - - [29/Nov/2015:16:44:09 +0100] "GET /lol.php HTTP/1.1" 500 187 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"
192.168.1.76 - - [29/Nov/2015:16:44:10 +0100] "GET /lol.php HTTP/1.1" 500 187 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"
192.168.1.76 - - [29/Nov/2015:16:45:15 +0100] "GET / HTTP/1.1" 200 23782 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"
192.168.1.76 - - [29/Nov/2015:16:56:32 +0100] "GET / HTTP/1.1" 403 518 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"
192.168.1.76 - - [29/Nov/2015:16:56:33 +0100] "GET /index.php HTTP/1.1" 200 23788 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"
192.168.1.76 - - [29/Nov/2015:16:56:36 +0100] "GET /index.html HTTP/1.1" 403 518 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"

pi@192:~ $ ls -la /var/www/html/
total 24
drwxr-xr-x 2 pi root 4096 nov.  29 17:05 .
drwxr-xr-x 3 pi root 4096 nov.  29 17:09 ..
-rw-r--r-- 1 pi pi     20 nov.  29 16:13 index.php
-rw------- 1 pi pi     31 nov.  29 16:23 lol.php
-rw-r--r-- 1 pi pi    178 nov.  29 16:35 mysql.php
-rw------- 1 pi pi     19 nov.  29 16:20 start.php

I used this tutorial

2
  • @SteveRobillard Np. :)
    – Jacobm001
    Commented Nov 29, 2015 at 18:29
  • What is the contents of the index.php file? And do any errors show in the webserver's log (somewhere under /var/log, dunno where :)
    – Wilf
    Commented Dec 9, 2015 at 0:42

1 Answer 1

2

Based on the above you have two problems file and directory ownership and odd file permissions. to correct this do the following:

sudo chown -R pi /var/www

this will make all of the files and sub-directories of the /var/www/ directory owned by the Pi user and group. to correct the file p permissions on the index.php file do this:

chmod 644 index.php

this will give the owner (pi) read and write permissions, the members of the pi group and everyone else read permission.

You can learn more about the commands I used by typing man chmod, and man chown at the command line. This will bring up the manual page for the commands with far more detail. You may also want to read the man page for the man command (man man).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.