✅ 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:
- Create a new configuration file:
sudo nano /etc/apache2/sites-available/your_domain.conf
- 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>
- 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