Sure… we have now PHP 8.0.0 on the stack! Yes, with year 2020 at the end of our eyes,, PHP Group has recently been rolled out major update for its PHP language. PHP 8.0 brings many new features, improvements and optimizations than the previous version – PHP 7.4. It’s claimed bring many improvement in the error handling, type stream and consistency.

On our customer server, we have tested many website using PHP 7.3 / PHP 7.4 and it’s trully faster and stable compared to the previous PHP version.

Well, on this today guide i will teach you on how to install and configuring Nginx web server with PHP 8.0 on CentOS 8 machine. I am using $5 Digital Ocean droplet on this testing purpose. So, let’s follow this simple tutorial.

Make sure you have full root access on the server. And if you are Windows user, you can use PuTTy command line terminal to login into your virtual private server. Since i am Linux user, so I can using both PuTTy and default Gnome Linux terminal. 🙂

REQUIREMENTS:
* Cloud Server with CentOS 8 Machine
* Server IPv4 Address
* Full Root Access
* PuTTy or Gnome Terminal

1.) Login to your server via Terminal.

$ ssh [email protected]

2.) Run system update

Since this is fresh server, so we need to run system update to make sure that the OS having the software packages.

$ dnf update

Install the following required packages, since we are using CentOS 8 minimal installation.

$ dnf install nano wget screen telnet curl -y

3.) Install Nginx web server

We can using default CentOS 8 repository in order install Nginx web server on our cloud machine. Simply run the following command.

$ dnf install nginx -y

Check Nginx version

$ nginx -v
$ nginx version: nginx/1.14.1

However, if you want the latest stable or mainline version of Nginx web server, simply add Nginx repository from Official Nginx website.

$ nano /etc/yum.repos.d/nginx.repo

# Nginx stable release

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

# Nginx mainline release

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

After we have Nginx installed on the system, don’t forget to enable it and run start command.

$ systemctl enable nginx.service
$ systemctl start nginx.service

4.) Install PHP 8.0 with FPM module (FastCGI Process Manager)

Now let’s install PHP 8.0 on your machine. Since we are using Nginx web server, so we must have PHP-FPM module (FastCGI Process Manager) installed on the machine.

First of all, we should add Epel release 8 and remi repository for CentOS 8 to the virtual machine. Simply run the following command.

$ dnf install epel-release
$ wget http://rpms.remirepo.net/enterprise/remi-release-8.rpm
$ rpm -Uvh remi-release-8.rpm

Run system update again:

$ dnf update

Let’s install PHP 8.0 with FastCGI Process Manager.

$ dnf module reset php
$ dnf module install php:remi-8.0

5.) Install PHP 8.0 Extensions

For example Zend OPcache if you want to have OPcache installed on your machine. Sure… in term of caching module, i will share on the next following tutorial on how to tune Zend OPcache in order to make your site more faster.

$ dnf install php-opcache
Last metadata expiration check: 0:16:23 ago on Thu 10 Dec 2020 07:43:48 PM UTC.
Dependencies resolved.
======================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================
Installing:
php-opcache x86_64 8.0.0-1.el8.remi remi-modular 750 k

Transaction Summary
======================================================================================================================================================
Install 1 Package

Total download size: 750 k
Installed size: 2.6 M
Is this ok [y/N]: y

6.) Configure PHP-FPM 8.0 Pools to Run with Nginx

In order to make Nginx web server can connect properly with PHP 8.0, we should slighly modify PHP-FPM Pools (www.con). Also, you can edit php.ini file if you want make some tweaks to the PHP settings.

$ nano /etc/php.ini

For example, you can change memory_limit variable from 128M to 256M or date.timezone variables.

; Maximum amount of mem
; http://php.net/memory
memory_limit = 256M

Now, let’s open PHP-FPM Pools configuration and please take a look at line of “listen = /run/php-fpm/www.sock”. That’s should be included on Nginx serverblock if you want to make your site running on Nginx with PHP8-FPM. :

$ nano /etc/php-fpm.d/www.conf
; Note: This value is mandatory.
listen = /run/php-fpm/www.sock

; Set listen(2) backlog.
; Default Value: 511
;listen.backlog = 511

; Set permissions for unix socket, if one is used. In Linux, read/write

7.) Restart and Enable PHP8-FPM Service

$ systemctl enable php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.serv
$ systemctl restart php-fpm.service

Check your PHP 8.0 version

$ php -v
PHP 8.0.0 (cli) (built: Nov 24 2020 17:04:03) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
[[email protected] ~]#

Now, we have Nginx web server with PHP8-FPM installed and running on CentOS 8 machine. It’s very easy to learn it, you should having relax time to learn on it and then configuring on your cloud machine itself.

LEAVE A REPLY

Please enter your comment!
Please enter your name here