DeveloperBreeze

How to Install PHP, MySQL, and phpMyAdmin on Ubuntu 25.04 (LAMP Stack Setup Guide)

Step 1: Update Package Index

Begin by updating your package index to ensure you have the latest information on available packages:

sudo apt update

Step 2: Install PHP and Required Extensions

Ubuntu 25.04 includes PHP 8.3 in its official repositories. Install PHP along with commonly used extensions for Laravel:

sudo apt install php php-cli php-mbstring php-xml php-bcmath php-curl php-mysql php-zip php-gd php-fpm unzip

Verify the PHP installation:

php -v

Step 3: Install MySQL Server

Install the MySQL server package:

sudo apt install mysql-server

Secure your MySQL installation:

sudo mysql_secure_installation

This script will prompt you to set a root password, remove anonymous users, disallow remote root login, remove the test database, and reload privilege tables.


Step 4: Install phpMyAdmin

Install phpMyAdmin along with necessary PHP extensions:

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

During installation:

  • When prompted to choose a web server, select apache2.
  • Choose Yes when asked to configure the database for phpMyAdmin with dbconfig-common.
  • Set a password for the phpMyAdmin application.

Enable the mbstring PHP extension and restart Apache:

sudo phpenmod mbstring
sudo systemctl restart apache2

You can now access phpMyAdmin at http://localhost/phpmyadmin.


Step 5: Configure Apache (Optional)

If you're using Apache and want to set up a virtual host for your Laravel application:

  1. Create a new configuration file:
   sudo nano /etc/apache2/sites-available/your_domain.conf
  1. Add the following configuration, replacing your_domain and the document root path as appropriate:
   <VirtualHost *:80>
       ServerName your_domain
       DocumentRoot /path/to/your/laravel/public

       <Directory /path/to/your/laravel/public>
           AllowOverride All
           Require all granted
       </Directory>

       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
   </VirtualHost>
  1. Enable the new site and the rewrite module:
   sudo a2ensite your_domain.conf
   sudo a2enmod rewrite
   sudo systemctl restart apache2

Step 6: Install Composer (PHP Dependency Manager)

Composer is essential for managing PHP dependencies:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
composer --version

Step 7: Add Composer to PATH (Optional)

If you're installing global Composer packages:

Add this line to your ~/.bashrc or ~/.zshrc file:

export PATH="$HOME/.config/composer/vendor/bin:$PATH"

Then reload your shell configuration:

source ~/.bashrc

Related Posts

More content you might like

Tutorial

ما هو حقن التبعيات (Dependency Injection)؟

وهي الطريقة الأكثر شيوعاً، حيث تُمرَّر التبعيات للكائن عبر المُنشئ.

مثال بسيط بلغة PHP:

Dec 01, 2025
Read More
Article

أفضل طرق إزالة الصدأ من العدّة والمسامير – دليل شامل منزلي واحترافي

  • يتم توصيل المسامير بالقطب السالب (Cathode).
  • توضع قطعة حديد قديمة كأنود (Anode) في الجهة المقابلة.
  • يتم تمرير تيار كهربائي منخفض الجهد، فيتحول الصدأ إلى رواسب تنفصل عن السطح.
  • قطعة شبكة سلك معدني (Wire Mesh).
  • تشكيلها على هيئة "سلة" أو مصفاة صغيرة.
  • توصيل القطب السالب للسلة نفسها.
  • وضع المسامير داخلها.

Dec 01, 2025
Read More
Tutorial

How to Stop SSH From Timing Out

Add these lines:

ClientAliveInterval 60
ClientAliveCountMax 3

Aug 21, 2025
Read More
Tutorial

How to Translate URLs in React (2025 Guide)

Translating URLs in React improves both UX and SEO, especially in 2025 where Google increasingly favors language-aware URLs over query parameters like ?lang=fr.

With this setup, your app can:

May 04, 2025
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!