‘pid’
directive is used to store the process ID of the main process.
$ps -eaf | grep nginx
0 64258 1 0 11:22AM ?? 0:00.04 nginx: master process nginx
-2 68050 64258 0 12:38PM ?? 0:00.00 nginx: worker process
188003303 68155 26600 0 12:39PM ttys000 0:00.00 grep nginx
As you see
the output, 64258 is the process id of nginx master process.
You can
get the same by looking at the contents of pid file.
How to
get the pid file location?
Execute the command ‘nginx -V’. $nginx -V
nginx version: nginx/1.17.3
built by clang 10.0.1 (clang-1001.0.46.4)
built with OpenSSL 1.1.1c 28 May 2019 (running with OpenSSL 1.1.1d 10 Sep 2019)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx/1.17.3_1 --sbin-path=/usr/local/Cellar/nginx/1.17.3_1/bin/nginx --with-cc-opt='-I/usr/local/opt/pcre/include -I/usr/local/opt/openssl@1.1/include' --with-ld-opt='-L/usr/local/opt/pcre/lib -L/usr/local/opt/openssl@1.1/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-compat --with-debug --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-ipv6 --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module
Search for
the property ‘--pid-path’.
--pid-path=/usr/local/var/run/nginx.pid
$cat /usr/local/var/run/nginx.pid
64258
How to
change the pid file?
Using
‘pid’ directive, you can change the pid file location.
pid /nginx_conf_details/my_nginx.pid;
Step 1:
Stop nginx server.
Step 2:
Update nginx.conf
file.
nginx.conf
pid /nginx_conf_details/my_nginx.pid; events { } http { include mime.types; server { listen 9090; server_name localhost; location = /about{ return 200 "Hello Welcome to NGINX"; } location = /not_found{ return 404 "File can't be found"; } } }
Step 3:
Start nginx server (sudo
nginx).
Step 4:
Confirm the process
id.
$cat /nginx_conf_details/my_nginx.pid
71481
$
$ps -eaf | grep nginx
0 71481 1 0 1:50PM ?? 0:00.00 nginx: master process nginx
-2 71482 71481 0 1:50PM ?? 0:00.00 nginx: worker process
188003303 71488 26600 0 1:50PM ttys000 0:00.00 grep nginx
$
No comments:
Post a Comment