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.
I know I can just check using these ps
and grep
command I will find that out
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:~#
With those result about, I know that this VM is using Apache.
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.