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

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

Tue Jul 17, 2018 2:46 pm

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

This installed Apache2, php v7, and MariaDB 10.1.23

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

Code: Select all

#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
I found a few additional setup commands were needed to get it to work which are detailed below:

Out of the box, mysql has no root password, but unlike previous versions, this version of MySQL with MariaDB won't work with an emtpy root password unless it is used with sudo.
Here is one way to revert this behaviour:

Code: Select all

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 you should be using a proper password instead.

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

Finally, the installation did not properly configure apache to use phpmyadmin conf files, so I added a couple of symlinks as follows:

Code: Select all

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
Pointing your browser at http://127.0.0.1/phpmyadmin should then give access to the phpmyadmin tool
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

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

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

Tue Jul 17, 2018 4:12 pm

procount wrote:
Tue Jul 17, 2018 2:46 pm
Finally, the installation did not properly configure apache to use phpmyadmin conf files, so I added a couple of symlinks as follows:
During installation of phpmyadmin you are asked to select a webserver. Use the up/down key to select a webserver, use the space key to enable or disable the configuration.

Don't change the order of statements. You must install phpmyadmin (and I suppose other debian packages too, that need to install a database) before you mess up your root account. If you first make your mysql installation secure and later decide to use phpmyadmin, you are on your own.

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

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

Thu Oct 18, 2018 5:57 pm

Finally, the installation did not properly configure apache to use phpmyadmin conf files, so I added a couple of symlinks as follows:

Please post the the symlinks, they are not visible on the site. Thank you

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

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

Thu Oct 18, 2018 7:51 pm

Well, @fbe suggested I missed something out, so if you follow their advice, you may not need the symlinks.

However, if you want to follow my original steps, I included the instructions to create the symlinks in the code block, which I repeat below. Just open a terminal and type the following in:

Code: Select all

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
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

Return to “Advanced users”