xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Tried to add wifi account/settings after set-up, and stopped responding...why?

Mon Sep 03, 2018 6:04 am

I could have followed something old? or even messed something else up myself.. (not much RPi experience, and zero CLI/Linux)

I did an initial set-up of the RPi3, using Etcher and the Raspbian Stretch image..

I then continued to install Apache, PHP and MySQL..

Added the SSH file, and was using Putty to connect via my PC.. (also via FTP using WinSCP)... everything was fine, and I left it, as is... I came back today to realize I didnt have permissions to drag/upload any files to the www/html directory in Apache... so as I was looking into how to do that I ran into about how to set-up wifi and connect on boot (I thought, 'nice' now I dont have to have this cable connected to it, I can go upstairs with my little netbook, and find the RPi once it connects to my WLAN in the house....etc)...however once I tried it.. the RPi no longer responded to anything. I could no longer connect via PUTTY,.. I could no longer connect via FTP.. when I tired to access the default webpage by its IP address.. it no longer responded, or served up the default PHP info page that it used to previously)..

I have/had no clue what happened, and basically was just curious.

This is what I did/followed to add/enable wifi.. after that (it stopped responding):
https://learn.adafruit.com/adafruits-ra ... cidentalis


Here are the steps I wrote for myself to follow, that I used to do my initial set-up.. (in case that was part of he problem some how?)


* Used Etcher to flash latest Raspbian Stretch to micro SD card.
* Added 'ssh' file to _root of SD card so I can connected via Putty/FTP..etc

Update Repositories:
------------------------------------------------
# sudo apt-get update


* Install Apache:

------------------------------------------------
-- sudo apt-get install apache2 -y //old line...difference? (apt-get)
# sudo apt install apache2 //new line


* Give permissions to Pi:

------------------------------------------------
# sudo chown -R pi:www-data /var/www/html/
# sudo chmod -R 770 /var/www/html/



* Change Default Web Page:
------------------------------------------------
# cd /var/www/html
# ls -al


** I test if the server is working by opening the web browser and typing the Raspberry Pi's IP address.
** I find out the IP address by typing: ifconfig in the terminal (or my router)



* Install PHP:
------------------------------------------------
# sudo apt install php php-mbstring

* Test PHP install:

//delete default apache index.html
# sudo rm /var/www/html/index.html

//create new index.php file in its place, with the following content:
# echo "<?php phpinfo ();?>" > /var/www/html/index.php

*** enabling PHP SHORT TAGS:
sudo nano /etc/php/7.0/apache2/php.ini //find short tags and edit/save config file (.ini)


* Install MySQL 7:
------------------------------------------------

# sudo apt install mysql-server php-mysql
** Type/Create root password when prompted




So after all the above.. I had a working RPi.. (I was enabling PHP short tags as well, but previous <?php parsing worked as expected...ie: info)

Once I did the Adafruit steps for the wifi.. and rebooted... no connection.

As a beginner I am curious as to what happened? :)

epoch1970
Posts: 5581
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Mon Sep 03, 2018 7:10 am

xl97 wrote:
Mon Sep 03, 2018 6:04 am
I could have followed something old?
Yes indeed.
Remove what you added to /etc/network/interfaces and ONLY configure wpa_supplicant:
https://www.raspberrypi.org/documentati ... ess-cli.md

Then the Pi will obtain an address on the network via DHCP.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Mon Sep 03, 2018 4:31 pm

Perfect!

And thanks for the link on how to do it a more 'current way'..

Another question if you dont mind.

I actually just went through the whole process of re-flashing the OS/image to the SD card again..

why? because I could NOT gain access any other way. I could no longer connect via SSH/Putty..

I could no longer connect via FTP either.

I guess I could have manually looked for that file on the SD card using my PC?

What were (could have been) my other options to fix that? (instead of starting all over).


once I get back to where I was.. I'll attempt the wifi stuff again using the new approach..


All that is left for me then.. (for the initial install).. is getting things to load in KIOSK mode (full screen, and loading a locally hosted webpage)

Then the final 'frontier'.. playing with 2-way serial communication via PHP, and Arduino and a web front end. :)

(not sure how to wait.get a serial response BACK from Arduino > Pi > PHP yet. ) :)

epoch1970
Posts: 5581
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Mon Sep 03, 2018 5:22 pm

xl97 wrote:
Mon Sep 03, 2018 4:31 pm
What were (could have been) my other options to fix that? (instead of starting all over).
Unfortunately applying the old way to the current system has the effect of disabling wifi or perhaps networking altogether on the new system...

Your only way out of there (and it is always the safest way until your setup is stable) would have been to connect keyboard and screen to the Pi and work locally at undoing things. A serial cable or HDMI cable can be very useful.

Another avenue is to get an USB SD reader that you can plug in the Pi and an extra SD installed with a working system, e.g. Raspbian Desktop. In case of issue on your development SD, you can then shutdown the Pi, put the "rescue" SD in, boot, access and repair the development SD inserted in the USB SD reader.
(A variant of this method is to use a linux PC or a linux VM on a PC to do repairs.)

Make sure you take backups regularly. Of your developments/config files, and also from time to time it is good to take a complete image of the SD for safekeeping. An SD is not as reliable as an HDD, taking a full backup with dd (or raspi-clone ?) is never a bad idea.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Mon Sep 03, 2018 6:01 pm

Great advice.

I was so 'stuck' on headless install.. (DOH!)

Also.. about the 'back-ups' I guess I never really thought of backing up an SD card? (make sense though as it is an OS)

dd or raspi-clone....??

Are these apps used to clone/image the current SD card content to make a backup image from?

epoch1970
Posts: 5581
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Mon Sep 03, 2018 6:31 pm

dd: if you look at install instructions floating around, you'll find examples of using "dd", an old unix command. A backup using dd is the inverse of an install using dd: read from an SD and copy to an image file (on another media).

raspi-clone: I think I got mixed up between rpi-clone and SD card copier, but the general idea is a more user-friendly GUI around "dd". There are many backup/restore utilities to choose from.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Wed Sep 05, 2018 3:06 pm

Thanks for all the help so far..

wifi has worked correctly this time around.. I also decided to plug things into a display as well.. and to not run things via SSH for the last remaining steps

I am currently facing another issue (permission issue I believe)

As I move toward my goal of:

* load default (locally hosted) webpage on boot
* display locally hosted webpage in full screen (KIOSK) mode

I installed PhpMyAdmin... to set up my DB/tables that populate/create the site...

I noticed I can NOT create any databases or tables? (It says No Permissions) at the top of the page.

Why? What part or parts in my steps above are missing to allow myself to create databases/tables...etc... in PhpMyAdmin?

I can 'log in' to PhpMyAdmin.. but just cant -do- anything while inside..

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Wed Sep 05, 2018 4:05 pm

xl97 wrote:
Wed Sep 05, 2018 3:06 pm
I can 'log in' to PhpMyAdmin.. but just cant -do- anything while inside..
You 'log in' to phpMyAdmin with your MySQL credentials - typically MySQL root credentials when using it on a local system. It sounds as if the credentials you used are of a MySQL user who does not have database creation privileges and does not have any associated databases. I have never used MySQL or phpMyAdmin on a Pi (and have only installed them on Windows systems), but your MySQL installation should have included the creation of a 'superuser', whose credentials are those you should be using for phpMyAdmin.

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Wed Sep 05, 2018 4:36 pm

hmm..

makes sense. (thanks for the reply)

I guess when I get home tonight. I'll see if I can log in with other credentials...

User avatar
HawaiianPi
Posts: 5968
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Thu Sep 06, 2018 12:13 am

xl97 wrote:
Mon Sep 03, 2018 6:01 pm
I was so 'stuck' on headless install.. (DOH!)
Headless install is possible. It's the way I set up most of my Pi computers. The info is available on the raspberrypi.org web site, but it's not necessarily all in one place, so this is how I set up headless boot with SSH and wireless networking. It works with Raspbian Jessie or Stretch, Desktop or Lite, and with the built-in WiFi on the Pi3B(+) & Pi Zero W, or a Raspbian compatible USB WiFi dongle on other models. Everything is done before you boot, and can be done on a Windows or Mac computer which only has access to the small FAT32 "boot" partition of a Raspbian imaged SD card.
  1. Grab the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
  2. Grab the Etcher software from https://etcher.io/
  3. Use Etcher to write the Raspbian image to your SD card.
    • You don't need to extract the image or format the card prior to writing.
    • Just run Etcher, choose the Raspbian .zip you downloaded, pick your SD card and write.
    • If you have trouble, verify the SHA256 checksum of the download (see notes at end).
    • Writing an image to your card will erase everything previously on it!
  4. Remove and reinsert the SD card so that your Windows or Mac PC can see the small FAT32 partition on the card (labelled "boot").
    • If you get a message telling you the card must be formatted, cancel it.
  5. On that small FAT32 partition, create a file with the name ssh (or ssh.txt). It can be empty, the contents don't matter.
  6. 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="Your network name/SSID"
         psk="Your WPA/WPA2 security key"
         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.
  7. Make sure that both files are in the main directory of the small FAT32 partition, not in any folder.
  8. Safely eject the card from your PC and use it to boot the Pi.
If Raspbian finds an ssh file it will enable SSH and delete the file. If it finds a wpa_supplicant.conf file, it will move it to its correct location and connect to your wireless network. Give your Pi some time to boot and connect to your network (the first boot always takes longer), then you should be able to SSH into the Pi and configure it how you like.

If you have a Zeroconf network service installed (Apple's iTunes or Bonjour install Zeroconf to Windows), you can SSH into pi@raspberrypi.local (provided you don't have any other Pi computers on your network with the same default hostname). Otherwise you must SSH into your Pi's IP address, which you can find by logging into your router and checking the list of connected clients, or using a network scanner app (like Fing for smartphones).

To login using SSH from Windows, you can use an app called PuTTY, which looks like this (click picture for download link).
Image

In the Host Name (or IP address) field, enter either,

Code: Select all

pi@raspberrypi.local
or
pi@your.pi.IP.address
make sure SSH is selected (it should be by default) and click on Open.

If you have done everything correctly, a terminal window will open and you should see a password request. Although, if it's the first time you've connected to your Pi, you may have to answer "yes" to a security question, and then you'll get the password prompt. After login you'll get a warning about having SSH enabled with the default password, so type passwd[Enter] and enter a new password (twice). And now you can do whatever you need to configure your little Raspberry Pi computer.

Code: Select all

sudo raspi-config
Will bring up the Raspbian configuration utility. If you have more than one Raspberry Pi computer on your network it's a good idea to change the hostnames to something unique so that they can easily be identified.

Notes:
If you have attempted this and failed and unplugged power to turn off your Pi, you should start over with a freshly imaged card. Improperly powering down the Pi can cause SSH key generation to fail, which will prevent SSH logins (even if everything else is correct).

Alternatives to PuTTY:
If your main PC has the Windows 10 OS, there are 2 alternatives to PuTTY. The Windows 10 Fall Creators Update (2017) added the ability to install the Windows Subsystem for Linux, which is a Linux Bash shell for Windows (there are a few different versions of Linux in the Microsoft Store). And the recent Windows 10 Spring Update (2018) added OpenSSH directly to the Windows command and powershell utilities.

Verifying hash checksums in Windows:
My favorite way to check file cryptographic hashes (checksums) in Windows is a free, open source utility called HashCheck. https://github.com/gurnec/HashCheck/releases/latest

It's a Windows shell extension that adds a Checksums tab to file properties. You can configure which checksums it calculates and displays, and you can input a sum to see if it matches the file properties you are looking at. You can also create text files with a list of sums and filenames to verify a bunch of files by double-clicking on the text file.

In addition, Windows 8 and 10 (and possibly 7) have a little known, built-in application called CertUtil that you can use for hash checking. To check the current version of Raspbian Stretch Lite (at the time of this post), open the Command prompt or Windows PowerShell in the same folder as the file and enter:

Code: Select all

certutil -hashfile 2018-06-27-raspbian-stretch-lite.zip sha256
Which should give you the output:

Code: Select all

SHA256 hash of 2018-06-27-raspbian-stretch-lite.zip:
3271b244734286d99aeba8fa043b6634cad488d211583814a2018fc14fdca313
CertUtil: -hashfile command completed successfully.
Which matches the value published on the download page.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Thu Sep 06, 2018 1:27 am

Thanks for the reply.

I believe that is pretty much what I outlined above? (minus the fact I used old wifi set-up info).. and yours has current/correct info on setting up wifi... or am I missing something glaring?

My comment about 'stuck on headless'.. was meant in response to my lack of being able to 'trouble shoot' anything once I messed up the DHCP ability..etc. :)

What I am currently attempting (and failing) to do is log into PhpMyAdmin .. so I have permissions to add databases/tables..etc..

last night, I was able to login.. but no permissions to do anything.

tonight.. I cant even get the IP to serve up the default webpage or access PhpMyAdmin! LOL..

I'm going to reboot the RPi upstairs.. and see if I can get at it again..

Thanks

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Thu Sep 06, 2018 1:59 am

update: well I went upstairs.. Pi was running as expected.. (have it connected to living room TV for a display right now)

I can only log into PhpMyAdmin use one set of credentials...

When looking back at the steps I took... here is where the MySQL user/account was created... but I dont see anything about the privileges?

Code: Select all

We will now delete the default mysql root user and 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) :

** Line above gets you to query prompt (MariaDB)

DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'

in which I just created one with the same user/pass combo...for sake of outlining my steps/process for myself.. (and this standalone project)



At this point, I'm not clear on what to do to proceed here?

I need to some how add a user account with the correct permissions.. but I cant seem to drop or add anyone at this point (I get error/response in Putty about needing user creation permissions to do the lines above?)


Here is the tutorial that outlines deleting the default user and why: (scroll down MySQL install section)

https://howtoraspberrypi.com/how-to-ins ... y-pi-lamp/


Should I? (and how can I?) remove PhpMyAdmin and MySQL and start the install process over perhaps? (kinda messy in my mind.. but I'm just slave to all this Linux/CLI/Raspbian stuff still!) :)

Thanks

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Thu Sep 06, 2018 3:35 am

xl97 wrote:
Thu Sep 06, 2018 1:59 am
update: well I went upstairs.. Pi was running as expected.. (have it connected to living room TV for a display right now)

I can only log into PhpMyAdmin use one set of credentials...

When looking back at the steps I took... here is where the MySQL user/account was created... but I dont see anything about the privileges?

Code: Select all

We will now delete the default mysql root user and 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) :

** Line above gets you to query prompt (MariaDB)

DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'

in which I just created one with the same user/pass combo...for sake of outlining my steps/process for myself.. (and this standalone project)
I say again that I have never had to install MySQL/MariaBD on a Pi, so if someone with more specific experience wants to comment, I hope that they do. However, I believe the critical line above is :

Code: Select all

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'
If you only entered the first two lines ("DROP USER..." and "CREATE USER...") as instructed (deleting and then recreating a user named 'root') and then exited from MariaDB, I would expect you to have exactly what you have described: a valid user of the database manager with no ability to do anything! If that is what you did, I think that it is probably not recoverable without uninstalling and reinstalling the database manager. You probably don't need to uninstall phpMyAdmin - it should work fine for a MariaDB user who has some privileges!

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Thu Sep 06, 2018 4:34 am

Thanks.. all information is welcome! (but yes.. I do hope someone with some direct exposure similar to my install/problems does chime in!) LOL


Question:

what specifically do you mean by this:
"uninstalling and reinstalling the database manager."

Are you referring (un)installing MySQL? (or "MariaDB" as I see it referred to)


*I havent even gotten to trying to get it to boot to a default webpage yet.. (since I can even get that 100% up and running yet either!...LOL)... nor in fullscreen/KIOSK mode yet!

1 (long) day at a time I suppose.

Actually.. since is somewhat off topic of my original post.. do you think I'd fare better with a new post about the permissions thing?


Thanks!

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Thu Sep 06, 2018 12:57 pm

xl97 wrote:
Thu Sep 06, 2018 4:34 am
Question:

what specifically do you mean by this:
"uninstalling and reinstalling the database manager."

Are you referring (un)installing MySQL? (or "MariaDB" as I see it referred to)
Yes, that is what I meant. MariaDB is, in effect, a development branch of MySQL, and is the way that the Raspbian folks have chosen to go. For most external purposes, the two are indistinguishable, but MariaDB has a number of features that make it more attractive to DB gurus and developers who want to do more complex things.

fruitoftheloom
Posts: 24050
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Thu Sep 06, 2018 1:18 pm

pfletch101 wrote:
Thu Sep 06, 2018 12:57 pm
xl97 wrote:
Thu Sep 06, 2018 4:34 am
Question:

what specifically do you mean by this:
"uninstalling and reinstalling the database manager."

Are you referring (un)installing MySQL? (or "MariaDB" as I see it referred to)
Yes, that is what I meant. MariaDB is, in effect, a development branch of MySQL, and is the way that the Raspbian folks have chosen to go. For most external purposes, the two are indistinguishable, but MariaDB has a number of features that make it more attractive to DB gurus and developers who want to do more complex things.

MariaDB was a Debian choice nothing to do with RPF / RPT:

https://mariadb.com/about-us/newsroom/p ... t-debian-9
Thinking outside the box is better than burying your head in the sand...

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Thu Sep 06, 2018 1:41 pm

fruitoftheloom wrote:
Thu Sep 06, 2018 1:18 pm

MariaDB was a Debian choice nothing to do with RPF / RPT:

https://mariadb.com/about-us/newsroom/p ... t-debian-9
Except that Raspbian is, in essence, Debian for the Pi! The distinction you are making is valid but the effects are the same - we get MariaDB instead of 'classical' MySQL..

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Thu Sep 06, 2018 3:43 pm

xl97 wrote:
Thu Sep 06, 2018 4:34 am
Thanks.. all information is welcome! (but yes.. I do hope someone with some direct exposure similar to my install/problems does chime in!) LOL
I did some experimenting on my development system. After a routine install of MariaDB ("sudo apt-get install mariadb-server"), I was simply returned to the command line - I did not get any of the instructions you showed in your listing. I found that if I entered:

Code: Select all

mysql -user root -p
, I got a password prompt, but entering a blank password (correct for a normal Raspbian install) resulted in an 'Access denied' error, as did:

Code: Select all

mysql -user pi -p
(entering the appropriate password). However,

Code: Select all

sudo mysql -user root -p
, with the blank password got me to the MariaDB command line, where I did not delete the default (root) user, but just entered:

Code: Select all

CREATE USER 'pi'@'localhost' IDENTIFIED BY 'pi_password';
GRANT ALL PRIVILEGES ON *.* TO 'pi'@'localhost';
I used the actual login password of my pi user, though I am not sure whether this is essential.
After doing this, entering

Code: Select all

mysql -user pi -p
on the command line, and then typing in the appropriate password, got me back into MariaDB - N.B. now without sudo.

I think that the problem with the instructions that you followed is that they tell you to delete the default superuser before creating a new user with similar privileges (but no sudo requirement). If you make a mistake in the second part of the process and don't recognize it before you have logged out of MariaDB, you are left with no way of getting back into it with full privileges. I think that this is what must have happened to you.

I would suggest that you uninstall MariaDB, then reinstall it, leave the root user unchanged and add your pi persona as a new user with full privileges, as shown above. If you then run phpMyAdmin and log in as the new pi user, you should be able to create and use the databases you need.

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Tried to add wifi account/settings after set-up, and stopped responding...why?

Sat Sep 08, 2018 2:44 am

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:

------------------------------------------------

Code: Select all

sudo apt install apache2



* 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:
------------------------------------------------

Code: Select all

cd /var/www/html
ls -al

** 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:
------------------------------------------------

Code: Select all

sudo apt install php php-mbstring
* Test PHP install:

//delete default apache index.html

Code: Select all

sudo rm /var/www/html/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:

Code: Select all

sudo /etc/init.d/apache2 reload
-Restart:

Code: Select all

sudo /etc/init.d/apache2 restart




* Installing PhpMyAdmin
--------------------------


A.) Install PHPMyAdmin:

Code: Select all

sudo apt 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:

Code: Select all

# sudo mysql --user=root
--

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)

Code: Select all

sudo mysql --user=root

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

Return to “Beginners”