LAMP is an acronym that stands for Linux Apache, MySQL and PHP, these are the components required to run and present web interface of PiHome Smart Heating Control.
PHP 5 no longer supported by PiHome, you can use it as at your own discretion, also mysql users need to disable ‘ONLY_FULL_GROUP_BY’ sqlmode see GitHub for more information
Note: if you are here for some troubleshoot Raspberry Pi LAMP (PHP and MySQL/MariaDB on a Raspberry Pi with phpMyAdmin) then check out troubleshooting post on Raspberry Pi LAMP
Install (LAMP) Apache and MySQL server on Pi
Lets just run update first by issuing following commands
1 2 |
sudo apt-get update sudo apt-get upgrade |
Now Install Apache, PHP and MySQL server with other dependencies
1 2 3 4 5 |
sudo bash apt-get install apache2 apache2-doc apache2-utils apt-get install libapache2-mod-php5 php5 php-pear php5-xcache apt-get install php5-mysql php5-curl php5-gd apt-get install mysql-server mysql-client python-mysqldb |
During MySQL server installation you will get option to set the mysql root password.
Install phpMyAdmin on Pi
PhpMyAdmin isn’t required but it will make your life easier if you need to do any troubleshooting for MySQL Database.
Begin the PhpMyAdmin installation
1 2 3 |
sudo bash apt-get install phpmyadmin choose apache2 |
Configure for dbconfig-common
Configure Apache to work with PhpMyAdmin. Edit /etc/apache2/apache2.conf and go to end of file.
1 |
nano /etc/apache2/apache2.conf |
Add following line and then CTRL+O to save changes and then CTRL+X to exit.
1 |
Include /etc/phpmyadmin/apache.conf |
Now restart Apache web server, if everything was correct Apache service should start successfully.
Change Document Root Folder
By default Apache server installed with document root pointing to /var/www/html, you need to change this in /etc/apache2/sites-available/000-default.conf for PiHome to work.
1 |
DocumentRoot /var/www/html |
to
1 |
DocumentRoot /var/www/ |
After this change copy all project folder to /var/www/ and restart apache service
1 |
/etc/init.d/apache2 restart |
28 comments
php5 replaced with php7. mysql is mariadb now. phpmyadmin does not work.
Hi Jean,
All PiHome code is written in php5 i haven’t got enough time to update this as i m trying to release PiHome on github, but thank you for your comments once this project become available for public you are more then welcome to contribute.
i have done another post for Install Apache, PHP 7.0 and MySQL/MariaDB on a Raspberry Pi (LAMP) with phpMyAdmin
Thank you very much for this detailed tutorial on pi lamp server. I found it extremely helpful! I just got my pi today and after going through your work – a fully functional server. Thank you!
Hi why when i started only see:
Please wait while system grab latest information from database…
and i cannot pres edit buttons>
what version of php you are running? can you check /var/log/apache2/error.log there might be some clues…
can you try to run php /var/www/cron/boiler.php and share the output.
2018-01-29 14:11:52 – Boiler Script Started
PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /var/www/cron/boiler.php on line 31
—————————————————————————————-
PHP Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/cron/boiler.php on line 66
PHP Notice: Undefined variable: boiler in /var/www/cron/boiler.php on line 228
PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/cron/boiler.php on line 228
2018-01-29 14:11:52 – Boiler Node ID: Child ID:
PHP Notice: Undefined variable: stop_cause in /var/www/cron/boiler.php on line 280
2018-01-29 14:11:52 – Boiler Log table updated Successfully.
PHP Notice: Undefined variable: current_time in /var/www/cron/boiler.php on line 297
2018-01-29 14:11:52 – PiHome Says: Thank you for Supporting !!!
2018-01-29 14:11:52 – Boiler Fired Status: 0
PHP Notice: Undefined variable: hysteresis in /var/www/cron/boiler.php on line 319
2018-01-29 14:11:52 – Boiler Hysteresis Status:
—————————————————————————————-
2018-01-29 14:11:52 – Boiler Script Ended
PHP is 5.5 and no error in apache log
I need to ose only Pi without arduino
Hi sorry missed your comments, can you elaborate what you mean by pi without arduino ?
@hawk,
to let you know i have added functionality for gpio connected zone, boiler and sensor to this, just make sure you add gpio pin number to zone and boiler table and uncomment gpio sections in boiler.php
need help drop me email of lave comments here.
Admin
Hi,
I’m trying to set this up on Stretch, with mysql on a remote instance.
Raspberry pi is networked and connected, apache installed and i got the web page example above.
I skipped the mysql steps, and phpmyadmin.
My install steps are:
apt-get install apache2 apache2-doc apache2-utils
apt-get install libapache2-mod-php7.0 php7.0 php7.0-fpm php-pear php7.0-opcache php7.0-mbstring php7.0-mysql php7.0-curl php7.0-gd
apt-get install mysql-server mysql-client python-mysqldb
Change document folder
git clone of the repo.
Changed the setup.php values for:
host (to an ip addres)
dbname is pihome
dbusername is pihome
dbpassword is
On php my admin i have created a db and user for pihome with password, and granted all non sys privs.
I then try and run:
/usr/bin/php /var/www/setup.php
get the following error:
PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /var/www/setup.php:38
Stack trace:
#0 {main}
thrown in /var/www/setup.php on line 38
@harvybob
php7 isnt supported for PiHome, you need to following Install Apache, PHP and MySQL on a Raspberry Pi (LAMP) let me know if you need more help
Admin
I have followed this exactly with no errors but I don’t know what you mean by After this change copy all project folder to /var/www/ nor do I know how to do this, please can you help?
Thomas,
you need to modify /etc/apache2/sites-available/000-default.conf and look for DocumentRoot /var/www/html and change this to DocumentRoot /var/www/ and restart Apache service
ps: this change is required if you want to install PiHome Smart Heating otherwise you are ok without this change and you should have working LAMP stack on your raspherry pi.
Hi
I have done this, I can reach the webpage to login but I put the default username and password in and it isn’t having it? I have also tried many difference combinations of pihome, pihome2018, admin, pihomedbadmin and passw0rd.
Thomas,
default login credentials for PiHome Web interface is User: admin and Password: pihome
These credentials are not working
can you check user table from your database? you should have 0f5f9ba0136d5a8588b3fc70ec752869 in your password column
I have connected to the database and asked it to show tables; but there is no user table?
it looks like your database creation had some issues. can you try to re-create database. you can do this by importing mysql file to phpmyadmin. after that don’t forget to MySQL_View.sql ( you may have to create table view one by one)
Which MySQL file do I import to phpmyadmin?
Thomas,
MySQL_Database/pihome_mysql_database.sql you can always download img file and write on sd card and you’ll have all working without much effort.
Hey there! I’ve been following your weblog for a long time
now and finally got the courage to go ahead and give you a shout out from Kingwood Tx!
Just wanted to mention keep up the excellent work!
Thank you very much for the invitation :). Best wishes.
PS: How are you? I am from France 🙂