Thank you everyone (@epoch1970 , @pflecth101 , @fbe - other thread)
For the help over the last couple days..(and the help in my 2 threads)
I have now successfully:
* Installed Raspbian (Stretch) onto my RPi3
* Installed Apache
* Installed MySQL
* Installed PHP
* Installed PhpMyAdmin
All working correctly.
I have written a quick web page (form) that is dynamically created by the database/tables I set-up and populated for the drink recipes and available drink ingredients, that sends out its 'recipe' details once the form is submitted via PHP to a connected Arduino. (which moves the stepper/servo around and physically creates the drink)..
I was previously running the above from a PC & WAMP.. and a connected Arduino via USB...
* I was told/read that you can NOT have 2-way serial communication using PHP on a Windows based machine.. but its not a problem on a Linux/Mac/Raspbian based OS
With your help.. I have now set up a platform where I have ported over the site and it is now loading when I call the RPi's IP in my browser on my PC..(or in Chromium locally)
To-Do-List:
-------------------------------------
* Load this default webpage upon boot
* Load the above webpage in FULLSCREEN (Kiosk mode?)
** Now that I am testing on Rasbian OS.. I need to search on how to connect my Arduino to my RPi.. so that the PHP script can send out serial data to it.
*** If anyone has any links on the topics above it is appreciated
As for closure to this initial post.. here is my final 'steps' in case any other noobs need a 'straight forward' tutorials based on the help provided here.
=========================================
Setting up your Raspberry Pi 3:
Installing current Raspberry Pi OS to the SD card:
----------------------------------------------------
* download latest Rasbian OS image: (currently 'Stretch')
https://www.raspberrypi.org/downloads/raspbian/
* download sd imaging tool "Etcher":
https://etcher.io/
- Etcher can use .zip file to write the image to yoru SD card, there is no need to extract it.
* Install Etcher, and run it.
* Point to Rasbian "Stretch" OS .zip, and select the SD card, and write 'FLASH' image to the SD card. (take roughly 45 minutes from my
experience)
--------------------------------------------------------------------------------------------
* This assumes you have already installed the latest version of Raspbian OS on the Pi.
* As of this writing it is Raspbian Stretch Desktop
--------------------------------------------------------------------------------------------
---How to SSH into your Raspberry Pi---
----------------------------------------------------
** Enable SSH on pi (Prepare the Pi)
- take sd car and add file into _root call 'ssh' (no file extension) //this enables SSH on the PI
** SSH into your Pi
- Use a program like Putty to SSH into your Pi
- Add the IP address and save/connect to your PI (ie: 192.168.0.xx etc) //use router to find out your IP settings
* Once connected/prompted use credentials below
- User: pi
- Pass: raspberry
---How to add wifi details your Raspberry Pi---
- To connect to a wireless network, create another file on the card called wpa_supplicant.conf, which has the following inside:
Code: Select all
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="SSID"
psk="PASSWORD"
key_mgmt=WPA-PSK
}
example file:
-------------------------
Code: Select all
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="HomeOneSSID"
psk="passwordOne"
priority=1
id_str="home"
key_mgmt=WPA-PSK
}
//Additional connections (if needed):
network={
ssid="HomeTwoSSID"
psk="passwordTwo"
priority=2
id_str="work"
key_mgmt=WPA-PSK
}
* Edit country=, ssid= and psk= with your information and save the file.
* Use the 2 letter country abbreviation in CAPS (without this you will have no WiFi).
* Use a pure text editor, not a word processor, to edit the wpa_supplicant.conf file.
*** If it finds a wpa_supplicant.conf file, it will move it to its correct location and connect to your wireless network.
* Note: do not include '#' in the commands below
Common commands:
-----------------------------------------------------
Shutdown:
Code: Select all
sudo shutdown -h now (or sudo halt)
Restart:
Code: Select all
sudo shutdown -r now (or sudo reboot)
Update Repositories:
Code: Select all
sudo apt-get update
sudo apt-get upgrade //bad?
sudo apt-get update // yes, again.
Installing Apache2 Web server, PHP & MySQL
-----------------------------------------------------
** Either SSH into your Raspberry Pi or connect it to a keyboard/mouse/HMDI display, and open the terminal.
* Install Apache:
------------------------------------------------
* Give permissions to Pi:
------------------------------------------------
Code: Select all
sudo chown -R pi:www-data /var/www/html/
sudo chmod -R 770 /var/www/html/
* Change Default Web Page:
------------------------------------------------
** you can test if the server is working by opening the web browser and typing the Raspberry Pi's IP address.
** you can find out the IP address by typing: ifconfig in the terminal
** Note:
Apache uses the directory “/var/www/html” as the root for your site. This means that when you call your Raspberry on port 80 (http),
Apache looks for the file in “/var/www/html”.
For example, if you call the address “
http://127.0.0.1/example”, Apache will look for the “example” file in the “/var/www/html” directory
* Install PHP:
------------------------------------------------
* Test PHP install:
//delete default apache index.html
//create new index.php file in its place, with the following content:
Code: Select all
echo "<?php phpinfo ();?>" > /var/www/html/index.php
*** enabling PHP SHORT TAGS:
Code: Select all
sudo nano /etc/php/7.0/apache2/php.ini //find short tags and edit/save config file (.ini)
* Reload/Restart Apache/Service:
------------------------------------------------
** this might need to be done before viewing the index.php page
-Reload:
-Restart:
* Installing PhpMyAdmin
--------------------------
A.) Install PHPMyAdmin:
B.) The package will begin installing. You will be asked which web server is installed, choose apache2.
C.) Configure PhpMyAdmin’s database -- When prompted, choose Yes.
D.) Configure Apache to work with PhpMyAdmin
Code: Select all
sudo nano /etc/apache2/apache2.conf
E.) Navigate to the bottom of the file (keep pressing CTRL + V to jump page by page until you’re at the bottom of the file) and add the following new line to the file:
Code: Select all
Include /etc/phpmyadmin/apache.conf
* Install MySQL 7:
------------------------------------------------
Code: Select all
sudo apt install mysql-server php-mysql
** Type/Create root password when prompted //never got a prompt?
* verify MySQL is working:
- To check the operation of MySQL use the command line.
To do this, we will simply connect via the command:
--
We will now create a new mysql root user, because the default one can only be used with Linux root account, and so not available for the webserver and php scripts.
To do so, once your connect to MySQL, simply run thoses commands (replace password with the password you want) :
* connect to db (used only for initial connection to create new user account)
Then type:
Code: Select all
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* to 'admin'@'localhost' WITH GRANT OPTION;*.* TO 'pi'@'raspberry';
ie:
u: admin
p: password
-------------------------------------
So you now have a web server, connected to PHP and MySQL. That’s all it takes.
On your nexts connections, you will be able to connect to mysql without using sudo,
with the command:
Code: Select all
sudo mysql --user=admin --password=password
p.s. if you screw up the permissions some how (I have removed the line that messed me up and corrected the other)
You can see this thread for removing MySQL and PhpMyAdmin:
https://www.raspberrypi.org/forums/view ... 3#p1362403