Background

Installing PHP in CentOS

entry image

Centos

Centos Version


[root@localhost usr]# rpm -q centos-release
centos-release-7-6.1810.2.el7.centos.x86_64

Install php72 centos7

$ sudo yum install epel-release
...

$ sudo yum-config-manager --enable remi-php72
...

$ sudo yum update
...
Install    3 Packages (+33 Dependent packages)
Upgrade  523 Packages

Total download size: 767 M
Is this ok [y/d/N]: n
Exiting on user command

[root@localhost logs]# cd ~
[root@localhost ~]# php -i > oldphpi
[root@localhost ~]# php -m > oldphpm

$ sudo yum install php72

$ php -v
PHP 7.0.33 (cli) (built: May 28 2019 09:26:45) ( NTS )
Copyright (c) 1997-2017 The PHP Group

[root@localhost ~]# which php
/usr/bin/php

[root@localhost ~]# php72 -v
PHP 7.2.28 (cli) (built: Feb 18 2020 11:21:09) ( NTS )

[root@localhost ~]# ln -s /user/bin/php72 /usr/bin/php
ln: failed to create symbolic link ‘/usr/bin/php’: File exists

[root@localhost ~]# mv /usr/bin/php /usr/bin/php70

[root@localhost ~]# ln -s /usr/bin/php72 /usr/bin/php

[root@localhost ~]# php -v
PHP 7.2.28 (cli) (built: Feb 18 2020 11:21:09) ( NTS )

[root@localhost ~]# yum --enablerepo=remi-php72 install bcmath bz2 calendar Core ctype curl date dom exif fileinfo filter ftp gd gettext hash iconv json libxml mbstring mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix readline Reflection session shmop SimpleXML sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlwriter xsl Zend OPcache zip zlib

[root@localhost ~]# yum --enablerepo=remi-php72 install php-bcmath php-bz2 php-calendar php-Core php-ctype php-curl php-date php-dom php-exif php-fileinfo php-filter php-ftp php-gd php-gettext php-hash php-iconv php-json php-libxml php-mbstring php-mysqli php-mysqlnd php-openssl php-pcntl php-pcre php-PDO php-pdo_mysql php-pdo_sqlite php-Phar php-posix php-readline php-Reflection php-session php-shmop php-SimpleXML php-sockets php-SPL php-sqlite3 php-standard php-sysvmsg php-sysvsem php-sysvshm php-tidy php-tokenizer php-wddx php-xml php-xmlreader php-xmlwriter php-xsl php-Zend OPcache php-zip php-zlib

[root@localhost usr]# which php
/usr/bin/php

[root@localhost usr]# whereis php
php: /usr/bin/php /usr/lib64/php /etc/php.d /etc/php.ini /usr/share/php /usr/share/man/man1/php.1.gz

[root@localhost ~]# sudo systemctl restart httpd.service

Apache

$ sudo systemctl restart httpd.service
$ sudo systemctl stop httpd.service
$ sudo systemctl start httpd.service

$ sudo apachectl –k restart
$ apachectl –k stop

Force Apache to refresh the configuration files:
$ sudo systemctl reload httpd.service

Set Apache to run when the system boots:
$ sudo systemctl enable httpd.service

Prevent Apache from loading when the system boots:
$ sudo systemctl disable httpd.service

$ systemctl status httpd

https://phoenixnap.com/kb/how-to-restart-apache-centos-linux