下载nginx最新包
目前最新稳定版本地址
https://nginx.org/download/nginx-1.16.0.tar.gz
建议创建一个文件夹下载
mkdir download && cd download
wget https://nginx.org/download/nginx-1.16.0.tar.gz
tar -zxvf nginx-1.16.0.tar.gz
cd nginx-1.16.0
安装nginx
源码安装为三部曲
“./configure”命令为编译做好准备;
“make”命令进行软件编译;
“make install”完成安装;
编译准备
安装依赖
yum groupinstall "Development Tools" "Server Platform Deveopment"
yum install openssl-devel pcre-devel
./configure 后面可以加
./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre
路径信息
nginx path prefix: "/usr"
nginx binary file: "/usr/sbin/nginx"
nginx modules path: "/usr/modules"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/tmp/nginx/client/"
nginx http proxy temporary files: "/var/tmp/nginx/proxy/"
nginx http fastcgi temporary files: "/var/tmp/nginx/fcgi/"
nginx http uwsgi temporary files: "/var/tmp/nginx/uwsgi"
nginx http scgi temporary files: "/var/tmp/nginx/scgi"
编译安装
make && make install
编辑nginx.conf
vi /usr/local/nginx/conf/nginx.conf
在后面加上
rtmp {
server {
listen 1935;
application rtmplive {
live on;
record off;
}
}
}
安装x264依赖库
需要安装
nasm-2.13.03
wget https://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.gz
yasm-1.2.0
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
解压并安装
tar -zxvf xxx
./configure
make && sudo make install
然后进入x264目录下配置
./configure --prefix=/usr/local/x264 --enable-shared --enable-static
然后编译安装
安装ffmpeg
配置
./configure --enable-gpl --enable-libx264 --enable-shared --prefix=/monchickey/ffmpeg
查询依赖
ldd $(which /monchickey/ffmpeg/bin/ffmpeg)
编辑conf
sudo vim /etc/ld.so.conf
添加下面一行
/usr/local/lib
更新
sudo ldconfig
推流模板
/monchickey/ffmpeg/bin/ffmpeg -re -i working/test2.mp4 -vcodec libx264 -acodec aac -strict -2 -f flv rtmp://127.0.0.1:1935/rtmplive/room
文件传输
scp Filename name@ip:Fileway
scp working/test1.mp4 root@39.108.14.234:working/
相关参考
nginx编译安装 及 配置WEB服务:https://blog.youkuaiyun.com/tjiyu/article/details/53027881
x264和FFMPEG 编译后遇到的一些问题:https://blog.youkuaiyun.com/bg2bkk/article/details/9048465