PHP7. 1. 6 là bản phát hành ổn định gần đây nhất và là ngôn ngữ kịch bản có mục đích chung phổ biến chủ yếu được sử dụng để phát triển web. Vì nó nhanh, linh hoạt và thực dụng, PHP có khả năng hỗ trợ mọi thứ từ blog của bạn đến các trang web phổ biến nhất trên thế giới
đang cài đạt PHP
Trước khi bạn bắt đầu cài đặt PHP, hãy đảm bảo rằng bạn đã thêm kho lưu trữ cần thiết vào máy của mình. Thực hiện hành động bằng cách chạy lệnh sau
[email protected]:~# add-apt-repository ppa:ondrej/php
Co-installable PHP versions: PHP 5.6, PHP 7.0, PHP 7.1 and most requested extensions are included.
PLEASE DON' T USE PHP 5.4 OR PHP 5.5. The PHP 5.5 and later are no longer supported with security updates, therefore they are not included in this repository.
You can get more information about the packages at //deb.sury.org
BUGS& FEATURES: This PPA now has a issue tracker: //deb.sury.org/#bug-reporting
.
.
gpg: Total number processed: 1
gpg: imported: 1
OK
Sau khi hoàn tất, hãy cập nhật repo mới được thêm vào như sau
[email protected]p:~# apt-get update
Hit:1 //ppa.launchpad.net/gns3/ppa/ubuntu zesty InRelease
Hit:2 //in.archive.ubuntu.com/ubuntu zesty InRelease
Get:3 //security.ubuntu.com/ubuntu zesty-security InRelease [89.2 kB]
.
.
Fetched 379 kB in 2s [128 kB/s]
Reading package lists.. Done
Bây giờ là lúc để cài đặt PHP 7. 1. 6. trong máy của bạn. Chạy lệnh sau để bắt đầu cài đặt PHP
[email protected]:~# apt-get install php7.1
Reading package lists.. Done
Building dependency tree
Reading state information.. Done
.
.
Processing triggers for libc-bin [2.24-9ubuntu2] ...
Processing triggers for ureadahead [0.100.0-19] ...
Processing triggers for systemd [232-21ubuntu2] ...
Processing triggers for ufw [0.35-4] ...
PHP7. 1. 6. được cài đặt trong hệ thống của bạn. Để kiểm tra, hãy chạy lệnh sau
[email protected]:~# php -v
PHP 7.1.8-2+ubuntu17.04.1+deb.sury.org+4 [cli] [built: Aug 4 2017 13:07:41] [ NTS ]
Copyright [c] 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright [c] 1998-2017 Zend Technologies
with Zend OPcache v7.1.8-2+ubuntu17.04.1+deb.sury.org+4, Copyright [c] 1999-2017, by Zend Technologies
Với các bước trên, quá trình cài đặt và xác minh PHP 7 đã hoàn tất. 1. 6. hoàn tất
Q
Các chức năng trong IMAP, POP3 VÀ LDAP?
A
Bạn có thể tìm thấy những thông tin cụ thể này trong PHP Manual
Q
Làm cách nào chúng ta có thể mã hóa và giải mã dữ liệu có trong bảng MySQL bằng MySQL?
A
Chạy lệnh sau,
AES_ENCRYPT[] và AES_DECRYPT[]
Q
Giả sử công cụ Zend của bạn hỗ trợ chế độ Vậy thì làm cách nào bạn có thể định cấu hình công cụ Zend PHP của mình để hỗ trợ chế độ?
PHP là ngôn ngữ kịch bản máy chủ mục đích chung nguồn mở được sử dụng rộng rãi và là công cụ mạnh mẽ để tạo các trang web động và tương tác. PHP được sử dụng rộng rãi, thay thế miễn phí và hiệu quả cho microsoft
Q
PHP là viết tắt của từ gì?
A
PHP là một từ viết tắt đệ quy Và nó là viết tắt của Hypertext Pre-Processor
Q
Web scripting trong PHP là gì?
A
Kịch bản web trong PHP là thêm các khả năng động vào các trang web trên toàn thế giới
Q
PHP là front-end hay back-end?
A
PHP là một công nghệ back-end hay còn gọi là ngôn ngữ Server Side Scripting
Q
What deos server-side scripting mean Trong PHP?
A
Kịch bản phía máy chủ là một kỹ thuật được sử dụng trong phát triển web bao gồm việc sử dụng các tập lệnh trên máy chủ web, tạo ra phản hồi được tùy chỉnh cho từng yêu cầu của khách hàng trên trang web
Bạn phải sao lưu máy chủ của mình trước khi chạy các lệnh này vì chúng không thể đảo ngược dễ dàng. Nếu bạn đang sử dụng dịch vụ lưu trữ đám mây, hãy đảm bảo rằng bạn hình dung phiên bản của mình trước khi chạy bất kỳ lệnh nào trong số này
Để biết phiên bản PHP nào bạn đang sử dụng, hãy chạy
php -v
Nếu bạn đang chạy PHP 7. x, bạn có thể tiếp tục với hướng dẫn này để nâng cấp lên PHP 8
1. Gói PHP
Nâng cấp từ PHP 7. x lên PHP 8 không chỉ liên quan đến việc nâng cấp lõi PHP mà còn tất cả các tiện ích mở rộng của nó. Ví dụ: nếu bạn sử dụng tiện ích mở rộng PHP cURL, bạn sẽ cần cài đặt thủ công phiên bản PHP 8 ở cuối hướng dẫn này
Ở cuối hướng dẫn này, tôi đã bao gồm một lệnh để cài đặt các tiện ích mở rộng PHP 8 phổ biến nhất, tuy nhiên, bạn nên kiểm tra xem PHP 7 nào. x hiện được cài đặt trên máy chủ cụ thể của bạn và lưu ý mọi thứ quan trọng đối với việc chạy ứng dụng web của riêng bạn
dpkg -l | grep php | tee packages.txt
đầu ra
ii libapache2-mod-php 1:7.2+60ubuntu1 all server-side, HTML-embedded scri
ii libapache2-mod-php7.2 7.2.24-0ubuntu0.18.04.7 amd64 server-side, HTML-embedded scri
ii php 1:7.2+60ubuntu1 all server-side, HTML-embedded scri
ii php-bz2 1:7.2+60ubuntu1 all bzip2 module for PHP [default]
ii php-common 1:60ubuntu1 all Common files for PHP packages
ii php-curl 1:7.2+60ubuntu1 all CURL module for PHP [default]
ii php-gd 1:7.2+60ubuntu1 all GD module for PHP [default]
ii php-mbstring 1:7.2+60ubuntu1 all MBSTRING module for PHP [defaul
ii php-mysql 1:7.2+60ubuntu1 all MySQL module for PHP [default]
ii php-pear 1:1.10.5+submodules+notgz-1ubuntu1.18.04.3 all PEAR Base System
ii php-php-gettext 1.0.12-0.1 all read gettext MO files directly,
ii php-phpseclib 2.0.9-1 all implementations of an arbitrary
ii php-tcpdf 6.2.13+dfsg-1ubuntu1 all PHP class for generating PDF fi
ii php-xml 1:7.2+60ubuntu1 all DOM, SimpleXML, WDDX, XML, and
ii php-zip 1:7.2+60ubuntu1 all Zip module for PHP [default]
ii php7.2 7.2.24-0ubuntu0.18.04.7 all server-side, HTML-embedded scri
ii php7.2-bz2 7.2.24-0ubuntu0.18.04.7 amd64 bzip2 module for PHP
ii php7.2-cli 7.2.24-0ubuntu0.18.04.7 amd64 command-line interpreter for th
ii php7.2-common 7.2.24-0ubuntu0.18.04.7 amd64 documentation, examples and com
ii php7.2-curl 7.2.24-0ubuntu0.18.04.7 amd64 CURL module for PHP
ii php7.2-gd 7.2.24-0ubuntu0.18.04.7 amd64 GD module for PHP
ii php7.2-json 7.2.24-0ubuntu0.18.04.7 amd64 JSON module for PHP
ii php7.2-mbstring 7.2.24-0ubuntu0.18.04.7 amd64 MBSTRING module for PHP
ii php7.2-mysql 7.2.24-0ubuntu0.18.04.7 amd64 MySQL module for PHP
ii php7.2-opcache 7.2.24-0ubuntu0.18.04.7 amd64 Zend OpCache module for PHP
ii php7.2-readline 7.2.24-0ubuntu0.18.04.7 amd64 readline module for PHP
ii php7.2-xml 7.2.24-0ubuntu0.18.04.7 amd64 DOM, SimpleXML, WDDX, XML, and
ii php7.2-zip 7.2.24-0ubuntu0.18.04.7 amd64 Zip module for PHP
ii phpmyadmin 4:4.6.6-5ubuntu0.5 all MySQL web administration tool
Ví dụ trên cho thấy PHP 7. 2 tiện ích mở rộng được cài đặt trên máy chủ của riêng tôi trước khi nâng cấp lên PHP 8. Sao chép kết quả của riêng bạn vào một tệp văn bản và giữ nó an toàn trong trường hợp bạn cần cài đặt phiên bản PHP 8 sau này
2. Gỡ cài đặt/Gỡ bỏ PHP 7. x và Tiện ích mở rộng
Để gỡ cài đặt PHP 7. x và tất cả các tiện ích mở rộng của nó, hãy chạy lệnh bên dưới
sudo apt-get purge php7.*
Nhấn
dpkg -l | grep php | tee packages.txt
7 và dpkg -l | grep php | tee packages.txt
8 khi được nhắcNếu bạn đã cài đặt phpMyAdmin, bạn có thể thấy màn hình này
[email protected]p:~# apt-get update
Hit:1 //ppa.launchpad.net/gns3/ppa/ubuntu zesty InRelease
Hit:2 //in.archive.ubuntu.com/ubuntu zesty InRelease
Get:3 //security.ubuntu.com/ubuntu zesty-security InRelease [89.2 kB]
.
.
Fetched 379 kB in 2s [128 kB/s]
Reading package lists.. Done
5Nhấn
ii libapache2-mod-php 1:7.2+60ubuntu1 all server-side, HTML-embedded scri
ii libapache2-mod-php7.2 7.2.24-0ubuntu0.18.04.7 amd64 server-side, HTML-embedded scri
ii php 1:7.2+60ubuntu1 all server-side, HTML-embedded scri
ii php-bz2 1:7.2+60ubuntu1 all bzip2 module for PHP [default]
ii php-common 1:60ubuntu1 all Common files for PHP packages
ii php-curl 1:7.2+60ubuntu1 all CURL module for PHP [default]
ii php-gd 1:7.2+60ubuntu1 all GD module for PHP [default]
ii php-mbstring 1:7.2+60ubuntu1 all MBSTRING module for PHP [defaul
ii php-mysql 1:7.2+60ubuntu1 all MySQL module for PHP [default]
ii php-pear 1:1.10.5+submodules+notgz-1ubuntu1.18.04.3 all PEAR Base System
ii php-php-gettext 1.0.12-0.1 all read gettext MO files directly,
ii php-phpseclib 2.0.9-1 all implementations of an arbitrary
ii php-tcpdf 6.2.13+dfsg-1ubuntu1 all PHP class for generating PDF fi
ii php-xml 1:7.2+60ubuntu1 all DOM, SimpleXML, WDDX, XML, and
ii php-zip 1:7.2+60ubuntu1 all Zip module for PHP [default]
ii php7.2 7.2.24-0ubuntu0.18.04.7 all server-side, HTML-embedded scri
ii php7.2-bz2 7.2.24-0ubuntu0.18.04.7 amd64 bzip2 module for PHP
ii php7.2-cli 7.2.24-0ubuntu0.18.04.7 amd64 command-line interpreter for th
ii php7.2-common 7.2.24-0ubuntu0.18.04.7 amd64 documentation, examples and com
ii php7.2-curl 7.2.24-0ubuntu0.18.04.7 amd64 CURL module for PHP
ii php7.2-gd 7.2.24-0ubuntu0.18.04.7 amd64 GD module for PHP
ii php7.2-json 7.2.24-0ubuntu0.18.04.7 amd64 JSON module for PHP
ii php7.2-mbstring 7.2.24-0ubuntu0.18.04.7 amd64 MBSTRING module for PHP
ii php7.2-mysql 7.2.24-0ubuntu0.18.04.7 amd64 MySQL module for PHP
ii php7.2-opcache 7.2.24-0ubuntu0.18.04.7 amd64 Zend OpCache module for PHP
ii php7.2-readline 7.2.24-0ubuntu0.18.04.7 amd64 readline module for PHP
ii php7.2-xml 7.2.24-0ubuntu0.18.04.7 amd64 DOM, SimpleXML, WDDX, XML, and
ii php7.2-zip 7.2.24-0ubuntu0.18.04.7 amd64 Zip module for PHP
ii phpmyadmin 4:4.6.6-5ubuntu0.5 all MySQL web administration tool
3 và dpkg -l | grep php | tee packages.txt
8 nếu được nhắc4. Thêm kho lưu trữ PPA của Ondřej Surý
Nếu bạn đang chạy Ubuntu 22. 04 trở lên thì không cần thêm kho bên dưới này. Thay vào đó, hãy chuyển sang phần 5
Nếu bạn đang chạy Ubuntu 20. 04 hoặc 18. 04, các gói nhị phân PHP 8 chỉ khả dụng trong kho lưu trữ Ondřej Surý PPA. Cài đặt bên dưới
[email protected]p:~# apt-get update
Hit:1 //ppa.launchpad.net/gns3/ppa/ubuntu zesty InRelease
Hit:2 //in.archive.ubuntu.com/ubuntu zesty InRelease
Get:3 //security.ubuntu.com/ubuntu zesty-security InRelease [89.2 kB]
.
.
Fetched 379 kB in 2s [128 kB/s]
Reading package lists.. Done
8Bạn có thể thấy một thông báo chào mừng
đầu ra
[email protected]p:~# apt-get update
Hit:1 //ppa.launchpad.net/gns3/ppa/ubuntu zesty InRelease
Hit:2 //in.archive.ubuntu.com/ubuntu zesty InRelease
Get:3 //security.ubuntu.com/ubuntu zesty-security InRelease [89.2 kB]
.
.
Fetched 379 kB in 2s [128 kB/s]
Reading package lists.. Done
9Nhấn
dpkg -l | grep php | tee packages.txt
8 để thêm kho lưu trữ5. Cài đặt PHP8
Khi viết, PHP 8. 1 hiện đã có sẵn vì vậy chúng tôi sẽ cài đặt cái đó. Nếu có phiên bản mới hơn, hãy đảm bảo thay đổi các lệnh bên dưới để phù hợp
[email protected]:~# apt-get install php7.1
Reading package lists.. Done
Building dependency tree
Reading state information.. Done
.
.
Processing triggers for libc-bin [2.24-9ubuntu2] ...
Processing triggers for ureadahead [0.100.0-19] ...
Processing triggers for systemd [232-21ubuntu2] ...
Processing triggers for ufw [0.35-4] ...
1[email protected]:~# apt-get install php7.1
Reading package lists.. Done
Building dependency tree
Reading state information.. Done
.
.
Processing triggers for libc-bin [2.24-9ubuntu2] ...
Processing triggers for ureadahead [0.100.0-19] ...
Processing triggers for systemd [232-21ubuntu2] ...
Processing triggers for ufw [0.35-4] ...
2đầu ra
dpkg -l | grep php | tee packages.txt
0Nhấn
ii libapache2-mod-php 1:7.2+60ubuntu1 all server-side, HTML-embedded scri
ii libapache2-mod-php7.2 7.2.24-0ubuntu0.18.04.7 amd64 server-side, HTML-embedded scri
ii php 1:7.2+60ubuntu1 all server-side, HTML-embedded scri
ii php-bz2 1:7.2+60ubuntu1 all bzip2 module for PHP [default]
ii php-common 1:60ubuntu1 all Common files for PHP packages
ii php-curl 1:7.2+60ubuntu1 all CURL module for PHP [default]
ii php-gd 1:7.2+60ubuntu1 all GD module for PHP [default]
ii php-mbstring 1:7.2+60ubuntu1 all MBSTRING module for PHP [defaul
ii php-mysql 1:7.2+60ubuntu1 all MySQL module for PHP [default]
ii php-pear 1:1.10.5+submodules+notgz-1ubuntu1.18.04.3 all PEAR Base System
ii php-php-gettext 1.0.12-0.1 all read gettext MO files directly,
ii php-phpseclib 2.0.9-1 all implementations of an arbitrary
ii php-tcpdf 6.2.13+dfsg-1ubuntu1 all PHP class for generating PDF fi
ii php-xml 1:7.2+60ubuntu1 all DOM, SimpleXML, WDDX, XML, and
ii php-zip 1:7.2+60ubuntu1 all Zip module for PHP [default]
ii php7.2 7.2.24-0ubuntu0.18.04.7 all server-side, HTML-embedded scri
ii php7.2-bz2 7.2.24-0ubuntu0.18.04.7 amd64 bzip2 module for PHP
ii php7.2-cli 7.2.24-0ubuntu0.18.04.7 amd64 command-line interpreter for th
ii php7.2-common 7.2.24-0ubuntu0.18.04.7 amd64 documentation, examples and com
ii php7.2-curl 7.2.24-0ubuntu0.18.04.7 amd64 CURL module for PHP
ii php7.2-gd 7.2.24-0ubuntu0.18.04.7 amd64 GD module for PHP
ii php7.2-json 7.2.24-0ubuntu0.18.04.7 amd64 JSON module for PHP
ii php7.2-mbstring 7.2.24-0ubuntu0.18.04.7 amd64 MBSTRING module for PHP
ii php7.2-mysql 7.2.24-0ubuntu0.18.04.7 amd64 MySQL module for PHP
ii php7.2-opcache 7.2.24-0ubuntu0.18.04.7 amd64 Zend OpCache module for PHP
ii php7.2-readline 7.2.24-0ubuntu0.18.04.7 amd64 readline module for PHP
ii php7.2-xml 7.2.24-0ubuntu0.18.04.7 amd64 DOM, SimpleXML, WDDX, XML, and
ii php7.2-zip 7.2.24-0ubuntu0.18.04.7 amd64 Zip module for PHP
ii phpmyadmin 4:4.6.6-5ubuntu0.5 all MySQL web administration tool
3 và dpkg -l | grep php | tee packages.txt
8 nếu được nhắcKhởi động lại Apache
dpkg -l | grep php | tee packages.txt
16. Cài đặt phần mở rộng PHP 8
Lệnh bên dưới bao gồm một số tiện ích mở rộng PHP phổ biến nhất, bao gồm một trang web WordPress điển hình. Tuy nhiên, nếu bạn thấy rằng một số tiện ích mở rộng bị thiếu, hãy tham khảo Bước 1 ở trên và cài đặt các gói bạn yêu cầu theo cách thủ công