1、在官网下载安装包
http://nginx.org/en/download.html
2、服务器上下载
wget -c https://nginx.org/download/nginx-1.18.0.tar.gz
3、解压
tar -xvzf nginx-1.18.0.tar.gz
4、进入目录并默认配置、编译安装
cd nginx-1.18.0/
./configure
make
5、nginx的启动、关闭等
#启动、停止nginx
cd /usr/local/nginx/sbin/
./nginx #启动
./nginx -s stop #停止,直接查找nginx进程id再使用kill命令强制杀掉进程
./nginx -s quit #退出停止,等待nginx进程处理完任务再进行停止
./nginx -s reload #重新加载配置文件,修改nginx.conf后使用该命令,新配置即可生效
#重启nginx,建议先停止,再启动
./nginx -s stop
./nginx
#查看nginx进程,如下返回,即为成功
ps aux|grep nginx
6、开机自启
#在rc.local增加启动代码即可
vi /etc/rc.local
#增加一行 /usr/local/nginx/sbin/nginx,增加后保存
#设置执行权限
cd /etc
chmod 755 rc.local
7、配置域名
#进入nginx配置文件目录,找到nginx的配置文件nginx.conf
cd /usr/local/nginx/conf/
#直接修改
vi nginx.conf
#修改完成后,重新加载配置文件
cd /usr/local/nginx/sbin/
./nginx -s reload
二、nodejs安装
1、下载
网络下载
wget https://npm.taobao.org/mirrors/node/v14.15.3/node-v14.15.3.tar.gz
2、解压
tar xvf node-v14.15.3.tar.gz
3、进入包内进行编译
cd node-v14.15.3/
./configure
make
4、安装
make install
5、检验
node -v
出现问题参考