Comments on Ubuntu 16.04 (LTS) LAMP server tutorial with Apache, PHP 7, and MySQL
LAMP is short for Linux, Apache, MySQL, PHP. This tutorial shows how you can install an Apache 2.4 web server on an Ubuntu 16.04 (Xenial Xerus) server with PHP 7 support (mod_php) and MySQL / MariaDB and how to setup an SSL certificate with Let's encrypt. Additionally, I will install PHPMyAdmin to make MySQL administration easier. A LAMP setup is a perfect basis for CMS systems like Joomla, Wordpress or Drupal.
163 Comment(s)
Comments
Thank you so much. Works perfectly.
Nice work, complete and worked perfectly first time.
excellent work thanks
WWWonderfuull!!!! :-)
hello thanks for your tuto its works without problems thanks for the time spent by writting it its help someone like me
Thank you very much! Vielen Dank für Ihre Hilfe!
Thank you to you for this tutorial which is very easy to use.Unfortunately, I get an error in the last step, after the installation of phpMyAdmin:The requested URL /phpmyadmin/ was not found on this server.
The same error with 127.0.1/phpmyadmin or localhost/phpmyadmin.
I tried 3 times to uninstall and reinstall without success.Pity that Ubuntu does not offer a LAMP package !
Best regards
Try to run:
dpkg-reconfigure phpmyadmin
and ensure that you select apache2 as config option. If no webserver config option is selected during phpmyadmin installation, then the alias to accessphpmyadmin does not get added to the apache config.
Hi
You probably missed the fact that you need to put a mark in the selection of apache2 in the config. It definitely looks like it's selected it when the red box is in the selection thing, but unless you press space it won't mark it as selected and it won't configure it it for apache. Hope that makes sense?!
Cheers
Gareth
Hi this work's for me,
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled/phpmyadmin.conf
the solution comes from here: https://www.digitalocean.com/community/questions/i-cannot-access-phpmyadmin-on-ubuntu-14-04
Followed the instructions with 16_04 and everything worked great up to phpMyAdmin.
I get the message:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using ? password: NO)
Uninstalled and tried again.
Still at a loss????
Other Ubuntu forum posts were for password: YES.
What should I check to solve this?
I encountered the same issue, did you find a solution?
Also having this issue!
try this http://askubuntu.com/a/763359
Use this
dpkg-reconfigure phpmyadmin
This is used for reconfiguring phpmyadmin, while reconfiguring it will ask you for a username and password. This will be used for logging in.
This Works for me, only in the reconfigure question :
Configure database for phpmyadmin with dbconfig-common? <-- No
And it Phpmyadmin works with the MariaDB user and password.
Try this. Fixed my issue in Ubuntu 16.10
http://askubuntu.com/questions/387062/how-to-solve-the-phpmyadmin-not-found-issue-after-upgrading-php-and-apache
Installing APCu is not necessary.
As it states on http://php.net/manual/en/intro.apcu.php: "APCu is APC stripped of opcode caching."
And that's exactly why we install APCu. For Opcode caching, we have already "Opcache" installed. But many software relies on the APC specific caching functions e.g. as a page cache and that's why we install APCu on top of Opcache, it adds the APC functions to PHP when Opcache is installed.
But in the article you wrote: "APCu is a free PHP opcode cacher for caching and optimizing PHP intermediate code. It is strongly recommended to have an Opcache installed to speed up your PHP page."
Which IMHO is not true.
Did you ever benchmark PHP without an opcode cache (and yes, the Opcache extension in PHP 7 is also an opcode cache, so disable it when you want to test without an opcache) with a PHP version that runs an Opcode cache? And if yes, did you do that in real life scenarios like a WordPress website with caching plugins enabled? I did that for different PHP versions and that's why I recommend to install it. But you don't have to believe me of course, leave it out, your server will work without it. As a side note, many caching plugins in websites recognize APC and use its specific functions as internal cache, APCu emulates this for newer PHP versions, so just installing opcache without APCu will not make these options available for your site.
I think we all agree that opcode caches are great. The thing DSmidge pointed out is: "APCu is APC stripped of opcode caching." and I said that this page claims "APCu is a free PHP opcode cacher".
Thank you for the Tutorial! It is very awesome.
On Unbuntu 16.04 i get a failure message in /var/syslog if i take a closer look.
It seems that setting a secure password for root user will do create problems with mysqlcheck because the password ist not updated in /etc/mysql/debian.cnf
For details see:
http://askubuntu.com/questions/772785/16-04-mariadb-error-in-syslog-mysqlcheck
Thanks a lot spent hours trying to get my lamp running. I used mysql though :)
Thanks, this helped getting my new dev server up and running :)
I wonder if you can help. I have followed all you tutorial which is well presented. but I cannot access phpmyadmin. I also did not know where to add the last line in you tutorial about unix_socket.
i have reinstalled the phpmyadmin and ensure apache2 is the server to use. i have checked and included the following line to apache2.conf
Include /etc/phpmyadmin/apache.conf
but still no access. any help would be great thankyou
Thank you so much for this pice of cake!
Hi
I managed to install everything fine butwhen I tried to run info.php I got the following message:
ForbiddenYou don't have permission to access / on this server.
Apache/2.4.18 (Ubuntu) Server at localhost Port 80 Here are the document root file permissions:root@Satellite-C660:/var/www/html# ls -ltotal 16-rw-r--r-- 1 root root 11321 May 20 00:56 index.html-rw-r--r-- 1 www-data www-data 35 May 20 01:55 info.phproot@Satellite-C660:/var/www/html#
Amazing! Thank you for this great tutorial.
excellent work thanks!
It says "ERROR 1046(3D000) at line 1: No database selected"
Not Found
The requested URL /phpmyadmin was not found on this server.
Apache/2.4.18 (Ubuntu) Server at localhost Port 80 i have a problem to access on phpmyadmin i don't know why, i've followed perfectly this tuto, please could you help me?You missed to enable phpmyadmin for apache (as described in the tutorail). You can redo the step by running:
dpkg-reconfigure phpmyadmin
then ensure that apache 2 is selected, there must show a cross for the apache option which gets enabled with the whitespace key of your keyboard. If no cross is shown there, then apache is not active for phpmyadmin and you wont be able to reach it then!
Hi,
Thanks, but Apache 2.4 is valuable with the event module enabled, and ISPConfig won't work with it - it insists on using morker right? Can't you change this so we can use the much better event, please? Thanks
ISPConfig does not depend on a specific apache mode, you just will not be able to use the mod_php mode in ispconfig in worker mode.
Thank you for this great tutorial! Everything works perfect but phpmyadmin. I got:
"Not FoundThe requested URL /phpmyadmin was not found on this server.Apache/2.4.18 (Ubuntu) Server at 104.154.46.68 Port 80"
Could you help me? Any idea? Thanks.
Solved "The requested URL /phpmyadmin/ was not found on this server." :
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
sudo service apache2 restart
Você é o melhor perfeito funcionando redondo.
Obrigado
At last, thanks...
Muitissimo obrigado.
thx!!!
Vielen Dank für dieses Howto. Es hat mir sehr geholfen, da ich wirklich Probleme hatte phpmyadmin zum laufen zu kriegen. Aber nun ist wieder alles so wie sein soll
Many thanks
wolfgang
Thank you this howto is perfect. I used it on Linux Mint 18
greets wolfgang
muchas gracias después de estar buscando como un loco y no poder andar el phpmyadmin, parece ser que por este método no da problemas.
solo quedaría para terminar tu tutorial agregar al final
/etc/apache2/apache2.conf agregando: Include /etc/phpmyadmin/apache.conf
para que funcione phpmyadmin
y nada mas. muy buen tutorial
Excellent guide, thank you very much!
Just one remark, with a local install on Xubuntu the address 192.168.1.100 does not work, but http://localhost does (and consequently localhost/info.php and localhost/phpmyadmin)
Suggestion: tell the user that the inlog name for the phpmyadmin page is root and the password is the one for MariaDB. That was not clear to me at first sight, because we just installed several software packages!
Thanks again for your work,
Paul.
Thanks for this comment Paul, it didn't work on 16.04 until I typed this. Just not sure how to interpret your fix for this.
Whole installation went fine except as others I had issues with the phpmyadmin install: The requested URL /phpmyadmin/ was not found on this server.
It was the firewall with me the command to fix was sudo ufw allow in "Apache Full"
Supppper!
Hello Guys,
Everything works except the https: (SSL) not sure why I followed it to the letter, I will be troubleshooting until I figure it out.
Thanks,
Thanks
Nice tutorial, thanks ^_^
Thank you mate for this post.... I upgraded my system to Mint 18 and had some buggs. after reviewing this post, it has solved the issue I had.
I have followed your instruction, and rechecked all, but can not get any responce for info.php...All I get is a blank page...I have the ports 80 and 443 open in firewalld...Hope you can help.
thanks very mych , it makes work easily!!
Impeccabile, installazione perfetta, semplice e funzionale
Grazie per il VS ottimo lavoro
Very nice article, works perfectly :)
Perfect Tutorial , Thanks!!!
Flawless Victory!
Thanks so much. This has helped me a lot!
It works fine!
Excelente post. todo funciona casi a la perfeccion, me gusto la colaboracion colocada, me falta hace multiple dominios para diferentes hosting hay ire dandome golpes de pecho.!
wow. it's work ! thanks so much
muy valiosa la información, gracias por este aporte
Thank you!!
Tnx for a very detailed STEPS: just need help
: I got everything done, but I just got some few errors:
1. root@home:/home/hive# a2ensite dafault-ssl ERROR: Site dafault-ssl does not exist!
- https not working
2. "Connection for controluser as defined in your configuration failed."
This is really gtate tutorial - the that you can folow and it works.
Even I had an issues with phpmyadmin, but was able quicly to fix it with
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf sudo a2enconf phpmyadmin.conf sudo service apache2 reloadIf I may request to make a tutoreal or just explain (anyone) how to "Install PHP 7 with zts."
I'm really having a hard time to find any information about it.
I need ZTS for "pecl install pthreads".
This is really gtate tutorial - the that you can folow and it works.
Even I had an issues with phpmyadmin, but was able quicly to fix it with
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf sudo a2enconf phpmyadmin.conf sudo service apache2 reloadIf I may request to make a tutoreal or just explain (anyone) how to "Install PHP 7 with zts."
I'm really having a hard time to find any information about it.
I need ZTS for "pecl install pthreads".
This is really great tutorial - the that you can follow and it works.
Even I had an issue with phpmyadmin, but was able quickly to fix it with
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf sudo a2enconf phpmyadmin.conf sudo service apache2 reloadIf I may request to make a tutoreal or just explain (anyone) how to "Install PHP 7 with zts."
I'm really having a hard time to find any information about it.
I need ZTS for "pecl install pthreads".
Wonderfull Document... helped me a lot....
Only one issue faced: phpmyadmin is not working after I installed it . I did following and its woked like a charm!!!..
vi /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
It is possible add SpeedPage module to this configuration, and this is convenient?Thank you so much!.
so where do i find the bind-address so I can let my remote server connect to the database? can this be done in phpmyadmin?
Excellent tutorial. Did the install in less than 10 mins.
Danke
Excellent! Thanks!
Thank you for your great article, helped me to a lot. Now I have a fast development computer.
In my case http://localhost worked instead of IP address, and I also get an 404 Error on phpmyadmin but as Carlos Guena suggested, this three line of command solved the problem:
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.confln -s /usr/share/phpmyadmin /var/www/html/phpmyadminservice apache2 restart
Thanks! You are man!
OMG! Perfectly Documented! Thanks a lot!
I receive an error message when trying to access 192.168.0.230/php.info, the browser will not access the page. What am I doing wrong?
I am having issues accessing php.info and the echo command involving disabling the unix_socket. It is showing an issue with the word priviledges.
Absolutely perfect and just what I was looking for.
Much easier than most other websites that take you through convulted twists and turns to get this to work.
Still having issues with php.info but figured out unix_socket. Whenever I try to access phpmyadmin I get nothing but a bunch of text. Why does it appear I'm getting code and not phpmyadmin?
It Works perfectly thanks..
Excellent tutorial bro, It works!
Thanks for this excellent article.
And it works very well
Thank you so much. Works perfectly....
Buen tutorial funciona perfectamente ... muchas gracias
Great tutorial, thank you. I did get stuck trying to log in to phpMyAdmin however the comment from till was spot on. It might be worth editing the guide to ensure a password is entered and not randomly generated or add a section for adding a mysql user to avoid being locked out of mysql completely.
Thank you very much , awesome tutorial great job
Just a not that these directions also work well on 16-10!
The title says that this tutorial is for 16.04 and not for Ubuntu 16.10. But I'm sure that howtoforge will post a tutorial for 16.10 soon as usual. For servers it is better to use a LTS version like Ubuntu 16.04 anyway.
Hi,
the new package names are:
php7.0-memcached instead of php-memcache (btw: the d is missing in the statement above)
php7.0-imagick instead of php-imagick
thanks for this very well tutorial!
regards, Kasalop
Great tutorial, if someone would make a script for this, it would be amazing! And just a note about the last part of the tutorial - phpmyadmin. If you cant reach the phpmyadmin after you've done all the steps, then you should add Include /etc/phpmyadmin/apache.conf to the /etc/apache2/apache2.conf file and restart the service.
Thank you so much. Clearly explained.
I had so many issues, untill I came accross this, worked flawlessly. Thank you for making the world a better place!
I have followed your instructions, but after:
> Now we set a root password for MariaDB.
mysql_secure_installation
> You will be asked these questions:
> Enter current password for root (enter for none): <-- press enter
I can't set a root password. After pressing enter it says:
> Access denied for user 'root'@'localhost' (using password: NO)
So I can't make changes.
Can anyone help?
Thank you, all steps worked perfectly.
Thank you so much for this tutorial.
I have been using it on several servers, and it worked every time.
Great manual.
One of the few manuals where everything works as explained.And where the explanations is complete! Fantastic job.
1 improvement : to lging in phpadmin : to use the username root
Great tutorial. I too had the issue where phpmyadmin wasn't found, but going through the comments helped me resolve. I swear it "looks" like apache2 is selected. Pressing the spacebar showed my what I was missing. Thanks everyone, and once again, thanks for a great tutorial !
Excellent!!!
hi,
i'm work whith ubuntu server 16.10 and I have problems when I want to login to phpmyadmin I get that the page was not found
what can i do?
please help
Great guide! Got everything set up in less than 10 mins. THANK YOU!
In 10 years of bullshit, this is one of the most well written tutorial.
Good job bro!!
Probably not the best solution but it worked for me..
I removed the root password,
SET PASSWORD FOR root@localhost=PASSWORD('');dpkg-reconfigure phpmyadmin
then reset the root password.
Execellent tutoriual!!!
Only is necessary to add the simbolic link from phpmyadmin to apache2
sudo /etc/init.d/apache2 reload
Thanks you
Thank you very much for this tutorial and some time we can't goto the phpmyadmin so have to create a link
sudo ln -s /usr/share/phpmyadmin /var/www/html/
I'll cite the comment from Gareth which explains what you did wrong during installation:
Hi
You probably missed the fact that you need to put a mark in the selection of apache2 in the config. It definitely looks like it's selected it when the red box is in the selection thing, but unless you press space it won't mark it as selected and it won't configure it it for apache. Hope that makes sense?!
Cheers
Gareth
Such a nice job.
Thanks so much
Best tutorial i ever read
Very clear and precise - terminal commands worked perfect
Hope loading Wordpress goes as smooth
Thank you
Very useful!! Congra.! . I had a problem after installed phpmyadmin and I solved with the following command: sudo ln -s /usr/share/phpmyadmin/ /var/www/html/phpmyadmin
This has been explained several times in the comments, you missed to enable the apache option during PHPMyAdmin install when the PHPMyAdmin installer asked for which server the program shall be enabled (as explained in the tutorial).
Thanks Sidi4. You're a god among men. May your days be long.
Gracias
Had an issue with 404 error trying to connect to phpmyadmin. Was fixed with a symlink:
ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
after that it worked but I am not sure if this would be considered best practice or if there is a better way to fix the issue.
Really you saved my day. Thanks mam. I love you. May Allah be with you. :)
Hi, This is my first time using linux. when following your tutorial (which is great btw) I have noticed that when you open up info.php for the first time you have a gui type interface. I am only getting a txt read out. I have tried googling the issue but It must be something basic ive missed becuase I can't find anything close to an answer. any help would be great. thanks
Thanks very much, it works great...
Gracias por tu aporte, por los paquetes actualizados que manejas....espero publiques mas articulos sobre linux...me fue de gran utilidad...thanks
Thanks, It works, thanks for sharing
Thanks, it works like a charm!
Thanks :)
After installing phpmyadmin i get 404.Solution:$ nano /etc/apache2/apache2.conf and add this line:
Include /etc/phpmyadmin/apache.confI must say - PERFECT, thanks a lot.
Hello very good description, thank you.
Is it possible to extend this description about to: How can use virtual hosts by using Lets Encrypt to set up multiple web pages, such as Joomla and Wordpress on the same Webserver?
That would be great.
Thank You
It s a wonderful article for us that we are trying to start with ubuntu!
Everything went well up to point 9.1
I can't get the root acces to work. And when I'm logged in phpmyadmin I've got no privileges to create a DB.
Ideas anyone?
Geat Job.Thanks so much.
Excelente!!!
Awesome tutuorial
Where can I get the virtual machine image of this?
The download link is in the upper right menu.
Such a great tutorial. Thank you for such clear instructions!
I did have an issue accessing phpmyadmin but http://askubuntu.com/questions/387062/how-to-solve-the-phpmyadmin-not-found-issue-after-upgrading-php-and-apache from comments fixed that.
Thanks again!
Thank you! It works like a charm!
Cool work....... everything works like a charme....
many thanks for your help
This was a fantastic tutorial. Thank you for you time and effor it took to get this up!!!
My system is working fantastic now.
Thank you
Great work man...thanks and keep going!!
How can I remove everything and start over the entire process?
Brilliant tutorial! The only missing thing is in section 8 right after installing a certificate, one have to restart service in order to be able to see with browser successfully SSLized ubuntu default page. The rest is just awesome piece of work and helps flawlessly install everything. Many thanks!
Thank you for this great detaild step by step, this is my first time to config a server, and it really reall helped alot
Thanks again
,
Amr
I have followed this tutuorial and get this error message after completing step 4
Error establishing a database connection (http://localhost/index.php)I'm trying to setup an LAMP environment to view websites I built that are no longer online
I'm on Peppermintos 4.4.0-97-generic
It works!
PERFECT! NICE!
Good ... How are you where I can download the virtual machine?
Thank you so much
regards
By clicking on the download link right below the big red download icon in the menu, left side at the top.
QUALITY MY SON
Can we directly proceed with step 1.2?
Thanks mate, very helpful and very well explained ;)
Excelente documentación. Agradecido contigo. ¡Saludos!
Inciiailmente parece muito bom! Obrigado!!
Always the best tutorials. I just did this on Ubuntu 17.10 and the only change I needed to make was changing the php version from 7.0 to 7.1. Thanks for the hard work.
Perfect! thank you so much
Simplemente perfecto. Sencillo y muy bien explicado. Gracias!!
Se deben añadir permisos a /var/www/html
sudo chown root:root -R /var/www/sudo chmod 777 -R /var/www/
Gracias de nuevo
Hi, I need change the default port for MySQL or MariaDB, how to this change, I try editing /etc/mysql/my.cnf but no view the options.
Wow bro well done well done ,perfect work works without a glich :)
I followed your tutorial and i get the following error when i want to get the certificate from letsencrypt:
Client does not support any combination of challenges that will satisfy the CA.
Can you help me please?
Thanks in advance,Yuri Madou
Excellent tutorial, clear, tested and that works the first time. Many thanks
THANK YOU! You guys saved my life. I was getting PDOException error and I figured out that nothing I had done worked, so I followed your tutorial and instead of mariaDB I used mySql. Works like a charm! Lov ya
Thanks a lot , Its works perfectly on ubuntu 16.04 LTS.One of the best article in the internet !!!
how can i do this with the DB server is separate from the rest of them? how is the configuration?
Use these commands:
sudo mysql -p -u root
SET GLOBAL validate_password_policy = 0;//where always be ignored.
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'howtoforge';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
Clear and precise instructions, works perfectly from start to end! I got HTTPS:// working. Many thanks!
Thanx man been stuck in for a while serving the data from db using php. This tutorila helped a lot....Appreciated
how did you get the HTTPS:// working ?
How I can get ready to use a virtual machine image for ubuntu?
The download link is in the menu on the right side of the page, near the top, right below the big red download icon.
Gracias super claro...!