Xibo & Nginx-rtmp

20141226 更新
不要用這個~~因為不穩定~Orz


環境: Ubuntu 14.04.01
1. 安裝build deb需要的套件

apt-get install dpkg-dev
  1. 創建source code目錄
mkdir -p /usr/src/nginx 
cd /usr/src/nginx 
  1. 透過apt-get下載nginx的source code
apt-get source nginx
  1. 安裝git
apt-get install git
  1. 透過git下載nginx-rtmp-module的source code
git clone https://github.com/arut/nginx-rtmp-module.git
  1. 將rtmp、xlst模組功能加入設定檔中
cd nginx-1.4.6/
vim debian/rules
<略>
common_configure_flags := 
                        --with-cc-opt="$(debian_cflags)" 
                        --with-ld-opt="$(debian_ldflags)" 
                        --prefix=/usr/share/nginx 
                        --conf-path=/etc/nginx/nginx.conf 
                        --http-log-path=/var/log/nginx/access.log 
                        --error-log-path=/var/log/nginx/error.log 
                        --lock-path=/var/lock/nginx.lock 
                        --pid-path=/run/nginx.pid 
                        --http-client-body-temp-path=/var/lib/nginx/body 
                        --http-fastcgi-temp-path=/var/lib/nginx/fastcgi 
                        --http-proxy-temp-path=/var/lib/nginx/proxy 
                        --http-scgi-temp-path=/var/lib/nginx/scgi 
                        --http-uwsgi-temp-path=/var/lib/nginx/uwsgi 
                        --with-debug 
                        --with-pcre-jit 
                        --with-ipv6 
                        --with-http_ssl_module 
                        --with-http_stub_status_module 
                        --with-http_realip_module 
                        --with-http_xslt_module 
                        --add-module=/usr/src/nginx/nginx-rtmp-module 
<略>
  1. 安裝nginx的相依性套件
apt-get build-dep nginx
  1. 建置nginx deb
dpkg-buildpackage -b
  1. 安裝編譯後的檔案
dpkg --install nginx-common_1.4.6-1ubuntu3.1_all.deb nginx-full_1.4.6-1ubuntu3.1_amd64.deb
  1. 安裝php5-fpm、mysql-server、php5-mysql
apt-get install php5-fpm php5-mysql mysql-server
  1. 修改nginx default site設定,加入php功能及相關host
vim /etc/nginx/sites-available/default
server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /usr/share/nginx/html;
        index index.html index.htm index.php;

        # Make site accessible from http://localhost/
        server_name xibo;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #       proxy_pass http://127.0.0.1:8080;
        #}

        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 /usr/share/nginx/html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ .php$ {
                fastcgi_split_path_info ^(.+.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #       # With php5-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }


        location /obs-remote {
            root  html;
            index index.html index.htm;
            #allow
            #deny all;
            #auth_basic "Restricted Area";
            #auth_basic_user_file    /usr/local/nginx/conf/.htpasswd;
        }

        location /stat {
            rtmp_stat all;

            # Use this stylesheet to view XML as web page
            # in browser
            rtmp_stat_stylesheet stat.xsl;
            #auth_basic "Restricted Area stat";
            #auth_basic_user_file    /usr/local/nginx/conf/.htpasswd;
        }

        location /stat.xsl {
            # XML stylesheet to view RTMP stats.
            # Copy stat.xsl wherever you want
            # and put the full directory path here
            root html;
            # auth_basic "Restricted Area stat.xsl";
            # auth_basic_user_file    /usr/local/nginx/conf/.htpasswd;
        }


        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /.ht {
        #       deny all;
        #}
}
  1. 修改nginx設定,加入rtmp模組
vim /etc/nginx/nginx.conf
rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                        #allow publish 10.0.0.0/8;
                        #deny publish all;
                        #allow play 10.201.80.107;
                        #deny play all;
                }
        }
}
  1. 重新啟動
service nginx restart
  1. 下載xibo cms
cd /usr/share/nginx/html
wget https://launchpad.net/xibo/1.6/1.6.4/+download/xibo-server-164.tar.gz
tar zxvf xibo-server-164.tar.gz
mv xibo-server-164 xibo
  1. 設定存取權限
chown -R www-data:www-data .
  1. 安裝php gd模組
apt-get install php5-gd
  1. 安裝php mcrypt模組並啟動
apt-get install php5-mcrypt
php5enmod mcrypt
  1. 根據網頁顯示的建議,調整php.ini
    You probably want to allow larger files to be uploaded than is currently available with your PHP configuration.
    We suggest setting your PHP post_max_size and upload_max_size to at least 128M, and also increasing your max_execution_time to at least 120 seconds.
vim /etc/php5/fpm/php.ini
<略>
max_execution_time = 120
<略>
post_max_size = 1024M
<略>
upload_max_filesize = 1024M
<略>
  1. 重新啟動nginx、php
service php5-fpm restart
service nginx restart

20. 開啟網頁設定xibo
連結:http://{伺服器IP}/xibo
  1. 設定時會詢問一個存放檔案的目錄,修改權限供nginx存取
mkdir /home/xibo
chown -R www-data:www-data /home/xibo/
  1. 安裝完後登入測試
    預設帳號 xibo_admin
This entry was posted in Nginx, Ubuntu, Xibo. Bookmark the permalink.