SoFunction
Updated on 2025-03-06

Linux to view nginx installation directory and configuration file path implementation

1. Check nginx installation directory

ps -ef | grep nginx

2. View the configuration file path

nginx -t

This command can also be used to check if the configuration file is correct.

Of course, you can also use the find command to search for files

# Find a file with file name from / root directoryfind / -name 
# Find a file with file name from the /etc directoryfind /etc -name 

3. Specify the configuration file and start the nginx service

nginxInstallation Directory -c Configuration file directory

Where: parameter "-c" specifies the path to the configuration file. If the "-c" parameter is not added, Nginx will load the files in the conf subdirectory of its installation directory by default.

4. Command parameters

/usr/local/nginx/sbin/nginx -parameter

Nginx parameters include:
-c: Use the specified configuration file instead of the conf directory.
-t: Test whether the configuration file is correct. When the configuration needs to be reloaded at runtime, this command is very important to detect whether the modified configuration file has syntax errors.
-v: Show nginx version number.
-V: Displays the version number of nginx, the compilation environment information and the compile time parameters.

Detect new configuration files:

/usr/local/nginx/conf# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/

This is the article about viewing the implementation of nginx installation directory and configuration file paths in Linux. For more information about viewing nginx installation directory and configuration file paths, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!