VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-install-lamp-stack-on-ubuntu?comment=212112

⇱ How To Install LAMP Stack (Apache, MySQL, PHP) on Ubuntu | DigitalOcean


How To Install LAMP Stack (Apache, MySQL, PHP) on Ubuntu

Updated on March 18, 2026
πŸ‘ How To Install LAMP Stack (Apache, MySQL, PHP) on Ubuntu

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Followed the guide step by step but I’m getting an error connecting to the database:

root@c0605c27b55d:/var/www/html# curl localhost/todo_list.php
Error!: SQLSTATE[HY000] [2002] Permission denied<br/>

Could this be because I’m running Ubuntu in Docker?

I wasn’t able to login to mysql with sudo mysql after running ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

I fixed this by logging it with mysql -p, then running ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;. I did this after running the mysql_secure_installation script.

If you receive a Status: inactive message after the sudo ufw status THEN USE THIS COMMAND sudo ufw enable


PHP 8.3 php.watch/articles/php-8.3-install-upgrade-on-debian-ubuntu#php83-ubuntu-quick

Save existing php package list to packages.txt file

sudo dpkg -l | grep php | tee packages.txt

Add Ondrej’s PPA sudo add-apt-repository ppa:ondrej/php Press enter when prompted.

sudo apt update

Install new PHP 8.3 packages

sudo apt install php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl,cli,mysql,zip,gd,xml,bcmath,opcache,pgsql,readline,soap}

Install FPM OR Apache module

sudo apt install php8.3-fpm

On Apache: Enable PHP 8.3 FPM

sudo a2enconf php8.3-fpm

When upgrading from an older PHP version:

sudo a2disconf php8.2-fpm

Remove old packages

sudo apt purge php8.2*

Seems to be a LOT of steps missing from the mysql installation - Now I have access denied

πŸ‘ Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow β€” whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Β© 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.