NOTE: This is an old article. Please go to the Meshlium development section in order to get the latest tutorials.

Howto create a PHP script

Requeriments:

  • At least one Meshlium

The usual route for PHP scripts is under /var/www directory. In this example we will create from scratch a PHP applicaction that returns ifconfig of the system.



Create the directory where our application will be located
~$ mkdir -p /var/www/my_scrips/
~$ cd /var/www/my_scripts
~$ vi ifconfig_info.php


Now we need to write the php script. We will use vi, but nano can be used too.
<?php
exec('/sbin/ifconfig',$return);
foreach($return as $line)
{
	echo $line.'<br>';
}
?>



Now change permisions so www-data can read the directory and the file
~$ chown -R www-data:www-data /var/www/my_scripts


Now if we point to the script with a web browser (http://meshlium_ip/my_scripts/ifconfig_info.php) we can get the ifconfig info.

© Libelium Comunicaciones Distribuidas S.L.

| Terms of use