Where is nginx.conf file? (Nginx Server configuration file)
In this tutorial we'll take a look at how to find nginx.conf file
It's hard to find nginx.conf because it depends on how Nginx was installed
To find nginx.conf file on your system run this on your command line:
nginx -t
Look for location of nginx.conf file in the cmd output:
$ nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful $ nginx -Vnginx version: nginx/1.11.1
built by gcc 4.9.2 (Debian 4.9.2-10)built with OpenSSL 1.0.1k 8 Jan 2015
TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf
The location of the Nginx configuration file, nginx.conf, depends on how Nginx was installed and configured on your system. In most cases, the configuration file is located in the conf directory within the Nginx installation directory.
On Linux systems, the default installation directory for Nginx is /usr/local/nginx, so the nginx.conf file is typically located at /usr/local/nginx/conf/nginx.conf.
On Windows systems, the default installation directory for Nginx is C:\nginx, so the nginx.conf file is typically located at C:\nginx\conf\nginx.conf.
If you are unsure where the nginx.conf file is located on your system, you can try searching for it using the find or locate command on Linux, or the dir command on Windows.
# Linuxfind / -name nginx.conf
# Windows dir /s nginx.conf
There is another trick you can use to find out where your nginx.conf is (or isn't)
Alternatively, you can check the error.log file in the Nginx log directory (usually located at /usr/local/nginx/logs on Linux or C:\nginx\logs on Windows) for the location of the nginx.conf file. The error.log file should contain a line similar to the following:
[emerg] 1#1: open() "/usr/local/nginx/conf/nginx.conf" failed (2: No such file or directory)
This line shows the location of the nginx.conf file that Nginx is trying to read.
If you cannot find the nginx.conf file in the default location, it is possible that it was moved or renamed during installation. In this case, you can try searching for it using the methods described above, or you can check the documentation for your specific Nginx installation for more information.
Listing of default nginx.conf file
Have you lost your default nginx.conf file? Here's a full example.
user www www; ## Default: nobodyworker_processes 5; ## Default: 1
error_log logs/error.log; pid logs/nginx.pid; worker_rlimit_nofile 8192; events { worker_connections 4096; ## Default: 1024 } http { include conf/mime.types; include /etc/nginx/proxy.conf; include /etc/nginx/fastcgi.conf; index index.html index.htm index.php; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; tcp_nopush on; server_names_hash_bucket_size 128; # this seems to be required for some vhosts server { # php/fastcgi listen 80; server_name domain1.com www.domain1.com; access_log logs/domain1.access.log main; root html; location