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-releaseyum 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 phpLoaded plugins: fastestmirrorLoading 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.vnInstalled PackagesName : phpArch : x86_64Version : 5.4.16Release : 48.el7Size : 4.4 MRepo : installedFrom repo : baseSummary : PHP scripting language for creating dynamic web sitesURL : http://www.php.net/License : PHP and Zend and BSDDescription : 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 PackagesName : phpArch : x86_64Version : 7.1.33Release : 13.el7.remiSize : 3.0 MRepo : remi-php71Summary : PHP scripting language for creating dynamic web sitesURL : http://www.php.net/License : PHP and Zend and BSD and MIT and ASL 1.0 and NCSADescription : 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 phpLoaded plugins: fastestmirrorLoading 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.vnInstalled PackagesName : phpArch : x86_64Version : 7.1.33Release : 13.el7.remiSize : 9.4 MRepo : installedFrom repo : remi-php71Summary : PHP scripting language for creating dynamic web sitesURL : http://www.php.net/License : PHP and Zend and BSD and MIT and ASL 1.0 and NCSADescription : 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 -vPHP 7.1.33 (cli) (built: Feb 3 2021 09:59:18) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologieswith Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies[root@localhost ~]#
- Tắt Firewall.
systemctl disable firewalldsystemctl 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 address1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:b6:c2:d6 brd ff:ff:ff:ff:ff:ffinet 192.168.100.122/24 brd 192.168.100.255 scope global dynamic ens32valid_lft 83554sec preferred_lft 83554secinet6 fe80::727b:2e7e:3e87:815/64 scope linkvalid_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.
0 comments