- Joined
- Jul 8, 2016
- Messages
- 48
- Points
- 8
PHP 7 was officially launched, if you want to install PHP 7 to experience the speed of it, so I wrote this article guide you to upgrade to PHP 7 for CentOS and Ubuntu operating system and configuration for Apache web server and nginx.
Note that in PHP 7 has many functions have been removed so that if your codes were so old, when upgraded to php7, your website can fail to run, hence you should consider before upgrading it. If the CMS like WordPress, Magento then it is not worry, for WordPress, it should be version 4.3 and Magento is 1.9.2 or higher.
Install PHP 7 on CentOS
CentOS 6.x:
CentOS 7.x:
After that, check with php-v, if the output is:
If you are using Apache:
If you are using NGINX
Type php-v to check php version and if it is showing these
Apply for both CentOS and Ubuntu, when Upgrading to PHP 7, if you use NGINX then you need to edit NGINX config file then your websites run, see path location
Install PHP 7 on CentOS and Ubuntu
Open NGINX config file and find the lines as following
Restart NGINX:
If you are using Apache then restart by this command
For Centos
For Ubuntu
Now you installed PHP 7 successfully on both CentOS and Ubuntu OS.
Note that in PHP 7 has many functions have been removed so that if your codes were so old, when upgraded to php7, your website can fail to run, hence you should consider before upgrading it. If the CMS like WordPress, Magento then it is not worry, for WordPress, it should be version 4.3 and Magento is 1.9.2 or higher.
Install PHP 7 on CentOS
CentOS 6.x:
Code:
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
yum install yum-plugin-replace
yum replace php-common --replace-with=php70w-common
yum install php70w php70w-opcache php70w-mysql
Code:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install yum-plugin-replace
yum replace php-common --replace-with=php70w-common
yum install php70w php70w-opcache php70w-mysql
Install PHP 7 on UbuntuPHP 7.0.0 (cli) (built: Jul 2 2015 18:38:21) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
Code:
sudo add-apt-repository ppa:ondrej/php-7.0
sudo apt-get update
Code:
sudo apt-get install php7.0
sudo apt-get install php7.0-mysql
Code:
sudo apt-get install php7.0-fpm
sudo apt-get install php7.0-mysql
Important: If you are using NGINXPHP 7.0.0-5+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
Apply for both CentOS and Ubuntu, when Upgrading to PHP 7, if you use NGINX then you need to edit NGINX config file then your websites run, see path location
Install PHP 7 on CentOS and Ubuntu
Open NGINX config file and find the lines as following
Code:
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Code:
service nginx restart
For Centos
Code:
systemctl restart httpd
Code:
service apache2 restart