HomeAboutContact
Book Consultation

Enterprise AI integration and software delivery for teams that need velocity without compromising security, compliance, or craft.

inquiries@advantageaieng.com

Services

  • AI & Automation
  • Product Engineering
  • Cloud & DevOps
  • Security

Company

  • About
  • Contact
  • Blog
  • FAQ

© 2026 Advantage AI Engineering Private Limited. All rights reserved.

Privacy Policy·Terms & Conditions
All posts

DevOps

How To Install Apache, MySQL, PHP & Composer On Ubuntu

Advantage AI Engineering · May 1, 2026 · 10 min read

How To Install Apache, MySQL, PHP & Composer On Ubuntu

Install the classic LAMP-style stack on Ubuntu: Apache as the web server, MySQL for data, PHP with common extensions, and Composer for dependency management.

This guide walks through Apache, MySQL, PHP, and Composer on Ubuntu using apt. Run commands step by step; the first time you use sudo in a session you may be asked for your password so only privileged users can change system packages.

Step 1: Installing Apache

Refresh the package index, then install Apache:

sudo apt update
sudo apt install apache2

After installation, open http://localhost (or your server IP) in a browser. You should see the Apache default page—your web server is running and reachable (ensure your firewall allows HTTP/HTTPS if you access it remotely).

Step 2: Installing MySQL

sudo apt install mysql-server
sudo mysql

In the MySQL prompt, set a root password and authentication (replace the example password with a long, unique password you store safely):

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
exit

Then you can log in from the shell with: mysql -u root -p (enter the password when prompted). Newer MySQL versions may use different default authentication plugins—if the ALTER line fails, check the MySQL 8.x docs for your exact release.

Step 3: Installing PHP

Apache serves your site, MySQL stores data, and PHP generates dynamic content. You need PHP, the MySQL driver for PHP, and Apache’s PHP module so .php files are executed by the web server. Core PHP packages are pulled in as dependencies.

sudo apt install php libapache2-mod-php php-mysql

When installation finishes, confirm the PHP version:

php -v

You can install many useful extensions in one go. Adjust the version (8.3 here) to match your installed PHP:

sudo apt-get install -y php8.3-cli php8.3-common php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php8.3-bcmath

Step 4: Setting up Composer

Composer is PHP’s dependency manager: you declare the libraries your project needs, and it installs and updates them. Download the official installer, verify it, and install the composer binary to /usr/local/bin:

curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
HASH=$(curl -sS https://composer.github.io/installer.sig)
echo $HASH
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); } echo PHP_EOL;"
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer

Test the installation:

composer

You should see Composer’s version and command list. For the latest verification steps, see getcomposer.org if installer signatures change.

Related

  • Exploring PHP: Powering Dynamic Websites with Ease — Part 3
  • Exploring PHP: Powering Dynamic Websites with Ease — Part 2