Before installing Nginx, please check your system type and whether the Nginx service is already installed or running on the system.
Execute the following command to check if there is already an Nginx process running.
ps -aux|grep nginx
If the terminal displays a result similar to the following, it indicates that an nginx process is already running. You don't need to install nginx again.
root 179252 0.0 0.3 56732 11760 ? S Sep27 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
If the terminal does not produce the expected results, please check whether the system has installed nginx but not running the service by searching for nginx executable programs. Execute the following command to search for nginx executable programs.
cd /
find -name nginx
If the system has already installed nginx, it will display a result similar to the following.
./usr/share/doc/nginx
./usr/sbin/nginx
./var/log/nginx
Query system type
uname -a
The installation of nginx varies among different Linux systems.
For Ubuntu/Debian
sudo apt update
sudo apt install nginx
For Centos
sudo yum install epel-release
sudo yum install nginx
For Fedora
sudo dnf install nginx
Start nginx service
sudo systemctl start nginx
sudo systemctl enable nginx
Find nginx configuration file path
root@iZt4n2mwfzq1jm449llyl2Z:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Based on the above result, start editing the nginx configuration file.