Question

Package not installed on Linux

I was trying to install the php and laravel pkg on Linux Ubuntu, but everytime he shows this error package not installed use the latest version.

What should I do?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
February 22, 2024

Heya,

If you’re encountering an error stating “package not installed use the latest version” while trying to install PHP and Laravel on Ubuntu, it’s likely that there are issues with the package versions or repository configurations. Here are the steps to troubleshoot and resolve this issue:

  1. Update and Upgrade Packages: First, ensure your package lists are up to date. Run these commands:
sudo apt update sudo apt upgrade
  1. Install PHP:

    • Check the PHP version available in your Ubuntu repository:
apt search php
-   Install the latest version of PHP available (for example, if the latest is PHP 8.0):
sudo apt install php8.0
-   Install necessary PHP extensions. Laravel requires some specific PHP extensions. You can install them with:
sudo apt install php8.0-xml php8.0-mbstring php8.0-mysql php8.0-sqlite3 php8.0-curl php8.0-gd
  1. Install Composer: Composer is a dependency manager for PHP, required for installing Laravel.

    • Download and install Composer by following the instructions on the official Composer website.
  2. Install Laravel: With PHP and Composer installed, you can install Laravel globally using Composer:

composer global require laravel/installer
Ensure that the Composer global bin directory is in your system's "PATH".
  1. Check PHP and Laravel Versions:

    • Verify PHP installation:
php -v
-   Verify Laravel installation:
laravel -v
  1. Troubleshooting:

    • If you are still receiving errors, it might be helpful to see the exact error messages. Errors can provide clues as to what might be going wrong.
    • Ensure that there are no conflicts between package versions and that your Ubuntu version supports the packages you’re trying to install.
    • Sometimes, adding a third-party PPA (Personal Package Archive) can help in getting the latest versions of PHP:
sudo add-apt-repository ppa:ondrej/php sudo apt update
-   After adding a new PPA, try installing PHP again.
alexdo
Site Moderator
Site Moderator badge
February 21, 2024

Heya,

You can use our article on How to setup a LAMP stack on Ubuntu 22.04 and just follow the steps for PHP to get it installed on your droplet:

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-22-04#step-3-installing-php

You can include any additional packages to the install command as well. Once done you can check the PHP version with php -v

Hope that this helps!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel