How to install all required PHP extensions for Laravel?
Asked Answered
M

6

93

I need to make my Ubuntu 16.04. Is there a way using the GUI or is the simplest way to do this by using terminal?

I have already installed PHP 7.1, MariaDB.

I need to enable:

  1. OpenSSL PHP Extension
  2. PDO PHP Extension
  3. Mbstring PHP Extension
  4. Tokenizer PHP Extension
  5. XML PHP Extension
Myrick answered 26/11, 2016 at 7:21 Comment(1)
What's the exact question here? What keeps you from installing the list of extensions as you usually do it, and as it is documented on many tutorials?Wandy
E
239

The Laravel server requirements specify the PHP extensions, including BCMath, Ctype, cURL, DOM, Fileinfo, JSON, Mbstring, OpenSSL, PCRE, PDO, Tokenizer, and XML, are required. These extensions are usually included and enabled during a PHP installation.

You can use the following command in Ubuntu to check the necessary extensions.

sudo apt install openssl php-bcmath php-curl php-json php-mbstring php-mysql php-tokenizer php-xml php-zip

Installation specific to a particular version of PHP (such as PHP 8.3)

sudo apt install openssl php8.3-bcmath php8.3-curl php8.3-json php8.3-mbstring php8.3-mysql php8.3-tokenizer php8.3-xml php8.3-zip

Additional PHP extensions may be required for your composer packages. Refer to the links below for more information.

PHP extensions for Ubuntu 22.04 LTS (Jammy Jellyfish)

PHP extensions for Ubuntu 20.04 LTS (Focal Fossa)

PHP extensions for Ubuntu 18.04 LTS (Bionic)

PHP extensions for Ubuntu 16.04 LTS (Xenial)

Exorable answered 26/11, 2016 at 7:27 Comment(8)
Does it uncomment ";" in my php.ini?Myrick
If not you can find the ini file here /etc/php/7.x/apache2/php.ini. Edit and restart Apache.Exorable
Are you sure that php-common and php-zip are needed? I found that sudo apt-get install php-mbstring php-xml unzip was enough. I could be wrong thoughDisrepute
@Disrepute at least mbstring depends on common. It will be installed by apt when you confirm to do so. Laravel does not need zip AFAIK, but composer is happy about it.Sophisticated
This one worked for Laravel 9 with PHP 8.2Nijinsky
Hey, there is no such thing as php8.x-json, just php-json. Thanks.Mcsweeney
@MahmoudKassem, php-json is for the default version, and php8.x-json is for a specific version.Exorable
@MadanSapkota Thank you for the clarification; however, json ext has been "made always available" since PHP 8, which is why it was not found. Therefore, there is no need to install this extension for 8.x versions. sourceMcsweeney
G
6

**

New requirements for installing Laravel 8 and PHP 8:

**

sudo apt install php8.0-common php8.0-dom php8.0-bcmath openssl php8.0-mbstring
Glossary answered 30/11, 2021 at 20:37 Comment(0)
H
4

Run the below command. It will install all required php8.1 extensions in Ubuntu

sudo apt install php8.1 php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-curl php8.1-gd php8.1-mbstring php8.1-xml php8.1-bcmath php8.1-fpm php8.1-phpdbg php8.1-cgi libphp8.1-embed libapache2-mod-php8.1
Halland answered 7/12, 2022 at 13:23 Comment(0)
B
2

All the necessary php8.3 extensions for Laravel 11:

These extensions will cover 99% of common php usage.

update and upgrade:

sudo apt update && sudo apt upgrade -y

add repository:

sudo add-apt-repository ppa:ondrej/php

update repository:

sudo apt update

Newest version of php:

The complete list of all the needed PHP extensions:

sudo apt-get install -y php php-cli php-common php-fpm php-mysql php-zip php-gd php-mbstring php-curl php-xml php-bcmath openssl php-json php-tokenizer

If you want php extension for the specific version of PHP:

The complete list of all the needed PHP extensions with version 8.3 for Laravel 11:

sudo apt-get install -y php8.3 php8.3-cli php8.3-common php8.3-fpm php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php8.3-bcmath openssl php8.3-tokenizer

you can replace 8.3 with the version that you want.

Note:

More info about the listed extensions:

  • php: PHP (Hypertext Preprocessor) language interpreter.
  • php-cli: Command-line interface for PHP.
  • php-common: Common files for PHP.
  • php-fpm: PHP FastCGI Process Manager.
  • php-mysql: MySQL database integration for PHP.
  • php-zip: ZIP archive support for PHP.
  • php-gd: GD extension for PHP (image processing).
  • php-mbstring: Multibyte string support for PHP.
  • php-curl: cURL extension for PHP (URL transfers).
  • php-xml: XML support for PHP.
  • php-bcmath: Arbitrary precision mathematics extension for PHP.
  • openssl: OpenSSL toolkit (used by PHP for encryption).
  • php-json: JSON support for PHP.
  • php-tokenizer: Tokenizer support for PHP (used for parsing PHP code).
Blackcock answered 3/4, 2023 at 0:11 Comment(0)
H
0

You can install PHP extensions like this:

sudo apt-get install php-xsl php-pgsql
Hen answered 4/9, 2022 at 19:0 Comment(0)
R
-1

Here is Extension with Name and Commands for UBUNTU

  1. Install or enable PHP's curl extension

    sudo apt install phpy-curl

  2. Install or enable PHP's simplexml extension.

    sudo apt install php-xml

  3. Install or enable PHP's gd extension

    sudo apt-get install php-gd

  4. Install or enable PHP's zip extension

    sudo apt install php-zip

Ruder answered 22/12, 2022 at 11:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.