title: How can I check if current web server is NGINX or Apache using bash script?
body: <p>I have a Laravel project deployed on Ubuntu VM. I have a script that I am working on right now that to know if the current VM deployed using nginx or Apache programmatically.</p>
  
  <p>I know I can just check using these <code>ps</code> and <code>grep</code> command I will find that out</p>
  
  <pre><code>root@theawsbiz:~# ps -aux | grep apache                                                                                                                 
  root      3446  0.0  1.8 544540 37144 ?        Ss   17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3449  0.1  1.9 550388 39796 ?        S    17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3454  0.0  1.0 547336 21532 ?        S    17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3457  0.0  1.8 548196 37864 ?        S    17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3458  0.0  1.0 547320 21428 ?        S    17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3462  0.0  1.7 550008 36264 ?        S    17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3465  0.0  1.8 550408 38160 ?        S    17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3466  0.0  1.9 550400 40512 ?        S    17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3467  0.0  1.0 547320 21416 ?        S    17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3468  0.0  1.7 548228 36236 ?        S    17:02   0:00 /usr/sbin/apache2 -k start                                                             
  www-data  3520  0.0  0.9 546872 19964 ?        S    17:06   0:00 /usr/sbin/apache2 -k start                                                             
  root      3526  0.0  0.0  14856  1036 pts/1    S+   17:06   0:00 grep --color=auto apache                                                               
  root@theawsbiz:~# ps -aux | grep nginx                                                                                                                  
  root      3529  0.0  0.0  14856  1092 pts/1    S+   17:06   0:00 grep --color=auto nginx                                                                
  root@theawsbiz:~# 
  </code></pre>
  
  <p>With those result about, I know that this VM is using Apache.</p>
  
  <p>But, I have no idea how to check it via a Bash script. How would one go about and do that? I'm open to any suggestions at this moment. </p>
  
  <p><a href="https://i.stack.imgur.com/tZdO8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tZdO8.png" alt="enter image description here"></a></p>