Best Cosmetic Hospitals Near You

Compare top cosmetic hospitals, aesthetic clinics & beauty treatments by city.

Trusted • Verified • Best-in-Class Care

Explore Best Hospitals

Step-by-Step Guide to Fix PHP 8.2 & Missing Extensions Error

Below is a Complete Guide to fix your PHP 8.2 missing error (Unable to locate package) and properly install PHP 8.2, required extensions, and Composer for your Laravel project on Ubuntu/Linux Server. This will also help you avoid the “mbstring extension is missing” error in Composer.


Error:

root@ip-111-20-60-60:/opt/lampp/htdocs# sudo apt install php8.2-cli php8.2-mbstring php8.2-xml
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package php8.2-cli
E: Couldn't find any package by glob 'php8.2-cli'
E: Unable to locate package php8.2-mbstring
E: Couldn't find any package by glob 'php8.2-mbstring'
E: Unable to locate package php8.2-xml
E: Couldn't find any package by glob 'php8.2-xml'

✅ Step-by-Step Guide to Fix PHP 8.2 & Missing Extensions Error


⚠️ Why This Error Happens

Ubuntu’s default package repositories often do not include PHP 8.2, especially on older versions of Ubuntu (20.04, 22.04). To get PHP 8.2, you need to add a special PHP PPA (Personal Package Archive) maintained by Ondřej Surý, a trusted PHP package maintainer.


📖 Step 1 – Add the PHP PPA (Trusted Source)

Run the following commands to add the PPA that contains PHP 8.2 packages.

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

📖 Step 2 – Install PHP 8.2 and Required Extensions

Once the PPA is added, you can install PHP 8.2 and all the necessary extensions.

sudo apt install php8.2-cli php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip unzip curl

Explanation

  • php8.2-cli – Command Line PHP (for running php commands)
  • php8.2-mbstring – Required by Laravel and Composer
  • php8.2-xml – Required for parsing XML files
  • php8.2-curl – Required for downloading packages
  • php8.2-zip – Required for extracting Laravel packages
  • unzip – Needed for Composer
  • curl – Needed to download Composer

📖 Step 3 – Verify PHP Installation

To confirm PHP 8.2 is installed, run:

php -v

You should see output like:

PHP 8.2.x (cli) (built: ...)

📖 Step 4 – Install Composer (Globally)

Download and install Composer (works with system PHP 8.2).

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

Verify Composer is working:

composer --version

You should see:

Composer version 2.x.x

📖 Step 5 – Use System PHP for Composer in Your Laravel Project

If your project is inside /opt/lampp/htdocs (XAMPP directory), you need to tell Composer to use system PHP (not XAMPP’s PHP).

To install Laravel dependencies:

cd /opt/lampp/htdocs/your-laravel-project
/usr/bin/php /usr/local/bin/composer install

This ensures system PHP 8.2 (with all extensions) is used instead of XAMPP’s PHP.


📖 Step 6 (Optional) – Make System PHP Default (If You Want)

If you want to make system PHP 8.2 the default PHP everywhere, you can change the $PATH in your user profile.

Edit your .bashrc file:

nano ~/.bashrc

Add this at the end:

export PATH=/usr/bin:$PATH

Save and reload:

source ~/.bashrc

This will ensure running php always uses system PHP 8.2, not XAMPP PHP.


🔔 Why This is Recommended

  • System PHP is better for CLI work (Composer, Artisan commands).
  • XAMPP PHP is often missing important extensions like mbstring, iconv, etc.
  • System PHP gets regular security updates via apt update.

Complete Command Summary

# 1. Update system and add PHP PPA
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

# 2. Install PHP 8.2 and required extensions
sudo apt install php8.2-cli php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip unzip curl

# 3. Verify PHP
php -v

# 4. Install Composer globally
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

# 5. Check Composer
composer --version

# 6. Run Composer in Laravel project using system PHP
cd /opt/lampp/htdocs/your-laravel-project
/usr/bin/php /usr/local/bin/composer install

🚀 You’re Ready to Use Laravel!

Best Cardiac Hospitals Near You

Discover top heart hospitals, cardiology centers & cardiac care services by city.

Advanced Heart Care • Trusted Hospitals • Expert Teams

View Best Hospitals
<p data-start="140" data-end="435">I’m Abhishek, a DevOps, SRE, DevSecOps, and Cloud expert with a passion for sharing knowledge and real-world experiences. I’ve had the opportunity to work with <a class="decorated-link" href="https://www.cotocus.com/" target="_new" rel="noopener" data-start="300" data-end="335">Cotocus</a> and continue to contribute to multiple platforms where I share insights across different domains:</p> <ul data-start="437" data-end="922"> <li data-start="437" data-end="514"> <p data-start="439" data-end="514"><a class="decorated-link" href="https://www.devopsschool.com/" target="_new" rel="noopener" data-start="439" data-end="485">DevOps School</a> – Tech blogs and tutorials</p> </li> <li data-start="515" data-end="599"> <p data-start="517" data-end="599"><a class="decorated-link" href="https://www.holidaylandmark.com/" target="_new" rel="noopener" data-start="517" data-end="569">Holiday Landmark</a> – Travel stories and guides</p> </li> <li data-start="600" data-end="684"> <p data-start="602" data-end="684"><a class="decorated-link" href="https://www.stocksmantra.in/" target="_new" rel="noopener" data-start="602" data-end="647">Stocks Mantra</a> – Stock market strategies and tips</p> </li> <li data-start="685" data-end="764"> <p data-start="687" data-end="764"><a class="decorated-link" href="https://www.mymedicplus.com/" target="_new" rel="noopener" data-start="687" data-end="732">My Medic Plus</a> – Health and fitness guidance</p> </li> <li data-start="765" data-end="841"> <p data-start="767" data-end="841"><a class="decorated-link" href="https://www.truereviewnow.com/" target="_new" rel="noopener" data-start="767" data-end="814">TrueReviewNow</a> – Honest product reviews</p> </li> <li data-start="842" data-end="922"> <p data-start="844" data-end="922"><a class="decorated-link" href="https://www.wizbrand.com/" target="_new" rel="noopener" data-start="844" data-end="881">Wizbrand</a> – SEO and digital tools for businesses</p> </li> </ul> <p data-start="924" data-end="1021">I’m also exploring the fascinating world of <a class="decorated-link" href="https://www.quantumuting.com/" target="_new" rel="noopener" data-start="968" data-end="1018">Quantum Computing</a>.</p>

Related Posts

SCMGalaxy OS for Consultants: How to Generate DevOps Assessment Reports and Transformation Roadmaps

Consultants are often brought into organizations when software delivery is already under pressure. Releases are slow.Deployments are risky.CI/CD pipelines are inconsistent.Security findings appear late.Kubernetes adoption is messy.Developers…

Read More

DevOps Consultants Optimize Deployment Pipelines for Maximum Efficiency

Introduction In today’s fast-paced digital market, the ability to release software reliably and at speed is a primary competitive advantage, yet many organizations remain trapped by brittle,…

Read More

Essential DevOps Consulting Practices for Securing Your CI/CD

Introduction In the modern era of rapid digital transformation, the CI/CD pipeline has become the essential backbone of software delivery, enabling organizations to iterate and deploy at…

Read More

The Guide to Modern CI/CD Pipeline Optimization

Introduction In today’s fast-paced digital market, the speed and reliability of your software delivery are primary drivers of business success, yet many organizations remain hindered by manual,…

Read More

The Ultimate Guide to Stock Market Education for Beginners

The pursuit of financial independence has evolved significantly over the past few decades. Where traditional savings accounts once served as the primary vehicle for wealth preservation, today’s…

Read More

Bridging the Gap: Connecting SEO, Influencer Strategy, and Asset Management

The digital marketing landscape has transformed into an intricate ecosystem where online visibility is no longer defined by search rankings alone. Today, professionals must navigate a convergence…

Read More
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x