Reconfigured Nginx To Use Php7.2
Introduction
Nginx is one of the most popular and powerful web servers available today. It is often used as the primary web server for large websites or as an alternative to Apache web servers. Nginx is capable of serving more concurrent users than Apache, and can handle a much larger load. Nginx also has an edge when it comes to speed and performance due to its architecture and other key factors. However, for Nginx to work properly, it needs to be properly configured and optimized.
In this article, we will demonstrate how to reconfigure Nginx to use the latest version of PHP, PHP 7.2. We will go through the process of reconfiguring Nginx, and the different ways you can optimize it for PHP 7.2.
Prerequisites
Before you begin this guide, you’ll need a few pieces of information:
- A server running Nginx
- A user with sudo privileges
- PHP 7.2 installed on the system
You should also make sure that all of the necessary components and dependencies are installed and up-to-date. You can do this with the following commands:
sudo apt-get update
sudo apt-get upgrade
Step 1 — Installing Nginx
Before we can reconfigure Nginx to use PHP 7.2, we need to install Nginx. We can achieve this by running the following command:
sudo apt-get install nginx
This will install the Nginx web server and all of the necessary dependencies. Once the installation is complete, you should see the following output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
...
Setting up nginx (1.10.3-1ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Step 2 — Configuring Nginx to Use PHP 7.2
Now that Nginx has been installed, we can begin the process of reconfiguring it to use PHP 7.2. First, we need to edit the default Nginx configuration file. The default configuration file is located in the /etc/nginx/sites-enabled/
directory, and is named default
. Open the file with sudo
privileges using your favorite text editor.
sudo nano /etc/nginx/sites-enabled/default
Once you have opened the default configuration file, look for the following line:
index index.html index.htm;
Below this line, add the following line:
index index.php index.html index.htm;
Save and close the configuration file, then check the syntax with the following command:
sudo nginx -t
If the test is successful, you should see the following output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Once the syntax has been checked, the changes can be applied by restarting the Nginx service:
sudo systemctl restart nginx
Step 3 — Testing PHP 7.2
Now that we have reconfigured Nginx to use PHP 7.2, we can test the setup by creating a test.php
file in the web root directory. We can do this using the following command:
sudo nano /var/www/html/test.php
Add the following code to the file and save it:
The phpinfo()
function displays information on the installed version of PHP, including the version and which modules are installed. To view this information, open your web browser and browse to http://your_server_ip/test.php
. You should see a page that looks like this:

At the bottom of the page you should see the version of PHP displayed. If you see PHP 7.2 listed as the version, then the Nginx configuration was successful.
Step 4 — Optimizing Nginx For PHP 7.2
Although you are now able to serve PHP pages, there is still more optimization work to do. Below are some suggestions that will help improve the performance of your web server:
Tune your Nginx configuration file for best performance.
Install the latest version of Nginx.
Enable FastCGI cache.
Install the PHP-FPM extension.
For more information on how to optimize Nginx for PHP 7.2, you can refer to our Optimizing Nginx for PHP 7.2 guide.
Conclusion
In this article, we have demonstrated how to reconfigure Nginx to use PHP 7.2. We have shown how to install Nginx, configure it to use PHP 7.2 and test the setup, as well as how to optimize it for best performance. We hope that this has been useful and that you have a better understanding of how to reconfigure Nginx for PHP 7.2.
FAQs
What is Nginx?
Nginx (pronounced “engine-ex”) is a web server software created in 2004 by Igor Sysoev and publicly released in 2004. It is known for its high performance, stability, and low resource consumption. Nginx has become one of the most popular web servers in the world.
Does Nginx Support PHP?
Yes, Nginx supports PHP, and it can be configured to use the latest version of PHP, PHP 7.2. This can be done by following the steps outlined in this article.
Is Nginx Faster Than Apache?
Yes, Nginx is generally faster than Apache. Nginx is able to serve more concurrent users than Apache, and can better handle large loads due to its architecture and other factors.
Thank you for reading this article. Please read other articles.
Related Posts:
- Nginx Multiple Apps Same Server Nginx Multiple Apps Same Server What is Nginx? Nginx is a popular open source web server software, responsible for taking user requests from a web browser, processing the request and…
- How To Hide Nginx In Centos 7 How To Hide Nginx In Centos 7 What is Nginx? Nginx is a powerful web server and is one of the most popular web server software available today. It's a…
- Codeigniter 404 Not Found Nginx Reverse Proxy Codeigniter 404 Not Found Nginx Reverse Proxy What is CodeIgniter? CodeIgniter is an open-source software development framework used for developing web applications written in PHP. The primary goal of CodeIgniter…
- Nginx And Apache Together Centos Nginx and Apache Together in Centos Overview A popular choice for websites is using the powerful combination of Nginx and Apache together. The two web servers are both reliable and…
- Nginx Ssi Inside Ssi Config Nginx SSI Inside SSI Config What is Nginx SSI? Nginx SSI (Server Side Includes) is an Apache web server module that enables users to embed dynamic HTML content into a…
- Ubuntu Install Nginx Php7.2 Mysql Ubuntu Install Nginx Php7.2 Mysql What is Nginx? Nginx is an open source web server that is very popular for powering web applications such as WordPress and Drupal. It is…
- Centos 6 Nginx Auto Reject When Upload Files Centos 6 Nginx Auto Reject When Upload Files Introduction to Centos 6 Centos 6 is a powerful, open-source Linux distribution that has been designed for advanced user, administrators, and server…
- How To Disable Nginx On Plesk Nginx How To Disable Nginx On Plesk Nginx What Is Nginx? Nginx is a web server and reverse proxy application that's similar to Apache but faster and more optimized for high…
- Sudo Systemctl Status Nginx.Service Sudo Systemctl Status Nginx.Service What is Nginx? Nginx is a free, open-source, high-performance web server that claims to offer better performance and scalability than Apache. Nginx also provides a reverse…
- Install Nginx Php Mysql Phpmyadmin Ubuntu 18.04 Install Nginx Php Mysql Phpmyadmin Ubuntu 18.04 Introduction In this article, we will demonstrate how to install Nginx, PHP, MySQL, and phpMyAdmin on an Ubuntu 18.04 server. Nginx is a…
- Linuxacademy-Nginx-Web-Server-Deep-Dive.Part05.Rar Following are the subtitles. Linuxacademy-Nginx-Web-Server-Deep-Dive.Part05.Rar Introduction to Nginx This article is the fifth part of the Linux Academy Nginx Web Server Deep Dive series. Nginx is a highly efficient, lightweight…
- Install Nginx Php Raspberry Pi Install Nginx Php Raspberry Pi What Is a Raspberry Pi? The Raspberry Pi is a low-cost, energy-saving device, made primarily for educational purposes. It is a small, single board computer…
- Nginx Php-Fpm Php Stack Overflow Articel Nginx Php-Fpm Php Stack Overflow Articel What Is Nginx? Nginx (pronounced engine-x) is an open source web server and reverse proxy software that is popular for its high performance and…
- Install Nginx And Php On Ubuntu 18.04 Install Nginx And Php On Ubuntu 18.04 Introduction In this article, we will guide you on how to install Nginx and php on Ubuntu 18.04. Nginx is a popular web…
- Nginx Php-Fpm Permission Denied Nginx + PHP-FPM - Permission Denied Issue What is Nginx? Nginx is an open source web server and reverse proxy. It is an ideal platform for building high performance, scalable…
- Ubuntu Server18 How To Enable Nginx Pdo Mysql Ubuntu Server18: How to Enable Nginx Pdo Mysql As a developer, you may have heard of Nginx, PDO, and MySQL – all are essential components of web applications. Nginx is…
- Nginx Reverse Proxy Apache Change Document Roo Nginx Reverse Proxy Apache Change Document Roo What is Nginx and Apache? Nginx and Apache are two of the most popular open source web servers out there. Nginx is known…
- Setting Up Php7 With Nginx Setting up PHP7 With Nginx What is PHP7? PHP7 is the most recent major release of PHP, a server-side scripting language used for dynamic web pages. PHP7 provides accelerated performance,…
- Nginx Vs Apache Performance Benchmark Nginx Vs Apache Performance Benchmark Introduction As web development continues to evolve, it’s essential for websites to stay ahead of the competition. Using the right server-side web service is essential…
- Nginx Vs Apache Wordpress Benchmark Nginx Vs Apache Wordpress Benchmark What Are Nginx and Apache? Nginx and Apache are two of the most popular web server software applications on the market today. Nginx is a…
- Performance Php Nginx Vs Nodejs Performance Php Nginx Vs Nodejs Introduction to PHP and Nginx PHP is a widely popular scripting language that is used for web development. It has various features such as the…
- Nginx Var Www Not Found Nginx Var Www Not Found What Is Nginx Var Www? Nginx Var Www is a technology that allows users to access websites via the Nginx server. It is based on…
- Reverse Proxy Nginx Dan Haproxy Reverse Proxy Nginx Dan Haproxy Introduction to Reverse Proxy Reverse proxy is a server that sits between a user and the destination server. It can be used to direct web…
- What If Create New File At Site-Available Nginx What If Create New File At Site-Available Nginx? What is Nginx? Nginx is an open-source HTTP server and reverse proxy, which is used to power websites such as sites, wikis,…
- Webmin Change Apaceh With Nginx Webmin Change Apache With Nginx Understanding Apache and Nginx Apache and Nginx are two of the most popular web servers on the market. Both are open source, highly configurable and…
- Nginx Unable To Open Primary Script Permission Denied Nginx Unable To Open Primary Script Permission Denied What Is Nginx? Nginx (Engine X) is a powerful, high-performance HTTP server and reverse proxy. It has a scalable architecture, designed to…
- Ubuntu Nginx Php-Fpm Short Cut Ubuntu Nginx Php-Fpm Short Cut What Is Nginx? Nginx is a web server software package developed by Igor Sysoev for use with the Linux operating system. It is open source…
- Install Nginx And Php On Ubuntu Install Nginx And Php On Ubuntu A Comprehensive Tutorial to Install Nginx And Php On Ubuntu Nginx and PHP are two of the most popular web server and scripting language…
- Arrti Nginx 1.2.1 Arrti Nginx 1.2.1 What is Nginx? Nginx is a fast and powerful open-source web server platform that can be used to serve webpages and applications. It is widely used on…
- Nginx Handle Large Upload Data Post Wordpress Nginx Handle Large Upload Data Post Wordpress Why Do We Need to Handle Large Upload Data in Wordpress? WordPress is used on a wide variety of platforms and web servers.…