Nginx is an open source Linux web server that accelerates content while utilizing low resources. Known for its performance and stability Nginx has many other uses such as load balancing, reverse proxy, mail proxy, and HTTP cache. Nginx, by default, does not execute PHP scripts and must be configured to do so. In this tutorial, we will show you how to enable and test PHP capabilities with your server.
- This article assumes you are logged in as root and using Ubuntu 16.04 LTS server. If not logged in as root, please add sudo before each command or login as root user.
- This article also assumes you have installed Nginx. If you have not yet installed Nginx or are unsure how to do so, please reference this easy to follow article.
- This article is tested using NGINX 1.10.3+, older versions should work, but it’s a good idea to update to the latest version if available before you try to configure PHP.
- This article will be running php7.0-fpm or later (as of Dec 31, 2018, PHP 5.6 will be approaching “end of life” and no longer supported.)
Step 1a: Give Me the Packages!
First, we want to make sure our manager is up-to-date. Run the following command
sudo apt-get update && apt-get upgrade
You also want to make sure that your Nginx is up-to-date. You can check the current version by running this command.
The result should return something like this.
Note: This article is using Nginx 1.10.3. If you need to update your Nginx version make sure you backup your configuration BEFORE you make any changes.
sudo cp /etc/nginx/nginx.conf / etc/nginx/nginx.conf.1.x.x.backup
This article will NOT cover updating your Ngnix as its focus is for PHP configuration.