nginx 部署教程

106 阅读1分钟

先用 root 安装需要的开发包:

yum install -y openssl-devel pcre-devel zlib-devel

编译安装

tar -xf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./configure --prefix=$HOME/apps/nginx
make
make install

赋权

为了能用 totpea 用户启动 nginx,且监听在 80 端口,需要给 nginx 赋权限。

cd /bomc/toptea/app/nginx/sbin
chown root:root nginx
chmod 755 nginx
chmod u+s nginx

同时修改 conf/nginx.conf,增加配置项:

user toptea toptea;

两个 toptea 分别表示用户名用户所在的组

2.4.3 启动和停止

/bomc/toptea/app/nginx/sbin 目录下,

  • 启动

    ./nginx
    
  • 停止

    ./nginx -s stop