Nginx File Configuration and Logs (Part 3)
Introduction:
after installing and going to Nginx directory /etc/nginx we can see Nginx file Like, nginx.config and sites-available file and other important files
each file of this has a role and task to make Nginx correct jobs.
in this article, I will explain important files to make correct Nginx and handle all requests without any problem.
all parts of Nginx Articles?:
Nginx Files:
to access nginx directory. in Linux Os
root@ubuntu-16gb-hel1-1:/etc/nginx# cd /etc/nginx/
to see all files inside Nginx directory you can use the following command
root@ubuntu-16gb-hel1-1:/etc/nginx# ls
the output from the above command :
you can see here all the nginx file.
we will start with nginx.config:
all of the Nginx main configuration?you can find it here ,?
we can write our own configuration in this file and Nginx setup here.?
we can write HTTP block here to define our configuration in all Nginx system.
in the next section will write our configuration and talk about each block in Nginx configuration
here we can write site domain and server block with configuration to specific application, and when reload Nginx nginx.config will read all files inside etc/sites-available/ folder.
but to enable this feature you must write the following configuration inside nginx.config
nginx by default will create the same file in sites-enabled with the same name.
include /etc/nginx/sites-enabled/fileName;
when create a new directory you must link with configuration file by site-enable
you must linked sites-available/ with sites-enabled/ because /nginx.config need linked with /sites-enabled/ to enabled your configuration
领英推荐
if we have any repeated configuration between services we can include inside this file and share it with other configuration files.
okay now we know where we can make our configration but where I can see my logs
when install nginx will created file in /var/log/nginx
inside this directory, we can find all logs from Nginx services.
okay lets go to above directory and see what the logs provide services
to go to above directory you can use the following command:
cd /var/log/nginx/
and to see all files in /var/log/nginx write the follwoing command:
ls
after that, you can see this file in output.
i will explain two important files in the logs section in this article.
every request received to Nginx will record in this file like the following image.
we can changed this file from configuration file.
each Nginx error will record here like the follwoing image.
i have one error just :)
Conclusion:
in this article, we know now what is the files job in Nginx and where we need each files in the Nginx system.?
and now we know where we can find our logs of each request in our system, with know where we can define our configuration.?
Nginx is easy to use and I will explain about configuration in the next article
all parts of Nginx Articles?: