第一步:依赖环境安装:
yum install pcre pcre-devel openssl openssl-devel zlib zlib-devel -y
yum install gcc gcc-c++ make libtool -y
第二步:下载nginx 版本,官网下载地址:http://nginx.org/download/
解压下载nginx版本:
tar -xvf nginx-1.13.10.tar.gz
下载rtmp,并解压:
wget https://github.com/arut/nginx-rtmp-module/archive/v1.1.11.tar.gz
tar -xvf v1.1.11.tar.gz
第三步:编译NGINX,添加rtmp模块(视频直播,可以不添加--add-module=/ftp/pub/nginx-rtmp-module-1.1.11/)
[root@localhost pub]# cd nginx-1.13.10
[root@localhost nginx-1.13.10]# ./configure --add-module=/ftp/pub/nginx-rtmp-module-1.1.11/
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@localhost nginx-1.13.10]# make && make install
第四步:开放指定端口和防火墙重启
[root@localhost nginx]# firewall-cmd --add-port=80/tcp --permanent
success
[root@localhost nginx]# firewall-cmd --add-port=8000/tcp --permanent
success
[root@localhost nginx]# firewall-cmd --add-port=8080/tcp --permanent
success
[root@localhost nginx]# firewall-cmd --reload
第五步:nginx 启动、设置开机自启动及其相关指令:
进入NGINX安装目录,执行./nginx 启动nginx
[root@localhost html]# cd /usr/local/nginx/sbin
[root@localhost html]# ./nginx
设置nginx 开机自启动(编辑/etc/rc.d/rc.local文件,添加如下代码):
[root@localhost sbin]# vi /etc/rc.d/rc.local
# nginx start
/usr/local/nginx/sbin/nginx
[root@localhost sbin]# chmod +x /etc/rc.d/rc.local #添加相关权限
停止nginx:
[root@localhost html]# cd /usr/local/nginx/sbin
[root@localhost html]# ./nginx -s stop
重新启动nginx
[root@localhost html]# cd /usr/local/nginx/sbin
[root@localhost html]# ./nginx -s reload