How to view the installation path of nginx?
To view the installation path of nginx, you can use one of the following methods:
- Use the command ‘which nginx’ to get the full path of the executable file for nginx, such as ‘/usr/sbin/nginx’.
- The “whereis nginx” command will display the executable file path and related file paths for nginx. For example, it may show something like: nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx /usr/share/man/man1/nginx.1.gz.
- Running the command ps -ef | grep nginx will display all running nginx processes, along with the executable file path for each process. For example:
root 1234 1 0 12:00 ? 00:00:00 /usr/sbin/nginx
nginx 5678 1234 0 12:00 ? 00:00:00 nginx: worker process
The installation path of nginx is /usr/sbin/nginx.
- The nginx configuration file in the /etc directory
- configuration file for nginx
cat /etc/nginx/nginx.conf
In the configuration file, you can find the “server” directive within the “http” directive, where the “root” directive typically specifies the root directory of nginx, which is the installation path of nginx. For example:
http {
server {
root /usr/share/nginx/html;
}
}
In the example given, /usr/share/nginx/html is the installation path for nginx.
Note: the above method is suitable for most Linux systems. There may be some differences for other operating systems or special configurations.