# Locate the Nginx.conf File My Nginx Is Actually Using

To locate the `nginx.conf` file that your Nginx server is actually using, you can follow these steps:

### **1. Check the Nginx Process**

The Nginx process usually has a command line that shows the path to the configuration file it's using. You can check this by using the `ps` command.

**Command:**

```bash
ps aux | grep nginx
```

**Explanation:**

- This command lists all processes related to Nginx.
- Look for the master process, which often includes the path to the `nginx.conf` file in its command line arguments.

### **2. Use the `nginx` Command**

You can also use the Nginx command-line tool to find the path of the configuration file.

**Command:**

```bash
nginx -t
```

**Explanation:**

- The `t` flag tests the configuration for syntax errors and prints the configuration file path.
- Look for a line in the output like:
    
    ```
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    ```
    

**Alternate Command:**

```bash
nginx -V
```

**Explanation:**

- The `V` flag shows the version of Nginx and configuration options.
- Look for a line that includes `-conf-path=` which indicates the path to the `nginx.conf` file.

### **3. Check Common Locations**

If the above methods do not work, check these common locations where Nginx typically stores its configuration file:

- **Default location on Debian/Ubuntu:**
    
    ```bash
    /etc/nginx/nginx.conf
    ```
    
- **Default location on CentOS/RHEL/Fedora:**
    
    ```bash
    /etc/nginx/nginx.conf
    ```
    
- **Alternative locations:**
    
    ```bash
    /usr/local/nginx/conf/nginx.conf
    /usr/local/etc/nginx/nginx.conf
    ```
    

### **4. Check the Nginx Service File**

If Nginx is running as a service, the service configuration file might specify the path to the `nginx.conf` file.

**Command to find the service file location:**

```bash
systemctl show -p ExecStart nginx
```

**Explanation:**

- This command shows the `ExecStart` parameter, which typically includes the path to the Nginx binary and may include configuration file options.

### **5. Look for Symbolic Links**

Sometimes the `nginx.conf` file might be a symbolic link. You can use the `ls -l` command to check for symbolic links in common configuration directories.

**Command:**

```bash
ls -l /etc/nginx/
```

**Explanation:**

- This command lists files and directories in `/etc/nginx/`, showing if `nginx.conf` is a symbolic link to another location.

### **Summary**

To locate the `nginx.conf` file that your Nginx server is using:

1. **Check Nginx Process:** Use `ps aux | grep nginx` to find the configuration file path.
2. **Use Nginx Command:** Run `nginx -t` or `nginx -V` to display the configuration file path.
3. **Check Common Locations:** Look in `/etc/nginx/nginx.conf` or alternative locations.
4. **Check Service File:** Use `systemctl show -p ExecStart nginx` to find configuration options.
5. **Look for Symbolic Links:** Use `ls -l /etc/nginx/` to check for symbolic links.

By following these steps, you should be able to identify the exact `nginx.conf` file that your Nginx instance is using.