PHP 8.1 cài gd

Bạn có cần cài đặt Tiện ích mở rộng PHP GD không? . Trong bài đăng này, tôi sẽ chia sẻ với các bạn cách cài đặt PHP GD Extension trong windows của bạn. Tiện ích mở rộng này rất quan trọng nếu bạn có chức năng tạo và thao tác với hình ảnh trong PHP. Vui lòng làm theo các bước đơn giản dưới đây

 

Trước tiên, hãy kiểm tra xem

sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
0 đã tồn tại trong thư mục máy chủ web tiện ích mở rộng của bạn chưa. Nếu bạn đang sử dụng Xampp, bạn sẽ tìm thấy nó ở đây "C. \xampp\php\ext"

 

Thứ hai, nếu tiện ích mở rộng

sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
0 chưa tồn tại, vui lòng tải xuống tại đây và tải nó lên thư mục tiện ích mở rộng máy chủ web của bạn hoặc tại đây "C. \xampp\php\ext"

 

Thứ ba, sau đó nếu phần trên đã được kiểm tra thì hãy mở tệp "php. ini" vào trình chỉnh sửa của bạn, tệp này có thể được tìm thấy trong thư mục này "C. \xampp\php\" sau đó tìm kiếm bên trong "php. tập tin ini"

 

Thứ tư, khi bạn đã tìm thấy "extension=gd2" thì nếu bạn thấy như thế này ";extension=gd2" thì đây là nhận xét, đó là lý do tại sao tiện ích mở rộng GD không được bật. Bây giờ chúng tôi sẽ kích hoạt tính năng này bằng cách xóa dấu ";"

//change the following line 
;extension=gd2

//to this
extension=gd2

 

GHI CHÚ. Nếu bạn không tìm thấy "extension=gd2" thì bạn phải thêm dòng này dưới "Dynamic Extensions" bên trong "php. tập tin ini". Chỉ cần xem tệp sau đây bên dưới

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=.so' and
; 'extension='php_.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;

extension=gd2

extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo

 

Thứ năm, bây giờ hãy khởi động lại máy chủ web của bạn

 

Khi máy chủ của bạn đã được khởi động lại, hãy kiểm tra và xác nhận xem GD đã được bật cho máy chủ web của bạn chưa. Bây giờ hãy tạo một tệp PHP sau đó đặt tên cho nó theo ý muốn rồi thêm mã này vào. Sau đó chạy nó. Sau đó tìm kiếm Hỗ trợ GD và bạn sẽ thấy cấu hình GD. Như vậy là bạn đã cài đặt thành công Tiện ích mở rộng GD

PHP (từ viết tắt đệ quy của PHP. Bộ tiền xử lý siêu văn bản) là ngôn ngữ kịch bản mã nguồn mở có mục đích chung được sử dụng rộng rãi, đặc biệt phù hợp để phát triển web và có thể được nhúng vào HTML

Một thẻ đã tồn tại với tên chi nhánh được cung cấp. Nhiều lệnh Git chấp nhận cả tên thẻ và tên nhánh, vì vậy việc tạo nhánh này có thể gây ra hành vi không mong muốn. Bạn có chắc chắn muốn tạo nhánh này không?

Không có kho phần mềm Ubuntu hoặc Debian hiện tại nào cung cấp PHP 8. 1 trong kho phần mềm mặc định của họ. Tuy nhiên, Ondřej Surý tiếp tục cung cấp các phiên bản PHP dưới dạng kho lưu trữ phần mềm Debian/Ubuntu và PHP 8. 1 gói hiện có sẵn

Có gì mới và thay đổi trong PHP 8. 1

PHP8. 1 mang đến một số tính năng, cải tiến và chức năng mới được đánh dấu là không dùng nữa. Để biết danh sách đầy đủ các thay đổi trong PHP 8. 1, xem Có gì mới và thay đổi trong PHP 8. 1

Các thay đổi về tiện ích mở rộng và phụ thuộc trong PHP 8. 1

  • Tiện ích mở rộng GD hỗ trợ định dạng hình ảnh AVIF từ PHP 8. 1 nếu tiện ích mở rộng được biên dịch với hỗ trợ hình ảnh AVIF. Tuy nhiên, hướng dẫn cài đặt bên dưới không bao gồm hỗ trợ hình ảnh AVIF
  • Tiện ích mở rộng Curl hỗ trợ DNS qua HTTPS (DoH) kể từ PHP 8. 1. Tính năng này yêu cầu phiên bản Curl 7. 62 trở lên và sẽ không khả dụng trên các phiên bản Debian/Ubuntu cũ hơn không gói phiên bản Curl muộn hơn 7. 62. Ví dụ: tính năng này sẽ không khả dụng trên Ubuntu 18. 04

Các thay đổi của Chỉ thị INI trong PHP 8. 1

  • Các chức năng
    sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
    sudo apt update
    6,
    sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
    sudo apt update
    7 và cài đặt INI liên quan không được dùng nữa
  • Cài đặt INI của
    sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
    sudo apt update
    8 và
    sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
    sudo apt update
    9 không được dùng nữa
  • Chỉ thị
    sudo apt install apt-transport-https lsb-release ca-certificates wget -y
    sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
    sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
    sudo apt update
    0 INI không được dùng nữa

1. Liệt kê các gói PHP hiện có

Khi cập nhật thiết lập PHP hiện có, việc liệt kê các tiện ích mở rộng PHP hiện có được cài đặt dưới dạng gói phần mềm sẽ dễ dàng hơn, để phù hợp với PHP 8. 1 danh sách tiện ích mở rộng

Trên các hệ thống cài đặt PHP 8. 1 lần nữa, bước này không bắt buộc

dpkg -l | grep php | tee packages.txt

Lệnh này liệt kê tất cả các gói PHP đã cài đặt, hiển thị chúng trên màn hình và lưu vào tệp có tên

sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
1 trong thư mục làm việc hiện tại

2. Thêm sudo apt install apt-transport-https lsb-release ca-certificates wget -y sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' sudo apt update2 PPA

Không có kho phần mềm mặc định nào trên Ubuntu hoặc Debian cho đến nay bao gồm PHP 8. 1. Ondřej Surý duy trì một kho lưu trữ gói chứa các tệp nhị phân đã biên dịch của tất cả các phiên bản PHP hiện tại, dành cho Ubuntu và Debian

Khi kho lưu trữ này được thêm vào, quá trình cài đặt và cập nhật ban đầu có thể được thực hiện bằng các lệnh

sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
3 tiêu chuẩn

Ubuntu

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update

Debian

sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update

Các bước trên sẽ thêm PPA làm nguồn gói, chứa tất cả các gói PHP và các phần phụ thuộc của chúng, chẳng hạn như

sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
4 và
sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
5

3. Cài đặt PHP8. 1 và tiện ích mở rộng

Tất cả PHP8. 1 gói theo mẫu

sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
6. Các phần mở rộng bổ sung (chẳng hạn như
sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
7,
sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
8, v.v. ) có thể được cài đặt dưới dạng các gói phần mềm theo tên của chúng (
sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
9,
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=.so' and
; 'extension='php_.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;

extension=gd2

extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
90, v.v. )

  • ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename
    ;
    ; For example:
    ;
    ;   extension=mysqli
    ;
    ; When the extension library to load is not located in the default extension
    ; directory, You may specify an absolute path to the library file:
    ;
    ;   extension=/path/to/extension/mysqli.so
    ;
    ; Note : The syntax used in previous PHP versions ('extension=.so' and
    ; 'extension='php_.dll') is supported for legacy reasons and may be
    ; deprecated in a future PHP major version. So, when it is possible, please
    ; move to the new ('extension=) syntax.
    ;
    ; Notes for Windows environments :
    ;
    ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
    ;   extension folders as well as the separate PECL DLL download (PHP 5+).
    ;   Be sure to appropriately set the extension_dir directive.
    ;
    
    extension=gd2
    
    extension=bz2
    extension=curl
    ;extension=ffi
    ;extension=ftp
    extension=fileinfo
    91 là một gói meta cài đặt chung một số gói phụ thuộc như
    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename
    ;
    ; For example:
    ;
    ;   extension=mysqli
    ;
    ; When the extension library to load is not located in the default extension
    ; directory, You may specify an absolute path to the library file:
    ;
    ;   extension=/path/to/extension/mysqli.so
    ;
    ; Note : The syntax used in previous PHP versions ('extension=.so' and
    ; 'extension='php_.dll') is supported for legacy reasons and may be
    ; deprecated in a future PHP major version. So, when it is possible, please
    ; move to the new ('extension=) syntax.
    ;
    ; Notes for Windows environments :
    ;
    ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
    ;   extension folders as well as the separate PECL DLL download (PHP 5+).
    ;   Be sure to appropriately set the extension_dir directive.
    ;
    
    extension=gd2
    
    extension=bz2
    extension=curl
    ;extension=ffi
    ;extension=ftp
    extension=fileinfo
    92 và
    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename
    ;
    ; For example:
    ;
    ;   extension=mysqli
    ;
    ; When the extension library to load is not located in the default extension
    ; directory, You may specify an absolute path to the library file:
    ;
    ;   extension=/path/to/extension/mysqli.so
    ;
    ; Note : The syntax used in previous PHP versions ('extension=.so' and
    ; 'extension='php_.dll') is supported for legacy reasons and may be
    ; deprecated in a future PHP major version. So, when it is possible, please
    ; move to the new ('extension=) syntax.
    ;
    ; Notes for Windows environments :
    ;
    ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
    ;   extension folders as well as the separate PECL DLL download (PHP 5+).
    ;   Be sure to appropriately set the extension_dir directive.
    ;
    
    extension=gd2
    
    extension=bz2
    extension=curl
    ;extension=ffi
    ;extension=ftp
    extension=fileinfo
    93 cũng như các gói phụ trợ như
    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename
    ;
    ; For example:
    ;
    ;   extension=mysqli
    ;
    ; When the extension library to load is not located in the default extension
    ; directory, You may specify an absolute path to the library file:
    ;
    ;   extension=/path/to/extension/mysqli.so
    ;
    ; Note : The syntax used in previous PHP versions ('extension=.so' and
    ; 'extension='php_.dll') is supported for legacy reasons and may be
    ; deprecated in a future PHP major version. So, when it is possible, please
    ; move to the new ('extension=) syntax.
    ;
    ; Notes for Windows environments :
    ;
    ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
    ;   extension folders as well as the separate PECL DLL download (PHP 5+).
    ;   Be sure to appropriately set the extension_dir directive.
    ;
    
    extension=gd2
    
    extension=bz2
    extension=curl
    ;extension=ffi
    ;extension=ftp
    extension=fileinfo
    94 nếu một trong số
    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename
    ;
    ; For example:
    ;
    ;   extension=mysqli
    ;
    ; When the extension library to load is not located in the default extension
    ; directory, You may specify an absolute path to the library file:
    ;
    ;   extension=/path/to/extension/mysqli.so
    ;
    ; Note : The syntax used in previous PHP versions ('extension=.so' and
    ; 'extension='php_.dll') is supported for legacy reasons and may be
    ; deprecated in a future PHP major version. So, when it is possible, please
    ; move to the new ('extension=) syntax.
    ;
    ; Notes for Windows environments :
    ;
    ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
    ;   extension folders as well as the separate PECL DLL download (PHP 5+).
    ;   Be sure to appropriately set the extension_dir directive.
    ;
    
    extension=gd2
    
    extension=bz2
    extension=curl
    ;extension=ffi
    ;extension=ftp
    extension=fileinfo
    92,
    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename
    ;
    ; For example:
    ;
    ;   extension=mysqli
    ;
    ; When the extension library to load is not located in the default extension
    ; directory, You may specify an absolute path to the library file:
    ;
    ;   extension=/path/to/extension/mysqli.so
    ;
    ; Note : The syntax used in previous PHP versions ('extension=.so' and
    ; 'extension='php_.dll') is supported for legacy reasons and may be
    ; deprecated in a future PHP major version. So, when it is possible, please
    ; move to the new ('extension=) syntax.
    ;
    ; Notes for Windows environments :
    ;
    ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
    ;   extension folders as well as the separate PECL DLL download (PHP 5+).
    ;   Be sure to appropriately set the extension_dir directive.
    ;
    
    extension=gd2
    
    extension=bz2
    extension=curl
    ;extension=ffi
    ;extension=ftp
    extension=fileinfo
    96 hoặc
    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename
    ;
    ; For example:
    ;
    ;   extension=mysqli
    ;
    ; When the extension library to load is not located in the default extension
    ; directory, You may specify an absolute path to the library file:
    ;
    ;   extension=/path/to/extension/mysqli.so
    ;
    ; Note : The syntax used in previous PHP versions ('extension=.so' and
    ; 'extension='php_.dll') is supported for legacy reasons and may be
    ; deprecated in a future PHP major version. So, when it is possible, please
    ; move to the new ('extension=) syntax.
    ;
    ; Notes for Windows environments :
    ;
    ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
    ;   extension folders as well as the separate PECL DLL download (PHP 5+).
    ;   Be sure to appropriately set the extension_dir directive.
    ;
    
    extension=gd2
    
    extension=bz2
    extension=curl
    ;extension=ffi
    ;extension=ftp
    extension=fileinfo
    97 không được yêu cầu rõ ràng
  • ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename
    ;
    ; For example:
    ;
    ;   extension=mysqli
    ;
    ; When the extension library to load is not located in the default extension
    ; directory, You may specify an absolute path to the library file:
    ;
    ;   extension=/path/to/extension/mysqli.so
    ;
    ; Note : The syntax used in previous PHP versions ('extension=.so' and
    ; 'extension='php_.dll') is supported for legacy reasons and may be
    ; deprecated in a future PHP major version. So, when it is possible, please
    ; move to the new ('extension=) syntax.
    ;
    ; Notes for Windows environments :
    ;
    ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
    ;   extension folders as well as the separate PECL DLL download (PHP 5+).
    ;   Be sure to appropriately set the extension_dir directive.
    ;
    
    extension=gd2
    
    extension=bz2
    extension=curl
    ;extension=ffi
    ;extension=ftp
    extension=fileinfo
    98 là gói meta cài đặt hầu hết các tiện ích mở rộng PHP được sử dụng rộng rãi trong một lần. Nó tự động cài đặt gói chẳng hạn như
    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename
    ;
    ; For example:
    ;
    ;   extension=mysqli
    ;
    ; When the extension library to load is not located in the default extension
    ; directory, You may specify an absolute path to the library file:
    ;
    ;   extension=/path/to/extension/mysqli.so
    ;
    ; Note : The syntax used in previous PHP versions ('extension=.so' and
    ; 'extension='php_.dll') is supported for legacy reasons and may be
    ; deprecated in a future PHP major version. So, when it is possible, please
    ; move to the new ('extension=) syntax.
    ;
    ; Notes for Windows environments :
    ;
    ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
    ;   extension folders as well as the separate PECL DLL download (PHP 5+).
    ;   Be sure to appropriately set the extension_dir directive.
    ;
    
    extension=gd2
    
    extension=bz2
    extension=curl
    ;extension=ffi
    ;extension=ftp
    extension=fileinfo
    99,
    sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
    sudo apt update
    90 trong số các tiện ích mở rộng hữu ích khác

Cài đặt PHP8. 1 với CLI

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=.so' and
; 'extension='php_.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;

extension=gd2

extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
9

Lệnh này sẽ cài đặt một số tiện ích mở rộng PHP do

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=.so' and
; 'extension='php_.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;

extension=gd2

extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
98 và CLI cho PHP 8. 1

Xác nhận cài đặt bằng cách chạy

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
9

tiện ích mở rộng bổ sung

Bạn có thể cài đặt các tiện ích mở rộng bổ sung từ cùng một mẫu

sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
6. Tham khảo tệp
sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
1 để xem danh sách các gói hiện có nếu bạn đang nâng cấp hệ thống hiện có

Lưu ý rằng kể từ PHP 8. 0, tiện ích mở rộng JSON được đóng gói và được cài đặt ngầm

Một ví dụ để cài đặt một vài tiện ích mở rộng hữu ích hơn

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
5

Công cụ phát triển

Đối với môi trường phát triển, bạn cũng có thể cài đặt các công cụ bảo hiểm mã hoặc trình gỡ lỗi Xdebug

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
6

Điều này không được khuyến nghị cho các máy chủ sản xuất

Cài đặt API máy chủ

Tùy thuộc vào máy chủ web bạn sử dụng, bạn sẽ cần cài đặt các gói bổ sung để tích hợp với máy chủ web


Đối với Apache sử dụng

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
94, Nginx, Litespeed, v.v. , Gói
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=.so' and
; 'extension='php_.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;

extension=gd2

extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
96 cung cấp khả năng tích hợp với PHP 8. 1 qua FPM

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
9

Đối với Apache sử dụng

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
96, hãy cài đặt
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=.so' and
; 'extension='php_.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;

extension=gd2

extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
97

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
2

Lưu ý rằng Apache2Handler được đổi tên thành

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
98 từ
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
99 trong PHP 8. 0. Gói
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=.so' and
; 'extension='php_.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;

extension=gd2

extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
97 tự động định cấu hình vị trí mô-đun Apache, nhưng nếu bạn đang cập nhật từ một thiết lập PHP hiện có, bạn có thể cần cập nhật các tệp cấu hình;

4. Kiểm tra PHP 8. 1 cài đặt

Để kiểm tra cài đặt PHP và các tiện ích mở rộng, hãy chạy các lệnh sau

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
7
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
0
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
1

Xóa các phiên bản PHP cũ

Nếu cài đặt mới hoạt động như mong đợi, bạn có thể xóa các gói PHP cũ khỏi hệ thống

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
2

Điều này giả định rằng bạn đang sử dụng PHP 8. 0 như phiên bản trước. Thay đổi phần

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
52 của lệnh trên bằng phiên bản PHP phù hợp

Chạy PHP8. 1 với các phiên bản khác

Thay vì loại bỏ các phiên bản PHP cũ, cũng có thể chạy nhiều phiên bản PHP song song

PHP8. 1 CLI sẽ được cài đặt tại vị trí

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
53 theo mặc định. Tương tự, các tệp nhị phân PHP khác sẽ được đặt trong cùng thư mục (
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
54,
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
55, v.v.). Theo mặc định, tên
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
56 sẽ được liên kết tượng trưng với phiên bản PHP mới nhất, nhưng có thể thay đổi vị trí mà lệnh
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
56 mặc định liên kết tới

Lệnh

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
58 cung cấp một cách dễ dàng để chuyển đổi giữa các phiên bản PHP cho PHP CLI

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
3

Thao tác này đưa ra lời nhắc chọn một cách tương tác đường dẫn nhị phân PHP thay thế mà

sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
56 trỏ tới

Làm cách nào để cài đặt GD trong php?

Để cài đặt hỗ trợ PHP GD trên máy chủ Windows, hãy làm theo các bước dưới đây. .
Lúc đầu, hãy đảm bảo rằng php_gd2. .
Nếu php_gd2. .
mở php. ini trong trình soạn thảo văn bản và kiểm tra xem tệp php_gd2. phần mở rộng dll đã được thêm vào. .
Nếu ;extension=php_gd2. .
Để bao gồm php_gd2. .
Khởi động lại máy chủ Windows

Làm cách nào để kiểm tra xem GD có được bật trong php không?

Để biết điều này, chúng ta có thể dùng hàm phpinfo và kiểm tra xem có hỗ trợ GD hay không. Đây là hình ảnh về chức năng phpinfo hiển thị trong hệ thống hỗ trợ GD. Hình ảnh trên được hiển thị bởi hàm phpinfo cho thấy hỗ trợ GD được bật trong hệ thống php và sẵn sàng sử dụng.

Làm cách nào để cài đặt tiện ích mở rộng php của GMP?

Cài đặt GMP trong PHP . Bạn có thể kích hoạt tương tự bằng cách xóa dấu (;) ;extension=gmp được thêm vào đầu tiện ích mở rộng trong php. ini . Sau đó khởi động lại apache và để xác nhận xem các thay đổi có phản ánh không.

Làm cách nào để cài đặt phiên bản php 8?

Để cài đặt PHP 8 trên Ubuntu 22. 04, bạn phải làm theo hướng dẫn từng bước dưới đây. .
Bước 1. Cập nhật kho hệ thống. .
Bước 2. Cài đặt các phụ thuộc cần thiết. .
Bước 3. Thiết lập kho lưu trữ PHP. .
Bước 4. Cài đặt PHP 8 trên Ubuntu 22. 04. .
Bước 5. Xác minh phiên bản PHP. .
Bước 6. Cài đặt phần mở rộng PHP 8