linux安装nginx过程

252 阅读1分钟

1、下载官网 nginx-1.10.3

  • 切换到要下载的目录
  • 下载:wget http://220.112.193.197/files/9182000003CA673D/nginx.org/download/nginx-1.10.3.tar.gz
  • 解压:tar -zxvf nginx-1.10.3.tar.gz
2、安装
  • 进入目录nginx-1.10.3
  • 执行配置命令:./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
  • 报错的话执行:yum -y install openssl openssl-devel 再执行一下上一步
  • 报错./configure: error: C compiler cc is not found就执行yum -y install gcc gcc-c++ autoconf automake make
  • 编译:make
  • 安装:make install
  • 检查是否安装成功:cd /usr/local/nginx/sbin;
    ./nginx -t
    结果显示:安装成功
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
3、启动nginx
  • 执行命令:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
4、停止nginx
  • 获取进程号:ps -ef | grep nginx
  • 从容停止Nginx:kill -QUIT master进程号
  • 快速停止Nginx:kill -TERM master进程号
  • 强制停止Nginx:kill -9 master进程号
5、nginx的重加载
  • 获取进程号:ps -ef | grep nginx
  • 执行命令:kill -HUP master进程号

参考:
阿里云服务器安装 nginx
centos下nginx启动、重启、关闭操作
./configure 常用参数说明