0% found this document useful (0 votes)
74 views14 pages

HOWTO: Install LAMP Stack (On Raspbian Stretch June 2018)

This document provides instructions for installing a LAMP (Linux, Apache, MySQL, PHP) stack on a Raspberry Pi running Raspbian Stretch. It summarizes a tutorial for installing Apache2, PHP 7, and MariaDB 10.1.23. Additional steps are needed to secure the MySQL root user and configure Apache to work with PHPMyAdmin. These include setting a root password in MySQL, uncommenting passwordless access in the PHPMyAdmin configuration file, and creating symlinks so Apache reads the PHPMyAdmin configuration files. Following these instructions installs the core LAMP components and configures PHPMyAdmin for database administration.

Uploaded by

Deyna Tamay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views14 pages

HOWTO: Install LAMP Stack (On Raspbian Stretch June 2018)

This document provides instructions for installing a LAMP (Linux, Apache, MySQL, PHP) stack on a Raspberry Pi running Raspbian Stretch. It summarizes a tutorial for installing Apache2, PHP 7, and MariaDB 10.1.23. Additional steps are needed to secure the MySQL root user and configure Apache to work with PHPMyAdmin. These include setting a root password in MySQL, uncommenting passwordless access in the PHPMyAdmin configuration file, and creating symlinks so Apache reads the PHPMyAdmin configuration files. Following these instructions installs the core LAMP components and configures PHPMyAdmin for database administration.

Uploaded by

Deyna Tamay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

Quick Start Guide


Forum FAQ
About
About us
Contact us
Technical, help and resource documents
Trademark rules

Search

Login
Register

Board index Using the Raspberry Pi Adv anced users

HOWTO: Install LAMP stack (on Raspbian Stretch June 2018)


Post Reply

Search this topic…

12 posts • Page 1 of 1

procount
Posts: 1652
Joined: Thu Jun 27 , 2013 12:32 pm
Location: UK

HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 1/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

Tue Jul 17 , 2018 2:46 pm

I needed to install a LAMP stack (Linux Apache My SQL PHP) for a student to run a project on.
I found it a little tricky since v ersions had changed since I last did this, but finally I found this tutorial that worked:
https://pchelp.ricmedia.com/setup-lamp- ... y -guide/3/ (https://pchelp.ricmedia.com/setup-lamp-serv er-raspberry -pi-3-complete-diy -guide/3/) (starting on page 3,
since I already had Raspbian installed)

This installed Apache2, php v 7 , and MariaDB 10.1.23

I adv ise following the abov e tutorial for completeness as it includes an additional step, but for a quick summary and [tl;dr]:

Code:

#Update system
sudo apt-get update
sudo apt-get upgrade -y

#Install Apache2
sudo apt-get install apache2 -y
sudo a2enmod rewrite
sudo service apache2 restart

#Install PHP
sudo apt-get install php libapache2-mod-php -y

#Install MySQL
sudo apt-get install mysql-server php-mysql -y
sudo service apache2 restart

#Install PhpMyAdmin
sudo apt-get install phpmyadmin -y

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 2/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

I found a few additional setup commands were needed to get it to work which are detailed below:

Out of the box, my sql has no root password, but unlike prev ious v ersions, this v ersion of My SQL with MariaDB won't work with an emtpy root password unless it is used
with sudo.
Here is one way to rev ert this behav iour:

Code:

sudo mysql -u root

[MariaDB] use mysql;


[MariaDB] update user set plugin='' where User='root';
[MariaDB] flush privileges;
[MariaDB] \q

#This needs to be followed by the following command:


mysql_secure_installation

Although y ou should be using a proper password instead.

Likewise, phpmy admin won't allow access with an empty password by default.
To allow passordless access, uncomment the lines in /etc/phpmy admin/config.inc.php where 'AllowNoPassword' is mentioned.
But y ou should be using a proper password.

Finally , the installation did not properly configure apache to use phpmy admin conf files, so I added a couple of sy mlinks as follows:

Code:

cd /etc/apache2/conf-available
sudo ln -s ../../phpmyadmin/apache.conf phpmyadmin.conf
cd /etc/apache2/conf-enabled
sudo ln -s ../conf-available/phpmyadmin.conf phpmyadmin.conf
sudo service apache2 restart

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 3/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

Pointing y our browser at http://127 .0.0.1/phpmy admin (http://127 .0.0.1/phpmy admin) should then giv e access to the phpmy admin tool

PINN - NOOBS with the extras... https://www.raspberrypi.org/forum s/viewtopic.php?f=63&t=142574

fbe
Posts: 47 0
Joined: Thu Aug 17 , 2017 9:08 pm

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Tue Jul 17 , 2018 4:12 pm

procount (./memberlist.php?mode=viewprofile&u=7 487 6&sid=9feff8eda2a7 5914eeb557 29a3601fcc) wrote: ↑ (./viewtopic.php?


p=1341918&sid=9feff8eda2a7 5914eeb557 29a3601fcc#p1341918)
Tue Jul 17 , 2018 2:46 pm

Finally , the installation did not properly configure apache to use phpmy admin conf files, so I added a couple of sy mlinks as follows:

During installation of phpmy admin y ou are asked to select a webserv er. Use the up/down key to select a webserv er, use the space key to enable or disable the
configuration.

Don't change the order of statements. Y ou must install phpmy admin (and I suppose other debian packages too, that need to install a database) before y ou mess up y our
root account. If y ou first make y our my sql installation secure and later decide to use phpmy admin, y ou are on y our own.

fy lloxera
Posts: 2
Joined: Sat Dec 26, 2015 9:46 pm

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Thu Oct 18, 2018 5:57 pm

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 4/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

Finally , the installation did not properly configure apache to use phpmy admin conf files, so I added a couple of sy mlinks as follows:

Please post the the sy mlinks, they are not v isible on the site. Thank y ou

procount
Posts: 1652
Joined: Thu Jun 27 , 2013 12:32 pm
Location: UK

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Thu Oct 18, 2018 7 :51 pm

Well, @fbe suggested I missed something out, so if y ou follow their adv ice, y ou may not need the sy mlinks.

Howev er, if y ou want to follow my original steps, I included the instructions to create the sy mlinks in the code block, which I repeat below. Just open a terminal and ty pe
the following in:

Code:

cd /etc/apache2/conf-available
sudo ln -s ../../phpmyadmin/apache.conf phpmyadmin.conf
cd /etc/apache2/conf-enabled
sudo ln -s ../conf-available/phpmyadmin.conf phpmyadmin.conf
sudo service apache2 restart

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 5/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

PINN - NOOBS with the extras... https://www.raspberrypi.org/forum s/viewtopic.php?f=63&t=142574

m0j01
Posts: 1
Joined: Sat Dec 01, 2018 9:48 am

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Sat Dec 01, 2018 9:50 am

Y o, thank y ou for the post. It is nice to be able to create tables in phpmy admin.

U-Rock

eMEsut
Posts: 4
Joined: Wed Apr 17 , 2019 2:12 pm

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Thu Apr 18, 2019 6:25 pm

Thanks @procount for y our tutorial, y ou sav e my time

I am newbie on linux and lamp....

I got some errors with sy mlinks, but i can login phpmy admin with root user, before i tried other tutorials but i couldn't login with root and couldn't create database

pi@raspberry pi:~ $ cd /etc/apache2/conf-av ailable


pi@raspberry pi:/etc/apache2/conf-av ailable $ sudo ln -s ../../phpmy admin/apache.conf phpmy admin.conf
ln: failed to create sy mbolic link 'phpmy admin.conf': Dosy a v ar

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 6/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

pi@raspberry pi:/etc/apache2/conf-av ailable $ cd /etc/apache2/conf-enabled


pi@raspberry pi:/etc/apache2/conf-enabled $ sudo ln -s ../conf-av ailable/phpmy admin.conf phpmy admin.conf
ln: failed to create sy mbolic link 'phpmy admin.conf': Dosy a v ar

AndieB
Posts: 3
Joined: Mon Jul 18, 2016 12:37 pm
Location: Sweden

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Thu Apr 25, 2019 4:45 am

Hi,

thank y ou for a great and simple HOWTO guide to hav e LAMP on Raspberry Pi.

Hav e one issue though.


When accessing phpmy admin there are not priv ileges to create a new database.
How shall I fix this?

Thanks!

~AndieB

procount
Posts: 1652

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 7/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

Joined: Thu Jun 27 , 2013 12:32 pm


Location: UK

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Thu Apr 25, 2019 10:30 am

@eMEsut & @AndieB


I'm not sure what is wrong with either of y our installations, as I'm not an expert on this, So I just went through my tutorial step by step again on the latest updated
Raspbian and it worked fine. I could create a new database too.
So may be there is something different about the OS y ou are using, or made a mistake in one of the steps? I Dunno.
Any way , if y ou install PINN, there is a ready made Raspbian-LAMP image under the testing category which is the result of the completing the tutorial abov e using the
June 2018 Raspbian v ersion.
I'm going to repeat the tutorial steps below in my next post with the latest v ersion of Raspbian, but with some minor adjustments according to the latest v ersions and
clarify ing some steps. May be try again with the following steps.

Last edited by procount on Thu Apr 25, 2019 10:42 am, edited 1 time in total.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forum s/viewtopic.php?f=63&t=142574

procount
Posts: 1652
Joined: Thu Jun 27 , 2013 12:32 pm
Location: UK

Re: HOWTO: Install LAMP stack (on Raspbian Stretch April 2019) Quote

Thu Apr 25, 2019 10:41 am

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 8/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

I needed to install a LAMP stack (Linux Apache My SQL PHP) for a student to run a project on.
I found it a little tricky since v ersions had changed since I last did this, but finally I found this tutorial that worked:
https://pchelp.ricmedia.com/setup-lamp- ... y -guide/3/ (https://pchelp.ricmedia.com/setup-lamp-serv er-raspberry -pi-3-complete-diy -guide/3/) (starting on page 3,
since I already had Raspbian installed)

This installed:
Apache2
PHP 7 .0.33-0+deb9u3 (cli) (built: Mar 8 2019 10:01:24) ( NTS )
my sql Ver 15.1 Distrib 10.1.37 -MariaDB, for debian-linux-gnueabihf (armv 8l) using readline 5.2

I adv ise following the abov e tutorial for completeness as it includes an additional step, but for a quick summary and [tl;dr]:

Code:

#Update system
sudo apt-get update
sudo apt-get upgrade -y

#Install Apache2
sudo apt-get install apache2 -y
sudo a2enmod rewrite
sudo systemctl apache2 restart

#Install PHP
sudo apt-get install php libapache2-mod-php -y

#Install MySQL
sudo apt-get install mysql-server php-mysql -y
sudo systemctl apache2 restart

#Install PhpMyAdmin
sudo apt-get install phpmyadmin -y

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 9/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

During the installation of phpmy admin, it will ask y ou to choose a webserv er. Y ou should choose Apache 2.
There will be a little red square on this selection already , but this is just the cursor; it does not mean it has already been selected! So press the space bar to select Apache2
befpore continuing.

I found a few additional setup commands were needed to get it to work which are detailed below:

Out of the box, my sql has no root password, but unlike prev ious v ersions, this v ersion of My SQL with MariaDB won't work with an emtpy root password unless it is used
with sudo.
Here is one way to rev ert this behav iour:

Code:

sudo mysql -u root

[MariaDB] use mysql;


[MariaDB] update user set plugin='' where User='root';
[MariaDB] flush privileges;
[MariaDB] \q

#This needs to be followed by the following command:


mysql_secure_installation

Although y ou should be using a proper password instead.

Likewise, phpmy admin won't allow access with an empty password by default.
To allow passordless access, uncomment the lines in /etc/phpmy admin/config.inc.php where 'AllowNoPassword' is mentioned.
But y ou should be using a proper password.

(So hav ing now properly selected the Apache2 webserv er when installing phpmy admin, there is no need to mess with the sy mlinks as in the prev ious tutorial as these will
be created correctly .)

Pointing y our browser at http://127 .0.0.1/phpmy admin (http://127 .0.0.1/phpmy admin) should then giv e access to the phpmy admin tool

PINN - NOOBS with the extras... https://www.raspberrypi.org/forum s/viewtopic.php?f=63&t=142574

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 10/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

DarkPlatinum
Posts: 829
Joined: Thu Nov 02, 2017 2:30 pm
Location: Unknown
Contact: Website

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Thu Apr 25, 2019 12:59 pm

Does this no longer work?

https://projects.raspberry pi.org/en/pro ... -wordpress (https://projects.raspberry pi.org/en/projects/lamp-web-serv er-with-wordpress)

1 * Raspberry Pi Zero W, 1 * Raspberry Pi 2, 1 * Raspberry Pi 3 1 * Raspberry Pi 3B +

Check Out My Raspberry Site (Run on a Raspberry Pi 3B ): Https://Html.dy nu.net

fbe
Posts: 47 0
Joined: Thu Aug 17 , 2017 9:08 pm

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Thu Apr 25, 2019 6:03 pm

It "works". But y ou should be aware that uses the my sql root user to run wordpress, it writes the my sql root password into wp-config.php and leav es it readable for
any one who can login to the serv er and it giv es the webserv er write access to the document root.

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 11/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

The my sql_secure_installation is useless in that tutorial, though it doesn't hurt. The "GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' IDENTIFIED BY
'Y OURPASSWORD';" statement doesn't grant any priv ilege ('root'@'localhost' already has all priv ileges) but does what the my sql_secure_installation was supposed to do -
it enables password authentication and sets the password for root (the IDENTIFIED BY clause does it). The "FLUSH PRIVILEGES" is useless.

If y ou want to do something serious, almost ev ery thing beginning with "Download WordPress" is wrong.

Andy roo
Posts: 3502
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) Quote

Thu Apr 25, 2019 6:49 pm

fbe (./memberlist.php?mode=viewprofile&u=24247 9&sid=9feff8eda2a7 5914eeb557 29a3601fcc) wrote: ↑ (./viewtopic.php?


p=1460420&sid=9feff8eda2a7 5914eeb557 29a3601fcc#p1460420)
Thu Apr 25, 2019 6:03 pm

It "works". But y ou should be aware that uses the my sql root user to run wordpress, it writes the my sql root password into wp-config.php and leav es it readable for
any one who can login to the serv er and it giv es the webserv er write access to the document root.
...

I do not know where this idea has come from. I was alway s taught that each application has minimal access to ANY THING with only sufficient to do the job they need
(role based authentication). Giv en it’s only a few seconds extra work to create a user specifically for WP and giv e access only to the WP database I wish that would become
the standard document.

fbe (./memberlist.php?mode=viewprofile&u=24247 9&sid=9feff8eda2a7 5914eeb557 29a3601fcc) wrote: ↑ (./viewtopic.php?


p=1460420&sid=9feff8eda2a7 5914eeb557 29a3601fcc#p1460420)
Thu Apr 25, 2019 6:03 pm

The "FLUSH PRIVILEGES" is useless.

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 12/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

This should be qualified in that the ‘flush’ is not needed in this case as the internal security routines capture and apply changes when done with GRANT as here. It’s only
needed when the security tables are updated directly with update / insert / delete.

As for the final statement WP still has a major following BUT is rapidly showing its age and ev en Gutenberg is a last minute gasp to win back users who are seeing ‘drag-
and-drop’ tools dev eloping sites that look better. Too many add-ins are not updated, clash or hav e security weaknesses that it’s a concern to mov e any site from v ersion
to v ersion and the whole idea of auto-updating the base of a multi-user site may well sit fine with WP teams but giv es me nightmares as I cannot test it before rolling it out.

The other worry in the majority of installs is no thought is giv en to security of the box - ev en a simple firewall rule should be included AS A MINIMUM with Fail2Ban etc
added.

Need Pi spray - these things are breeding in my house...

Display posts from prev ious:


All posts

Sort by
Post time

Ascending

Go

Post Reply
12 posts • Page 1 of 1

Return to “Adv anced users”

Jump to

Board index
All times are UTC

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 13/14
30/7/2019 HOWTO: Install LAMP stack (on Raspbian Stretch June 2018) - Raspberry Pi Forums

Delete all board cookies

ABOUT US SUPPORT
About us Help
Our team Documentation
Governance Projects
Safeguarding Training
Our supporters Downloads
Jobs Research
Contact us FAQ

SIGN UP TO OUR NEWSLETTER

Your email here

SUBSCRIBE

RASPBERRY PI FOUNDATION
UK REGISTERED CHARITY 1129409

Privacy Cookies Trademark rules and brand guidelines

https://www.raspberrypi.org/forums/viewtopic.php?t=218354 14/14

You might also like