Adding PHP to your vera http server.

[i]French up to date version of this tutorial : TouteLaDomotique.com : la maison connectée au meilleur prix

Hi all,
I write this tutorial that explains how to install PHP on the vera’s webserver.
So you can install your php website (like control interfaces) directly on your vera (such as the excellent MyVera).

WARNING
This tutorial (unlike the usual tutorial) requires to add and edit files directly inside the vera. There is nothing complicated if you follow this tutorial.
But I must warn you that these things can cause a “crash” of your vera and neither micasaverde and I can be held responsible for this.

INFO:
This is a specially compiled version of PHP for vera and reduced to a minimum to reduce the memory footprint flash and ram.
So there is a lot of features that are missing such as mysql functions. In contrast curl, json and GD support is present :wink:
Another point for those familiar with PHP: PHP errors do not appartront and cause a 500 error (Internal server error). To see the php error that triggered this, we must look at the lighttpd log in “/var/log.lighttpd_error”

PREREQUISITE:

Step 1: Copy Package

  • Copy the file “php4vera-xxxxxx.tgz” in the “/tmp” vera’s folder with your winscp software (SCP protocol).

STEP 2: Installing Package

  • open a terminal using ssh and run the following commands:
cd /tmp
tar xvzf php4vera-20120108.tgz
cd /tmp/php4vera-20120108/
cp -R * /
cd /usr/lib/
ln -s libcurl.so.4.3.0 libcurl.so.4

Step 3: Configuring lighttpd web server

  • Edit the file “/etc/lighttpd.conf” (either directly ssh with “vi” or you can download it with winscp, make your changes and send it back to your vera).
  • At the beginning of the file, remove the “#” in front of them: “mod_alias” and “mod_fastcgi”.
  • At the very end of the file add:
fastcgi.server = ( ".php" => (( 
"bin-path" => "/usr/bin/php-cgi", 
"socket" => "/tmp/php.socket" 
))) 

Step 4: Test that everything works

  • Restart the web server:
pkill -9 lighttpd
lighttpd -f /etc/lighttpd.conf

If there is no message that appears is that the server is restarted. To test that PHP works well, open your browser and enter: http:///phpinfo.php
You should see the status page of PHP.

Voila, you have PHP installed on your vera webserver :slight_smile:

Do not hesitate to send me your feedback here.

Update with a new PHP version that handle graphics manipulation library (called GD).

Just curious are you a year out of whack in you file naming convention? *20120108 :wink: Another year has gone!

Oups! You’re right! :o
This is because I wont grow old ;D
I’ll fix it on the next release.

For me the command “pkill -9 lighttpd” didn’t work to kill the server, I used “killall lighttpd” instead.

Thank you very much for the detailed tutorial!

I’m trying to install this and my vera seems to hang at the following point

root@MiOS_16029:~# cd /tmp
root@MiOS_16029:/tmp# tar xvzf php4vera-20120108.tgz
php4vera-20120108/
php4vera-20120108/etc/
php4vera-20120108/etc/php.ini
php4vera-20120108/www/
php4vera-20120108/www/phpinfo.php
php4vera-20120108/usr/
php4vera-20120108/usr/bin/
php4vera-20120108/usr/bin/php-cgi
php4vera-20120108/usr/lib/
php4vera-20120108/usr/lib/libfreetype.so.6
php4vera-20120108/usr/lib/libpng15.so.15
php4vera-20120108/usr/lib/libcurl.so.4.3.0
php4vera-20120108/usr/lib/libjpeg.so.8
php4vera-20120108/usr/lib/lighttpd/
php4vera-20120108/usr/lib/lighttpd/mod_fastcgi.so
php4vera-20120108/usr/lib/lighttpd/mod_alias.so
root@MiOS_16029:/tmp# cd /tmp/php4vera-20120108/
root@MiOS_16029:/tmp/php4vera-20120108# cp -R * /

root@MiOS_16029:/tmp/php4vera-20120108# cd /usr/lib/
root@MiOS_16029:/usr/lib# ln -s libcurl.so.4.3.0 libcurl.so.4
root@MiOS_16029:/usr/lib#

at this point putty becomes extremely slow key presses take 30 seconds or more to register i cannot login with winscp it just times out the connection attempt.

am i doing something wrong? ???

installing on vera2 BTW

Everything seems good and at this point PHP is installed but not activated. You should not have any problem.
What the “df -h” command says ?

I’m not sure what you mean with the “gf -h” command. I am not very savvy when is comes to this. I had to try installing several times and the vera would become unresponsive after the “tar xvzf php4vera-20120108.tgz” command (no SSH, winscp, or ui5) and had to unplug the vera. I would let it sit for over 30 minutes just to make sure it would not come back. The log i posted above was the only time I could get that far.

After the reboot I checked that the files were in the proper places according with the log, but after modifying the lighttpd.conf (winscp method) i would loose any access to the UI5 interface and going to the phpinfo.php would fail to connect with the server. If i replace the lighttpd.conf with the original every thing comes back in UI5.

Am viewing this as a learning experience since I don’t have hardly any experience with SSH or linux commands.

thank you for all the help.

hre is what comes up after the fd -h command

root@MiOS_16029:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 6.3M 6.3M 0 100% /rom tmpfs 14.9M 5.8M 9.1M 39% /tmp /dev/mtdblock/4 8.9M 7.2M 1.7M 81% /overlay mini_fo:/overlay 6.3M 6.3M 0 100% / /dev/loop/0 4.6M 4.6M 0 100% /mios

Edit: It seems that if i remove the # from the “mod_alias” or “mod_fastcgi” causes instant loss of the UI5 I can still SSH and Winscp in to the vera to revert the changes ang can use the vera again.

I also noticed that there is a lighttpd.conf file in the “ect/tighttpd” folder do i need to make these changes there instead of the one inside the “ect/” folder?

Maybe the vera2 has less ram memory than the vera light and the “/tmp” is a ramfs. So when it will become full, the vera free ram memory will be null and will crash (or going reaalllyyyyy slloooowwww).
The “df -h” command will tell you how disk space you have and the “free” command will tell you how free memory you have.
You can find a tips to copying files one by one and putting them in the right place on your vera.
An other solution is to plug an USB key to your vera and copy files on it.

Vera 2 (32MB) has half the memory of the Vera Lite (64MB). I believe it also has half the flash space as well.

  • Garrett

here is what it says wen the free command is entered

root@MiOS_16029:~# free
              total         used         free       shared      buffers
  Mem:        30540        29104         1436            0          600
 Swap:            0            0            0
Total:        30540        29104         1436
root@MiOS_16029:~#

if you look at the edit i made to post #8 any changes to the lighttpd.conf causes the crash.

but am i just unable to run php do to the lack of space on the vera2?

Your Vera interface crahes because all files needed for pho are not installed.
If you have no free space the only solution you have is to put them on an USB key plugged in your Vera. (or to buy the Vera light)

[quote=“psykokwak, post:13, topic:173836”]Your Vera interface crahes because all files needed for pho are not installed.
If you have no free space the only solution you have is to put them on an USB key plugged in your Vera. (or to buy the Vera light)[/quote]

that makes sence.

I dont supose there is a guide on how to get this running on a usb? (sigh) I’m more of a hardware guy than a programmer.

I also need this help. In the directions above, what do you change or where do you place the files to get them on USB drive? I have two USB drives attached to Vera2 for Datamine and for Log/Swapfile (although, after looking at the df -h output, I’m now wondering if Vera put the log files on the Datamine USB drive instead of the newer drive that I attached).

/root$ df -h Filesystem Size Used Available Use% Mounted on /dev/root 6.3M 6.3M 0 100% /rom tmpfs 14.9M 332.0K 14.6M 2% /tmp /dev/mtdblock/4 8.9M 8.8M 60.0K 99% /overlay mini_fo:/overlay 6.3M 6.3M 0 100% / /dev/scsi/host0/bus0/target0/lun0/part1 503.9M 21.7M 456.6M 5% /tmp/log/cmh /dev/loop/0 4.8M 4.8M 0 100% /mios /dev/scsi/host0/bus0/target0/lun0/part1 503.9M 21.7M 456.6M 5% /dataMine

Hi,

Old Post about getting PHP4 running on a Vera, I would like to know if anybody did that on the new VeraPlus?

Thanks.