How to Install a LAMP Server on Debian 9 Stretch Linux -

If you're looking to set up a LAMP stack to host your website, it'd be hard to find a better option to build it on than Debian Stretch. Debian is, after all, well known for its stability, security, and massive package repositories, and Stretch is certainly no exception.

This is a companion discussion topic for the original entry at

Dave Brace

Hey. Great tutorial. I’m stuck tho :frowning:

# apt install apache2 libapache2-mod-php7.0

index.html containing:
(code you indicated)
done but browsing to localhost comes back blank

Any tips on troubleshooting apache with this php install?

--------- edit
ok so browsed to localhost\index.php (which I created and put your test snip in)
This worked php responded with version/config details
--------- edit

Can’t get phpmyadmin to work yet tho :open_mouth:

Fernando López

All working fine. Thank you.

Yesenia Castellano

Running on Raspberry Pi3 / Debian 9. All worked until I attempted localhost/phpmyadmin and got a 404 not found error. How shall I proceed? Already tried reinstall and still no luck for me. Thanks in advanced for anyones help.

NVM… answered my own question. Found my fix on an old forum by entering the following:

sudo dpkg-reconfigure -plow phpmyadmin


apache2-mod-php7.0 isn’t the right package name…

Lubos Rendek Mod → lachlan

Hi although apache2-mod-php7.0 will work too:

apt install apache2-mod-php7.0
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘libapache2-mod-php7.0’ for regex ‘apache2-mod-php7.0’
The following additional packages will be installed…

You are right anyway. This will be corrected soon…thank you

Echo Mgm

If phpmyadmin does not work:

Add: Include /etc/phpmyadmin/apache.conf
at the end of: /etc/apache2/apache2.conf
save and restart apache2 with: service apache2 restart
Now http://localhost/phpmyadmin should work

Clément Aymé -> Echo Mgm

Or try to reinstall it. This works for me:

apt install --reinstall phpmyadmin

Michael Fristedt

Works like a charm for me! Thanks for a good guide!

Guadefocus magapó

I tried updating from php5 and also formatting and installing php7 from zero, on my raspberrypi.
No one worked logging mysql.

After php 7, mysql was deprecated, and now is ussing mariadb by default.
When logging by “–skip-grant-tables” mode, after updating root password, not working again after setting new password.

While --skip-grant-tables is enabled, no one can set permissions…
Ever same problem in loop.

Nenyer Atencio

I followed the instructions and the php does not work for me. I have Debian 9.

Clément Aymé -> Nenyer Atencio

Try to reinsttall. It was the case for me.

apt install --reinstall php7.0 php7.0-mysq
apt install --reinstall apache2 apache2-mod-php7.0

sebastien -> Clément Aymé

great thanks


In my case installation process don’t prompted to create a root password for MariaDB

Anush Priyesus -> dark_diesel

mysql_secure_installation will work…

Mauro Valvano -> dark_diesel

Me too, you must access with ‘root’ and empty password and then you can create a new user.

Wael Mejdoub

Thanks , That’s working

Gandalf life

Hey there ! Dunno if I can help but on my machine (VPS SSD debian 9 from ovh) :
-Php is not executed (it’s maybe missing something like php7.0-fpm but as i’m not that good, i have no idea about that).
-Secondary, you have to ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin so it has a shortcut for phpmyadmin.

As i have no idea how to fix these issues, i can’t go farther to try this. Peace and thanks for this introduction to debian 9 :stuck_out_tongue:

SKITZO -> Gandalf life

I did the shortcut and than this, and then it started working.

“sudo nano etc/apache2/apache2.conf”
Then add the following line to the end of the file.

“Include /etc/phpmyadmin/apache.conf”
Then restart apache

“/etc/init.d/apache2 restart”

Nicolas Voulgaris

I have a problem with the installation of phpmyadmin, nothing is created inside /var/www.
Therefore nothing appears when I go to MyServerIP/phpmyadmin

Do you have a solution ?