-
Notifications
You must be signed in to change notification settings - Fork 2
Installation
As our project involved Mysql, Php, web-server, there are several commands to set up the working environment as follows:
-
Checking the raspberry pi system is up to date.
sudo apt-get update
sudo apt-get upgrade
-
Installing apache2, php, mysql supports
sudo apt-get install apache2 -y
sudo apt-get install php7.0
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get default-libmysqlclient-dev
After installing supports for the environment, database and relevant table should be created in order to read and write data.
If you would like to create a specific login account rather than using the 'root', you can simply go through the following commands:
-
Creating a new user named as 'pi'
sudo mysql -u root for entering mysql database.
mysql> USE mysql;
mysql> CREATE USER 'pi'@'localhost' IDENTIFIED BY '';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'pi'@'localhost';
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='pi';
mysql> FLUSH PRIVILEGES;
mysql> exit;
service mysql restart
-
creating a database for raspberry pi
mysql>create database sensor;
mysql>use sensor;
mysql>create table th_sensor(name char(20) not null primary key,value float(10,2) not null, value2 float(10,2);
mysql>exit;
-
Now you can copy /Code/html folder to the default localhost directory as /var/www/html.
-
Creating a boot script for launch the system once the pi opened.
-
For example, creating a file named as boot.desktop under the directionary: .config/autostart/
-
The content of the file as follows:
[Desktop Entry]
Type=Application
Name=testboot
NoDisplay=true
Exec=/var/www/html/ ./main
-
Finally, after reboot your pi, you can open your web browser to see the interface.