Nginx is a web server. A web server is the program that gets requests from a client (the browser) and returns responses (like a web page) to the client through HTTP. It’s able to accept requests and return responses through the HTTP protocol.
Does PHP tie into Nginx?
PHP does not really tie into Nginx or vice versa. Nginx just decides what to do with a request and where to send it. You can try to make a request to a website, but nothing will happen if Nginx isn’t listening for that request. You are the one who decides the general rules for requests. You create these rules in a configuration file.
Like many web technologies, it’s possible to do a lot with Nginx, but many things you can do in Nginx can also be done in PHP.
Nginx also lets you serve multiple websites from a single IP address. This is known as virtual hosting.
Sometimes, walking through the steps helps you to understand something better.
- Enter URL into a browser. https://paircode.com/forums/forum/general
- Hit enter.
- The browser (the client/user agent) makes an HTTP request to the server at pair code. com. The DNS is responsible for pointing the domain to the server using an IP address.
- The Nginx web server gets this request.
- It then looks up rules that you set up to decide where to send the request. It can send the request to a PHP file.
- The PHP file gets the requests and builds out the web page.
- PHP gives the HTML page back to the web server (Nginx), and NginX sends the HTML page (the response) back to the browser through HTTP.
Instead of sending an HTML page, the web server can also send back other files, like images, videos, CSS, and JavaScript files.
Some languages have packages that are web servers. In C#, the ASP.NET framework has a built-in server called Kestrel.
NodeJS has a package called “http”. This package which is used in place of Nginx.
Becoming familiar with Nginx is important, especially if you want to become a back end web developer. In the end, it’s just one more tool to add to your belt.