CentOS 6.4 x86_64 部署 nginx 服务器实现点播功能
1、这里我用虚拟机安装的是:CentOS-6.4-x86_64-minimal.iso,安装完之后,个人习惯会先安装vim 和 openssh-server 方便远程和编辑文本2、安装开发环境和一些依赖:yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurse...
1、这里我用虚拟机安装的是:CentOS-6.4-x86_64-minimal.iso,安装完之后,个人习惯会先安装vim 和 openssh-server 方便远程和编辑文本
2、安装开发环境和一些依赖:
yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel gettext-devel pcre-devel
3、安装wget:
yum install wget
4、下载离线安装包
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
5、安装源库:
chmod +x nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -i nginx-release-centos-6-0.el6.ngx.noarch.rpm
6、如果出现错误:
[root@localhost Desktop]# rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
error: nginx-release-centos-6-0.el6.ngx.noarch.rpm: Header V4 RSA/SHA1 signature: BAD, key ID 7bd9bf62
error: nginx-release-centos-6-0.el6.ngx.noarch.rpm cannot be installed
执行一下这个:
rpm --import /etc/pki/rpm-gpg/RPM*
7、安装nginx:
yum install nginx
8、安装完成后:
默认nginx配置文件: /etc/nginx/nginx.conf 【nginx主要的配置文件】
默认nginx的ssl配置文件: /etc/nginx/conf.d/ssl.conf 【配置SSL证书的,也可以并入到nginx.conf文件里】
默认nginx的虚拟主机配置文件: /etc/nginx/conf.d/virtual.conf 【如同Apache的虚拟主机配置,也可以并入到nginx.conf文件里】
默认的web_root文件夹路径: /usr/share/nginx/html 【web目录夹,放置Magento主程序】
9、配置iptables:
iptables -I INPUT 5 -p tcp --dport 80 -j ACCEPT
10、启动、停止、重启:
service nginx start
service nginx stop
service nginx restart
11、可以查看一下 nginx 的配置信息:
[root@localhost flv_file]# /usr/sbin/nginx -V
nginx version: nginx/1.8.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --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.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
可以看到里面是有对 flv 的支持的。
12、配置 nginx.conf 文件,使他支持 flv 点播功能:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html/flv_file/;
index index.html;
charset utf-8;
#charset koi8-r;
#access_log logs/host.access.log main;
limit_rate_after 10m;
limit_rate 512k;
location / {
root html;
index index.html index.htm;
}
location ~ \.flv {
flv;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include /etc/nginx/conf.d/*.conf;
}
这里我们加入的 server 占用的 80 端口,并且设置了 flv 文件的目录,然后我们只要把 flv 文件放在这个目录下,再启动nginx 就可以了。
13、web端获取flv文件流demo在这篇文章里,方法一样,改一下IP就行了:点击打开链接
14、Starting nginx: nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
意思是重复绑定了server name,但这个警告不会影响到服务器运行。而且,这个重复绑定的意思是现在运行的nginx服务和将要加载的新配置中的重复,所以,这个警告其实是不必的。
更多推荐
所有评论(0)