yum -y install gcc gcc-c++ pcre pcre-devel openssl openssl-devel zlib zlib-devel unzip
mkdir downloads/
cd downloads/
wget http://nginx.org/download/nginx-1.9.9.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip -O rtmp.zip
unzip rtmp.zip
tar -zxvf nginx-1.9.9.tar.gz
cd nginx-1.9.9/
./configure --add-module=../nginx-rtmp-module-master/ --with-http_realip_module
make && make install
确认安装成功:
/usr/local/nginx/sbin/nginx -v
/usr/local/nginx/sbin/nginx
如果需要用systemctl来启动nginx, 请修改nginx的服务配置文件:
cp /usr/lib/systemd/system/nginx.service /usr/lib/systemd/system/nginx_backup.service
vim /usr/lib/systemd/system/nginx.service
保存后reload配置:
systemctl daemon-reload
再尝试用systemctl启动nginx服务:
systemctl stop nginx
systemctl start nginx
参考: