VoIP: (05.02.01) Hướng dẫn cài đặt PHP v7.1 trên CentOS 7 (64bit) trước khi cài đặt FusionPBX cho FreeSwitch v1.6

By , 0 View

Mục tiêu thực hành:
- Cài đặt Required Repositories và các gói Package.
- Kích hoạt Required Remi Repository.
- Cài đặt gói PHP v7.1.
- Kiểm tra phiên bản PHP được cài đặt.

Các bước triển khai:
Cài đặt Required Repositories và các gói Package.
- Cài đặt packages cần thiết trước khi tiến hành cài đặt PHP v7.1.
yum -y update && yum -y install epel-release
yum install git nano httpd unixODBC mysql-connector-odbc memcached ghostscript libtiff-devel libtiff-tools at mariadb mariadb-server tftp-server

- Cài đặt yum-utils và bật kho EPEL.
    + Enable both EPEL and Remi repositories.
yum install epel-release yum-utils -y
yum -y install epel-release.noarch yum-utils

- Tải xuống và cài đặt remirepo bằng lệnh yum.
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Kích hoạt Required Remi Repository.
- Kiểm tra phiên bản PHP hiện đang được cài đặt trên CentOS 7.
    + By default, CentOS 7 ships with PHP version 5.4 which has been officially reached it’s End of life for quite some time “in mid of 2015” and is no longer supported.
[root@localhost ~]# yum info php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos-hcm.viettelidc.com.vn
 * epel: my.mirrors.thegigabit.com
 * extras: centos-hcm.viettelidc.com.vn
 * remi-php71: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: centos-hcm.viettelidc.com.vn
Installed Packages
Name        : php
Arch        : x86_64
Version     : 5.4.16
Release     : 48.el7
Size        : 4.4 M
Repo        : installed
From repo   : base
Summary     : PHP scripting language for creating dynamic web sites
URL         : http://www.php.net/
License     : PHP and Zend and BSD
Description : PHP is an HTML-embedded scripting language. PHP attempts to make it
            : easy for developers to write dynamically generated web pages. PHP also
            : offers built-in database integration for several commercial and
            : non-commercial database management systems, so writing a
            : database-enabled webpage with PHP is fairly simple. The most common
            : use of PHP coding is probably as a replacement for CGI scripts.
            : 
            : The php package contains the module (often referred to as mod_php)
            : which adds support for the PHP language to Apache HTTP Server.

Available Packages
Name        : php
Arch        : x86_64
Version     : 7.1.33
Release     : 13.el7.remi
Size        : 3.0 M
Repo        : remi-php71
Summary     : PHP scripting language for creating dynamic web sites
URL         : http://www.php.net/
License     : PHP and Zend and BSD and MIT and ASL 1.0 and NCSA
Description : PHP is an HTML-embedded scripting language. PHP attempts to make it
            : easy for developers to write dynamically generated web pages. PHP also
            : offers built-in database integration for several commercial and
            : non-commercial database management systems, so writing a
            : database-enabled webpage with PHP is fairly simple. The most common
            : use of PHP coding is probably as a replacement for CGI scripts.
            : 
            : The php package contains the module (often referred to as mod_php)
            : which adds support for the PHP language to Apache HTTP Server.

[root@localhost ~]#

Cài đặt gói PHP v7.1.
yum-config-manager --disable remi-php54

yum-config-manager --enable remi-php71
yum -y install php
yum -y install php php-ldap php-zip php-embedded php-cli php-mysql php-common php-gd php-xml php-mbstring php-mcrypt php-pdo php-soap php-json php-simplexml php-process php-curl php-bcmath php-snmp php-pspell php-gmp php-intl php-imap perl-LWP-Protocol-https php-pear-Net-SMTP php-enchant php-pear php-devel php-zlib php-xmlrpc php-tidy php-opcache php-cli php-pecl-zip unzip gcc

[root@localhost ~]# yum info php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos-hcm.viettelidc.com.vn
 * epel: my.mirrors.thegigabit.com
 * extras: centos-hcm.viettelidc.com.vn
 * remi-php70: ftp.riken.jp
 * remi-php71: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: centos-hcm.viettelidc.com.vn
Installed Packages
Name        : php
Arch        : x86_64
Version     : 7.1.33
Release     : 13.el7.remi
Size        : 9.4 M
Repo        : installed
From repo   : remi-php71
Summary     : PHP scripting language for creating dynamic web sites
URL         : http://www.php.net/
License     : PHP and Zend and BSD and MIT and ASL 1.0 and NCSA
Description : PHP is an HTML-embedded scripting language. PHP attempts to make it
            : easy for developers to write dynamically generated web pages. PHP also
            : offers built-in database integration for several commercial and
            : non-commercial database management systems, so writing a
            : database-enabled webpage with PHP is fairly simple. The most common
            : use of PHP coding is probably as a replacement for CGI scripts.
            : 
            : The php package contains the module (often referred to as mod_php)
            : which adds support for the PHP language to Apache HTTP Server.

[root@localhost ~]#

Kiểm tra phiên bản PHP được cài đặt.
[root@localhost ~]# php -v
PHP 7.1.33 (cli) (built: Feb  3 2021 09:59:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies
[root@localhost ~]# 

- Tắt Firewall.
systemctl disable firewalld
systemctl stop firewalld

- Apache web Server is installed on your system as a dependency for PHP, start its service.
systemctl start httpd

- Kiểm tra dịch vụ Apache web Server.
[root@localhost ~]# ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:b6:c2:d6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.122/24 brd 192.168.100.255 scope global dynamic ens32
       valid_lft 83554sec preferred_lft 83554sec
    inet6 fe80::727b:2e7e:3e87:815/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]#


- Create a info.php file under /var/www/html
echo "<?php phpinfo(); ?>" > /var/www/html/info.php

- Truy cập đường dẫn http://192.168.100.122/info.php

Các liên kết tham khảo:

Mọi thắc mắc, các bạn vui lòng liên hệ với mình thông qua kênh Zalo (Jade Bùi) 076.877.2021.

You Might Also Like

0 comments