1.下载nginx源码包https://nginx.org/
2.将源码上传到linux服务器
3.解压包,并进入解压后的文件目录下
4.编译环境准备
一键安装四个依赖

yum -y install gcc gcc-devel pcre pcre-devel openssl openssl-devel

执行命令

./configure --prefix=/usr/local/nginx

编译

make

看到下面的结果表示编译成功

sed -e “s|%%PREFIX%%|/usr/local/nginx|”
-e “s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|”
-e “s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|”
-e “s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|< man/nginx.8 > objs/nginx.8

安装

  make install

将 /usr/local/nginx/sbin目录 添加到path环境变量中

vi ~/.bash_profile

在这里插入图片描述

生效

source ~/.bash_profile

nginx命令

   nginx -m 显示所有加载的模块
   nginx -l 显示所有可以使用的指令
   nginx -t 检查nginx的配置文件是否正确
   nginx -s start 启动nginx
   nginx -s reload 重启nginx
   nginx -s stop 停止nginx
   ps -ef | grep nginx  //查看进程命令

Logo

更多推荐