BREAKING NEWS

10 November 2015

Project Raspberry Pi Relays with Web Server Apache LAMP


Foreword:
This article will explain step by step procedures to follow to implement a server LAMP on debian linux distro .Basically we will see specifically to follow every instruction in the DB in php programming and html, and finally the python that trigger activation events GPIO ports through PHP. A short video description of what we're going to do.
Part Software WebRelays
In collaboration with our friend George. Part Harsware WebRelays




Hardware used:
For this automated control system will use a Raspberry Pi Type B an ethernet cable to connect to the modem, but also replaceable with wi-fi dongle for the wireless connection, an SD card to 8GB large enough to hold multiple files for development , a 5v power supply by 1000 mah (1A) and finally to the test will use a relay module to handle at least two light controls.
Software used:
As mentioned above, first we use the debian linux distro to install the microprocessor Raspberry Pi, after completing the installation of the image comninceremo installing the Apache server with the respective programming languages ​​PHP, PYTHON, HTML, MYSQL for management of the database, the graphical interface and the activation process of the GPIO ports of the board.
Guide:
REMEMBER WELL : whenever that gives you permission problems use the command:
sudo chmod 777 www if you are in the folder / var
or
sudo chmod 777 / var / www if you are in another folder
It may happen that you will need to repeat this procedure several times during installation to give permissions to all folders in the folder contanenti www . We have found using three times the procedure of inserting images from the keypad of wordpress and we headed in the c d / var / www and we used the command sudo chmod 777 wp-content to give privileges to the folder which will set out the images, and then for each entry of each new folder we used education sudo chamod 777 www for reconfirmation of pemessi.
This procedure explains step by step all the steps and links needed to complete the installation of the Server WebRelay .
Let's start with the installation of the Debian linux distro installed and once we pass the installation of putty to remotely control raspberry and WinSCP to move the files to the www server that we will create.
First download putty and Windisk (including IMG) and create the image of the distro to put it on the Raspberry Pi.Once downloaded and installed the operating system, we pass to the installation of a very useful application which acts as FTP and called WinSCP .
Download WinSCP:
Then we download the template based on wordpress:
once you click on the download site to perform the download process.
BEFORE THE INSTALLATION:
We open Putty that will allow us to connect remotely with the Raspberry Pi. Let's go on the router to find the IP address of the rasp and insert it in the program Putty eg. "192.168.1.xx" and as credeziali username "pi" and password "raspberry". If all goes well you will manage to end the microprocessor.
Installation command line:
the first command to be made to allow installation and whatever else is education:
sudo apt-get update
Then press y to confirm it. 
Then we install the main components to give life to the Apache Web Server:
sudo apt-get install apache2 
sudo apt-get install php5 
sudo apt-get install mysql-server mysql-client php5-mysql
As always repeat "y" to confirm it. The last instruction to install MySQL you will see a page where you will enter the credentials of the database for the Convention must enter username and password as the word "root" and keep pressing "y" and "OK." 
After the first installation process if everything goes well you found Apache Startato so we can get our "hands" in the folder of the Web server / var / www / and give life to our pages.
Now another key step that allows you to give privileges to the user Pi to run python code php and all languages ​​concerned:
sudo visudo
dovemo find a file with the file contents and the last line we will have to enter this:
pi ALL = (ALL) NOPASSWD: ALL 
apache ALL = (ALL) NOPASSWD: ALL 
ALL = www-data PYTHON, NOPASSWD: ALL
usually after installing the server already you found the first two statements should be so included only the last.
INSTALLATION WITH WinSCP FTP TEMPLATE BASIC WP:
Now we will use the program WinSCP downloaded a few minutes ago to move the base wordpress template in the / var / www of the Raspberry Pi.
While you open winscp head to the file you just downloaded:
Unzip it and you will find a folder on the PC you open that folder and inside you will see many files. These files will be racked in Raspberry.
Once you open the program is very similar to Putty will ask you to enter the IP address and credentials of their Raspberry Pi that are the same as in the case of Putty. To the left of the program there will be folders PC and go into that folder just mentioned where there is your wordpress open it and drag all the files into the right side where you should head in the / var / www / and so you will have copied all the wordpress theme.
Open the archive file WebRelays.zip where inside there are some folders with files. Copy the folder on your desktop Wilson.1.17 in wilson rename the folder and inside there will be the contents of the template that will use WinSCP to copy it and then reuse in Raspberry path this time in / var / www / wp-content / themes.
After the process of copying and pasting the file server comes the somewhat critical installation.
PART INSTALLATION:
If you have copied all the files in Raspberry well you can go to the procedure for viewing content. Open the browser and in the URL bar enter the IP address of your Raspberry and press enter, the load should be the initial setup of WordPress with its name credentials and creating and connecting to the data base.
IMPORTANT NOTE: MYSQL CONTROLS AND PRIVILEGES BEFORE DELL'INSTALLAZION WP
It 'very imporatante this section because usually you are having various problems such as errors CONNECTION database or can not copy because of permission problems linux or whatever else. It 'very difficult to give an answer with certainty when a guide who does not have before the problem arises but in this section will give you the basics to solve the most common problems that occur in the installation.
We also install:
sudo apt-get install phpmyadmin
Normally this instruction depends on the distro but in almost all cases the installation is successful the usual press "y" to the end and as in mysql will ask the credentials you specify always root as username and password.
Then from Winscp copied in / var / www / is also a file that is located inside the zip file that will send email calledphpminiadmin.php which is a customized version of critics to write instructions in the DB.
Open another browser tab with the IP address of the rasp and the file has been uploaded in this way will appear a login for the DB and if you entered everything in correctly entering password and username with the word root will have access in the editor DB for the inclusion of instructions to populate the DB.
eg. 192.168.1.xx / phpminiadmin.php
CREATE DATABASE NAME TO INCLUDE THE INSTALLATION OF WORDPRESS:
As explained before a time you find the SQL editor we will create the DB name to contain the tables and fields for operation of wordpress. Then in the box to write let's include this statement.
CREATE DATABASE WebRelays;
If the entry has been successful in the box will be a written Done to confirm that has finished loading in the DB.
Subsequently re-open the browser tab where we had left open the installation process and now we are ready to enter all fields that require site name etc. etc.
NOTE: We will also request access to the data base you enter the address or host also said the word "localhost"then will ask the name of the DATA BASE and enter "WebRelays" check case sensitive and very sensitive to the characters and finally the username and password are "root" . Take back and finally begin to install the stuff. After installation, you should see the base template, if not visible refreshate page.
THIRD PART OF THE INSTALLATION:
We are in the final phase of the installation we say that the "bulk" has passed. At this stage and for those who do not know wordpress you just adjust the template as the installation we have added one of our own who was wilson panel must activate it. How do you do this?
Always go to your browser and enter your 192.168.1.xx / wp-admin will have access to the system control panel of your website now enter the password you entered in the installation of Wp as
Note: nothing to do with the root password. This is the password in the configuration of the name of the website of wordpress.
Once you logged customized theme and put wilson  and created three pages as to indicate:
  • Product Info
  • how to use WR
  • Web Relays APP
Manage your pages and insert content to your liking with a few images and other illustrative demonstration.
THE FINAL PROJECT:
Now we come to the end first we consider that at this stage we will proceed with two simple steps usingphpminiadmin.php to enter into db other instructions to populate the management gpio and then uploading other files with WinSCP.
So the first thing we go on WinSCP and copy the folder app we downloaded the file WebRelays.zip with all of its contents in the folder / var / www . After copying all we have to go in phpminiadmin.php as always by browsers and write if you have closed:
192.168.1.xx / phpminiadmin.php
credentials root root
and in the space editor include this new education it takes to create our own structure.
TABLE statement to create:
with this function we will create in our DB WebRelays table gpio with fields gpio and value.
NOTE: remember to put themselves under the DB WebRelays top editor you can select the database in question.CREATE TABLE gpio ( gpio VARCHAR (100), value VARCHAR (100) ); Now we just have to enter the values ​​in the table indicating the number of gpio and the port value if high or low indicated by "checked" or "" (two quotation marks indicates a blank space).




DATA ENTRY IN TABLE:
INSERT INTO gpio (gpio, value) 
VALUES ('8', ');
This statement the esguiremo for 3 times by changing the values ​​of gpio.
INSERT INTO gpio (gpio, value) 
VALUES ('7', ');
INSERT INTO gpio (gpio, value) 
VALUES ('25', ');
In this way, with these three settings we can use the LIGHTS MANAGEMENT of OpenHome . Finally we go back to:
192.168.1.xx / wp-admin from browser and there dirgiamo editor wp Relays APP Web page that we created here by the editor will insert a frame that will allow us to view the contents of pulsantistica created.
<Iframe src = "/ app / index.php" height = "500"> </ iframe>
WordpressWebRelays
If you followed all the steps correctly you can now view the contents of the page 192.168.1.xx properly and you can already handle all the management lights. From here on, you have to add only some SQL statements to enter new doors gpio and some files with WinSCP for improvements.

Share this:

Post a Comment

 
Back To Top
Distributed By Blogger Templates | Designed By OddThemes