簡體   English   中英

嘗試在 ubuntu 20.04 上安裝 php-mbstring

[英]Trying to install php-mbstring on ubuntu 20.04

我只是想創建一個新的 laravel 項目並遇到此消息

Creating a "laravel/laravel" project at "./example-app"
Installing laravel/laravel (v8.5.22)
  - Installing laravel/laravel (v8.5.22): Extracting archive
Created project in /home/alifirhas/0_Work/Belajar/postgresql/example-app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework[v8.40.0, ..., 8.x-dev] require ext-mbstring * -> it is missing from your system. Install or enable PHP's mbstring extension.
    - Root composer.json requires laravel/framework ^8.40 -> satisfiable by laravel/framework[v8.40.0, ..., 8.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/8.0/cli/php.ini
    - /etc/php/8.0/cli/conf.d/10-opcache.ini
    - /etc/php/8.0/cli/conf.d/10-pdo.ini
    - /etc/php/8.0/cli/conf.d/20-calendar.ini
    - /etc/php/8.0/cli/conf.d/20-ctype.ini
    - /etc/php/8.0/cli/conf.d/20-exif.ini
    - /etc/php/8.0/cli/conf.d/20-ffi.ini
    - /etc/php/8.0/cli/conf.d/20-fileinfo.ini
    - /etc/php/8.0/cli/conf.d/20-ftp.ini
    - /etc/php/8.0/cli/conf.d/20-gettext.ini
    - /etc/php/8.0/cli/conf.d/20-iconv.ini
    - /etc/php/8.0/cli/conf.d/20-phar.ini
    - /etc/php/8.0/cli/conf.d/20-posix.ini
    - /etc/php/8.0/cli/conf.d/20-readline.ini
    - /etc/php/8.0/cli/conf.d/20-shmop.ini
    - /etc/php/8.0/cli/conf.d/20-sockets.ini
    - /etc/php/8.0/cli/conf.d/20-sysvmsg.ini
    - /etc/php/8.0/cli/conf.d/20-sysvsem.ini
    - /etc/php/8.0/cli/conf.d/20-sysvshm.ini
    - /etc/php/8.0/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

看起來我必須在我的電腦上安裝 php-mbstring,所以我運行命令

sudo apt-get install php-mbstring 

正如我在這個線程中發現的: laravel/framework requires ext-mbstring

但是還有另一個錯誤信息

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php-mbstring : Depends: php8.0-mbstring but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

這是我運行sudo apt install php7.4-mbstring時的錯誤代碼

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php7.4-mbstring : Depends: libonig5 (>= 6.8.1) but it is not installable
E: Unable to correct problems, you have held broken packages.

我試過什么

  • 在我的電腦上重新安裝 php7.4 然后嘗試安裝 mbstring,但失敗
  • 將我的 php 版本更新到版本 -8 然后嘗試安裝 mbstring,但失敗
  • 執行此線程中的操作: https ://askubuntu.com/questions/1064634/unable-to-install-php-mbstring,但失敗

那么有人知道如何安裝 php-mbstring 嗎? 或者我怎樣才能制作一個 laravel 項目?

我希望你們能幫我解決這個問題,拜托。 我已經在這個問題上工作了將近 8 個小時,但仍然找不到解決方案。

原來我必須為我的系統啟用 Universe 存儲庫,就像這樣

sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"

sudo apt-get update #to update my system

正如 Jarad 在此線程中所說, Cannot install php-mbstring on ubuntu 18.04 然后我就可以跑了

sudo apt-get install php-mbstring 

但事實證明,我必須具體說明我要安裝的版本。 如果我只是運行php-mbstring ,只會為 php 8.0 安裝 mbstring,而不是系統上安裝的版本。 我必須具體,然后我運行命令

sudo apt-get install php7.4-mbstring 

(我搬到了php7.4)

它運行完美。 還要感謝@Nico Haase 和@Peter Krebs 的幫助。

對我有用的是指定版本,並且不要忘記更新:

sudo apt update
sudo apt install php7.4-mbstring

你試過系統更新嗎?

sudo apt-get upgrade

我今天才用這個,希望對你也有幫助。

我今天為 php8.0-mbstring 模塊遇到了這個問題,我發現我的系統中沒有正確的存儲庫,所以我的方法是這樣的,它對我有用,希望它也能幫助你:

sudo add-apt-repository ppa:ondrej/php

sudo apt-get install php8.0-mbstring

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM