(启动报错处理:
nginx: [alert] could not open error log file: open() "/usr/local/app/nginx-1.16.1/logs/error.log" failed (2: No such file or directory)
2021/04/15 10:26:26 [emerg] 7596#0: open() "/usr/local/app/nginx-1.16.1/logs/access.log" failed (2: No such file or directory))
一:安装基础工具:
yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

二:安装 Nginx  
地址:http://nginx.org/en/download.html
查找需要的版本,这里以1.16.1 为例:
wget https://nginx.org/download/nginx-1.16.1.tar.gz

解压:
tar -zxvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./configure
./configure --prefix=/usr/local/app/nginx   (指定安装目录)

make
make install



启动nginx
 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf  (最安全的启动方式)
 或者
 cd /usr/local/nginx/sbin/
./nginx 
./nginx -s stop  # 此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
./nginx -s quit   # 此方式停止步骤是待nginx进程处理任务完毕进行停止。
./nginx -s reload  #启动

 
 重启Nginx (cd  /usr/local/nginx/sbin)
 ./nginx -s quit  
./nginx 

设置开机自启动:
即在rc.local增加启动代码就可以了。

vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx
设置执行权限:

chmod 755 rc.local