Bước 2. Cài đặt kho lưu trữ
Để nâng cấp PHP 5. 6, bạn sẽ cần cài đặt và kích hoạt các kho lưu trữ của bên thứ ba như REMI và EPEL. Thực hiện theo các URL bên dưới để cài đặt và kích hoạt kho lưu trữ
- Cài đặt kho lưu trữ REMI
- Cài đặt Kho lưu trữ EPEL
Bước 3. Gỡ bỏ PHP 5. 3 phiên bản
Bây giờ, bạn sẽ cần chạy lệnh bên dưới để xóa PHP 5 của mình. 3 phiên bản
# yum remove php-common
Bạn sẽ nhận được một số đầu ra như dưới đây
Loaded plugins: fastestmirror Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package php-common.i686 0:5.3.3-48.el6_8 will be erased --> Processing Dependency: php[api] = 20090626 for package: php-mcrypt-5.3.3-5.el6.i686 --> Processing Dependency: php[language] >= 5.3 for package: php-tcpdf-6.2.11-1.el6.noarch --> Processing Dependency: php[language] >= 5.2.17 for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php[zend-abi] = 20090626 for package: php-mcrypt-5.3.3-5.el6.i686 --> Processing Dependency: php-bz2 for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-ctype for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-curl for package: php-tcpdf-6.2.11-1.el6.noarch --> Processing Dependency: php-curl for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-date for package: php-tcpdf-6.2.11-1.el6.noarch --> Processing Dependency: php-date for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-filter for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-hash for package: php-tcpdf-6.2.11-1.el6.noarch --> Processing Dependency: php-hash for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-iconv for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-json for package: php-tcpdf-6.2.11-1.el6.noarch --> Processing Dependency: php-json for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-libxml for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-openssl for package: php-tcpdf-6.2.11-1.el6.noarch --> Processing Dependency: php-pcre for package: php-tcpdf-6.2.11-1.el6.noarch --> Processing Dependency: php-pcre for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-session for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-simplexml for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-spl for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-zip for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-zlib for package: php-tcpdf-6.2.11-1.el6.noarch --> Processing Dependency: php-zlib for package: phpMyAdmin-4.0.10.17-2.el6.noarch --> Processing Dependency: php-common for package: php-php-gettext-1.0.11-12.el6.noarch --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-pdo-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-gd-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-mysql-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-tidy-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-xml-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-fpm-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-cli-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-process-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-mbstring-5.3.3-48.el6_8.i686 --> Processing Dependency: php-common[x86-32] = 5.3.3-48.el6_8 for package: php-bcmath-5.3.3-48.el6_8.i686 --> Running transaction check ---> Package php.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-bcmath.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-cli.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-fpm.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-gd.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-mbstring.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-mcrypt.i686 0:5.3.3-5.el6 will be erased ---> Package php-mysql.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-pdo.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-php-gettext.noarch 0:1.0.11-12.el6 will be erased ---> Package php-process.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-tcpdf.noarch 0:6.2.11-1.el6 will be erased --> Processing Dependency: php-tcpdf = 6.2.11-1.el6 for package: php-tcpdf-dejavu-sans-fonts-6.2.11-1.el6.noarch ---> Package php-tidy.i686 0:5.3.3-48.el6_8 will be erased ---> Package php-xml.i686 0:5.3.3-48.el6_8 will be erased ---> Package phpMyAdmin.noarch 0:4.0.10.17-2.el6 will be erased --> Running transaction check ---> Package php-tcpdf-dejavu-sans-fonts.noarch 0:6.2.11-1.el6 will be erased --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================== Removing: php-common i686 5.3.3-48.el6_8 @updates 2.9 M Removing for dependencies: php i686 5.3.3-48.el6_8 @updates 3.3 M php-bcmath i686 5.3.3-48.el6_8 @updates 27 k php-cli i686 5.3.3-48.el6_8 @updates 6.3 M php-fpm i686 5.3.3-48.el6_8 @updates 3.3 M php-gd i686 5.3.3-48.el6_8 @updates 312 k php-mbstring i686 5.3.3-48.el6_8 @updates 1.9 M php-mcrypt i686 5.3.3-5.el6 @epel 38 k php-mysql i686 5.3.3-48.el6_8 @updates 189 k php-pdo i686 5.3.3-48.el6_8 @updates 150 k php-php-gettext noarch 1.0.11-12.el6 @epel 57 k php-process i686 5.3.3-48.el6_8 @updates 53 k php-tcpdf noarch 6.2.11-1.el6 @epel 11 M php-tcpdf-dejavu-sans-fonts noarch 6.2.11-1.el6 @epel 1.5 M php-tidy i686 5.3.3-48.el6_8 @updates 44 k php-xml i686 5.3.3-48.el6_8 @updates 275 k phpMyAdmin noarch 4.0.10.17-2.el6 @epel 20 M Transaction Summary ====================================================================================================================================== Remove 17 Package[s]
Bước 4. Cài đặt PHP5. 6 Phiên bản
Sau khi gỡ bỏ PHP 5. 3. Bạn sẽ cần chạy lệnh bên dưới để cài đặt PHP 5. 6 phiên bản
# yum install php php-gd php-mysql php-mcrypt -y
Bạn sẽ nhận được một số đầu ra như dưới đây
Loaded plugins: fastestmirror Setting up Install Process Loading mirror speeds from cached hostfile * base: mirror.nbrc.ac.in * epel: epel.excellmedia.net * extras: mirror.nbrc.ac.in * remi: mirror.oxilion.nl * remi-php56: mirror.oxilion.nl * remi-safe: mirror.oxilion.nl * updates: mirror.fibergrid.in Package php-mysql is obsoleted by php-mysqlnd, trying to install php-mysqlnd-5.6.29-1.el6.remi.i686 instead Resolving Dependencies --> Running transaction check ---> Package php.i686 0:5.6.29-1.el6.remi will be installed --> Processing Dependency: php-common[x86-32] = 5.6.29-1.el6.remi for package: php-5.6.29-1.el6.remi.i686 --> Processing Dependency: php-cli[x86-32] = 5.6.29-1.el6.remi for package: php-5.6.29-1.el6.remi.i686 ---> Package php-gd.i686 0:5.6.29-1.el6.remi will be installed ---> Package php-mcrypt.i686 0:5.6.29-1.el6.remi will be installed ---> Package php-mysqlnd.i686 0:5.6.29-1.el6.remi will be installed --> Processing Dependency: php-pdo[x86-32] = 5.6.29-1.el6.remi for package: php-mysqlnd-5.6.29-1.el6.remi.i686 --> Running transaction check ---> Package php-cli.i686 0:5.6.29-1.el6.remi will be installed ---> Package php-common.i686 0:5.6.29-1.el6.remi will be installed --> Processing Dependency: php-pecl-zip[x86-32] for package: php-common-5.6.29-1.el6.remi.i686 --> Processing Dependency: php-pecl-jsonc[x86-32] for package: php-common-5.6.29-1.el6.remi.i686 ---> Package php-pdo.i686 0:5.6.29-1.el6.remi will be installed --> Running transaction check ---> Package php-pecl-jsonc.i686 0:1.3.10-1.el6.remi.5.6 will be installed ---> Package php-pecl-zip.i686 0:1.13.5-1.el6.remi.5.6 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================== Installing: php i686 5.6.29-1.el6.remi remi-php56 2.7 M php-gd i686 5.6.29-1.el6.remi remi-php56 75 k php-mcrypt i686 5.6.29-1.el6.remi remi-php56 48 k php-mysqlnd i686 5.6.29-1.el6.remi remi-php56 270 k Installing for dependencies: php-cli i686 5.6.29-1.el6.remi remi-php56 4.1 M php-common i686 5.6.29-1.el6.remi remi-php56 1.1 M php-pdo i686 5.6.29-1.el6.remi remi-php56 114 k php-pecl-jsonc i686 1.3.10-1.el6.remi.5.6 remi-php56 51 k php-pecl-zip i686 1.13.5-1.el6.remi.5.6 remi-php56 51 k Transaction Summary ====================================================================================================================================== Install 9 Package[s] Total download size: 8.4 M Installed size: 29 M Downloading Packages: [1/9]: php-5.6.29-1.el6.remi.i686.rpm | 2.7 MB 00:03 [2/9]: php-cli-5.6.29-1.el6.remi.i686.rpm | 4.1 MB 00:10 [3/9]: php-common-5.6.29-1.el6.remi.i686.rpm | 1.1 MB 00:02 [4/9]: php-gd-5.6.29-1.el6.remi.i686.rpm | 75 kB 00:00 [5/9]: php-mcrypt-5.6.29-1.el6.remi.i686.rpm | 48 kB 00:00 [6/9]: php-mysqlnd-5.6.29-1.el6.remi.i686.rpm | 270 kB 00:00 [7/9]: php-pdo-5.6.29-1.el6.remi.i686.rpm | 114 kB 00:00 [8/9]: php-pecl-jsonc-1.3.10-1.el6.remi.5.6.i686.rpm | 51 kB 00:00 [9/9]: php-pecl-zip-1.13.5-1.el6.remi.5.6.i686.rpm | 51 kB 00:00 -------------------------------------------------------------------------------------------------------------------------------------- Total 427 kB/s | 8.4 MB 00:20 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : php-pecl-jsonc-1.3.10-1.el6.remi.5.6.i686 1/9 WARNING : These php-* RPMs are not official Fedora / Red Hat build and overrides the official ones. Don't file bugs on Fedora Project nor Red Hat. Use dedicated forum at //forum.remirepo.net/ Installing : php-common-5.6.29-1.el6.remi.i686 2/9 Installing : php-pecl-zip-1.13.5-1.el6.remi.5.6.i686 3/9 Installing : php-cli-5.6.29-1.el6.remi.i686 4/9 Installing : php-pdo-5.6.29-1.el6.remi.i686 5/9 Installing : php-mysqlnd-5.6.29-1.el6.remi.i686 6/9 Installing : php-5.6.29-1.el6.remi.i686 7/9 Installing : php-mcrypt-5.6.29-1.el6.remi.i686 8/9 Installing : php-gd-5.6.29-1.el6.remi.i686 9/9 Verifying : php-pecl-zip-1.13.5-1.el6.remi.5.6.i686 1/9 Verifying : php-cli-5.6.29-1.el6.remi.i686 2/9 Verifying : php-5.6.29-1.el6.remi.i686 3/9 Verifying : php-mcrypt-5.6.29-1.el6.remi.i686 4/9 Verifying : php-pecl-jsonc-1.3.10-1.el6.remi.5.6.i686 5/9 Verifying : php-gd-5.6.29-1.el6.remi.i686 6/9 Verifying : php-mysqlnd-5.6.29-1.el6.remi.i686 7/9 Verifying : php-pdo-5.6.29-1.el6.remi.i686 8/9 Verifying : php-common-5.6.29-1.el6.remi.i686 9/9 Installed: php.i686 0:5.6.29-1.el6.remi php-gd.i686 0:5.6.29-1.el6.remi php-mcrypt.i686 0:5.6.29-1.el6.remi php-mysqlnd.i686 0:5.6.29-1.el6.remi Dependency Installed: php-cli.i686 0:5.6.29-1.el6.remi php-common.i686 0:5.6.29-1.el6.remi php-pdo.i686 0:5.6.29-1.el6.remi php-pecl-jsonc.i686 0:1.3.10-1.el6.remi.5.6 php-pecl-zip.i686 0:1.13.5-1.el6.remi.5.6 Complete!
Sau khi cài đặt PHP 5. 6, bạn sẽ cần khởi động lại dịch vụ Apache của mình để có hiệu lực
# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
Bước #5. Xác minh đang chạy phiên bản PHP hiện tại trên hệ thống
Chạy lệnh bên dưới để xác minh phiên bản hiện tại của PHP
Sử dụng dòng lệnh
________số 8Bạn sẽ nhận được một số đầu ra như trên
Sử dụng trang thông tin PHP
Tạo phpinfo. trang php trên tài liệu web của bạn với văn bản bên dưới
# vim /var/www/html/phpinfo.php
Lưu và thoát
Nhập url bên dưới vào trình duyệt của bạn
//ip_domain_name/phpinfo.php
Bạn sẽ nhận được kết quả dưới đây trong trình duyệt của mình
Bây giờ bạn có thể thấy PHP 5. 3 đã được nâng cấp lên PHP 5. 6
Tôi hy vọng bài viết này sẽ hữu ích để hiểu cách chúng ta có thể nâng cấp PHP 5. 3 to PHP 5. 6 trên CentOS 6. x và RHEL 6. hệ thống x