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)؟

يمكن تعديل أو استبدال أي تبعية دون تغيير الكائن الرئيسي، مما يجعل الكود أسهل في التطوير على المدى الطويل.

توجد ثلاث طرق رئيسية لحقن التبعيات:

Dec 01, 2025
Read More
Article

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

سواء كنت تريد تنظيف عدة يدويّة مصدّأة في المنزل أو لديك مئات المسامير تحتاج معالجة بالجملة، هناك طرق موثوقة لإزالة الصدأ بفاعلية:

  • للاستخدام المنزلي: الخل، الملح والليمون، صودا الخبز، أو الصنفرة.
  • للاستخدام الاحترافي والكميات الكبيرة: التحليل الكهربائي باستخدام شبكة سلك، طبق ستانلس، أو سلك تجميعي.

Dec 01, 2025
Read More
Tutorial

How to Stop SSH From Timing Out

sudo nano /etc/ssh/sshd_config

Add these lines:

Aug 21, 2025
Read More
Tutorial

How to Translate URLs in React (2025 Guide)

{
  "routes": {
    "home": "accueil",
    "about": "a-propos"
  },
  "title": "Bienvenue sur notre site !"
}

Create routes.js:

May 04, 2025
Read More

Discussion 0

Please sign in to join the discussion.

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