10

I am trying to install Laravel. I am on Ubuntu 18.04.5 LTS, have php 8.0.2, and running Apache2. My issue is that I can't install Laravel as it keeps giving the error that I don't have the 'mbstring' extension.

When I do the commands

sudo apt update sudo apt install php-mbstring 

they get installed to /etc/php/7.2/mods-available. Laravel is looking for the extensions in /etc/php/8.0/. I have also tried installing the newest version of mbstring:

sudo apt install php8.0-mbstring 

But get the error

Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package php8.0-mbstring E: Couldn't find any package by glob 'php8.0-mbstring' E: Couldn't find any package by regex 'php8.0-mbstring' 

Can someone help me figure this out? Why does mbstring not get installed to php8.0, and why can't I install mbstring for 8.0? I have googled online and found guides for installing mbstring for 8.0 and this specific command, but I can't see that extension.

3
  • 3
    The php8.0-mbstring is provided from this repository : launchpad.net/~ondrej/+archive/ubuntu/php Commented May 13, 2021 at 19:31
  • Thank you for that information. Would that mean I don't use 'apt install php8.0-mbstring'? What would I have to do instead? All the links I click on google tell me to do that same command. Commented May 13, 2021 at 19:46
  • It worked! I had to read that document a bit to figure out what you mean. Thanks! Posting the answer as a full comment below. Commented May 13, 2021 at 19:55

2 Answers 2

11

Figured it out thanks to Michal Przybylowicz's comment.

The website's repository: https://launchpad.net/~ondrej/+archive/ubuntu/php needs to be added to Ubuntu's package system. The site lists the commands to do:

sudo add-apt-repository ppa:ondrej/php sudo apt-get update 

I also did:

sudo add-apt-repository ppa:ondrej/apache2

since I run apache2. After that Laravel said that I need the 'dom' extension as well. That was solved by:

sudo apt install php8.0-dom

After that Laravel finally installed! Thanks Michal!

3
  • I am a bit skeptical, can this repo be trusted? Commented May 13, 2021 at 21:57
  • Few months later, everything seems to be fine. So far I see no reason to doubt that repository. Commented Oct 22, 2021 at 16:46
  • 1
    @Teso Ondrej appears to be the official Debian package manager for PHP. Commented Dec 10, 2021 at 17:05
1

@kush solution worked great for me - after +4 hours of trying stuff.

Obviously, also works if you get this errors:

curl

PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: /usr/lib/php/20200930/curl (/usr/lib/php/20200930/curl: cannot open shared object file: No such file or directory), /usr/lib/php/20200930/curl.so (/usr/lib/php/20200930/curl.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

sudo apt install php8.0-curl or sudo apt install php[your-version]-curl

mbstring

PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring' (tried: /usr/lib/php/20200930/mbstring (/usr/lib/php/20200930/mbstring: cannot open shared object file: No such file or directory)

sudo apt install php8.0-mbstring or sudo apt install php[your-version]-mbstring

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.