after I searched for hours for a solution, I now turn directly to the forum.
I try using the Arduino Yun to build a PHP webserver.
As described in Yun-Playground, I have installed PHP using SSH.
As I found out now, I have to change the uhttpd-file, that the Yun recognizes the ".php" files.
But how should this be done?
How can I get access to this file, and what do I need to change?
Do I need to make further changes so that my PHP server works?
Now I have another question.
If i access my Yun via the IP, the Configuration Page is loaded. Is there an possibility to change this value, so that my Yun forward me to the sd dictionary and not to the configuration page?
clear browser cache (at Firefox Clear All History), reload page.
The phpinfo has following error:
Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /www/phpinfo.php on line 4
Thanks, that solved it. But after following your instructions I still get:
404: Not Found!
MIME-TYPE not known
When accessing from the browser (both chrome and firefox)
EDIT: I should probably give a quick explanation of what I'm trying to do... I'm using mjpg-streamer to start streaming on boot on port 8081. I can access it outside the local network but so can everyone with internet. To make it more secure I made a .html life to input login credentials and a .php file to check those credentials and allow or deny access to the stream. Something like:
Hasr:
... EDIT: I should probably give a quick explanation of what I'm trying to do... I'm using mjpg-streamer to start streaming on boot on port 8081. I can access it outside the local network but so can everyone with internet. ...
Smart move!
Setup mjpg-streamer with password authentication for Yun:
Followed your instructions on that thread but the stream.html isnt asking me for a password when I access it internally or externally network-wise. Do I need to change anything else?
Didn't know if I should reply here or in the other thread xD
Oh and for curiosity sake, what can I be missing to get the .php files working? Never know when I might need to make it work EDIT: Ok, the phpinfo.php file is working fine! But the /www/webcam/test.php file isn't... Any idea why? I'm confused with this. 2EDIT: The test.php file works fine in the /www/ folder. Problem is, I can't (more like I don't know) how to make the stream wacthable in that folder... In /www/webcam/ folder I can watch the stream but in the /www/ folder I can't. Any way to work around this?
Tried this but no luck:
I'm having trouble with sonnyyu's instructions. Using PuTTY, PHP seems to install just fine and that line previously mentioned is already commented out as it should be. However "phpinfo.php" does not exist in that directory. I followed all the instructions, so I'm confused why the file isn't there. Obviously, I can't navigate to it with the browser either. I've played around with this for a while. Any suggestions on what I might be doing wrong or on how to get feedback as to what is going on?
sonnyyu:
nano /www/phpinfo.php
....
Using browser http://arduinoip_address/phpinfo.php to confirm php is installed.
I tried adding the phpinfo.php file in the /www directory with the code you posted 3 different ways (although, I'm probably misunderstanding what you were telling me to do).
xcfreek58:
I tried adding the phpinfo.php file in the /www directory with the code you posted 3 different ways (although, I'm probably misunderstanding what you were telling me to do).
echo "<?php phpinfo(); ?>" > /www/phpinfo.php
This is a command you enter at the Linux command line. It echos the string "<?php phpinfo(); ?>" to the file /www/phpinfo.php, essentially creating that file named phpinfo.php in the /www folder, with a PHP script that calls phpinfo(). This is the easiest way to create a simple file without needing an editor application.
echo "<?php phpinfo(); ?>" >
What do expect this to do? I can't make sense of it in any context.
<?php phpinfo(); ?>
This is the actual PHP code to call the phpinfo() function. This is what you would enter into /www/phpinfo.php, if you were to create/edit the file directly using a text editor application. This command is only useful as the contents of a PHP file, it has no meaning if you type it at the Linux command prompt.
ShapeShifter:
This is a command you enter at the Linux command line. It echos the string "<?php phpinfo(); ?>" to the file /www/phpinfo.php, essentially creating that file named phpinfo.php in the /www folder, with a PHP script that calls phpinfo(). This is the easiest way to create a simple file without needing an editor application.
So I used this command at the Linux command line (via Putty) to create that file in that directory. I also ran all the php install commands again just to ensure that PHP was installed
Package php5 (5.4.5-3) installed in root is up to date.
Package php5-cgi (5.4.5-3) installed in root is up to date.
Package nano (2.2.6-1) installed in root is up to date.
So I would think that I could create an HTML file like this one and it would display the line that is being echoed in the PHP:
<!doctype html>
<html>
<head>
</head>
<body>
<h1>My First PHP Page</h1>
<?php
echo "xcfreek58 is awesome with PHP";
?>
</body>
</html>
I would expect "xcfreek58 is awesome with PHP" to show up below "My First PHP Page", but it doesn't. For some reason only "My First PHP Page" is there.
What did you name the file? You call it an HTML file, not a PHP file. If you have the extension .html or .htm, then the web server will serve it up like a static html file. The PHP code will be sent through the the web browser, which won't understand it, and will simply ignore it.
If you have the extension .php on the file, then the web server on the Yun knows it's a PHP file that needs to be processed before serving up the file. It will be sent through the PHP processor, which will recognize the PHP code in the file, and perform the code, substituting any output for the PHP code. The page served up to the web browser will actually have the entire block of PHP code removed, and it will appear as if the "awesome" text was always in the file.
If your HTML file has any extension other than .php, that is your problem. If it has a .php extension, then you probably have a configuration problem. You say you created the phpinfo.php file, but you don't say what happened when you ran it? If it didn't work, don't bother trying anything else until it does. If it did work, and your HTML file has a .php extension, then you have a strange situation...
What did you name the file? You call it an HTML file, not a PHP file. If you have the extension .html or .htm, then the web server will serve it up like a static html file. The PHP code will be sent through the the web browser, which won't understand it, and will simply ignore it.
If you have the extension .php on the file, then the web server on the Yun knows it's a PHP file that needs to be processed before serving up the file. It will be sent through the PHP processor, which will recognize the PHP code in the file, and perform the code, substituting any output for the PHP code. The page served up to the web browser will actually have the entire block of PHP code removed, and it will appear as if the "awesome" text was always in the file.
If your HTML file has any extension other than .php, that is your problem. If it has a .php extension, then you probably have a configuration problem. You say you created the phpinfo.php file, but you don't say what happened when you ran it? If it didn't work, don't bother trying anything else until it does. If it did work, and your HTML file has a .php extension, then you have a strange situation...
I did have it named as index.html, but it doesn't work when I name it index.php because whenever I load the file, it is automatically downloaded by my browser to my Downloads folder and not rendered. Does that mean that I don't have PHP installed correctly? I believe that I followed all the steps above that sonnyyu reposted.
I'm using an SD card in my Yun. Could that make any difference as to whether the PHP processor will process the file?