-
Notifications
You must be signed in to change notification settings - Fork 979
Set up my own Stream Server
There is a video to help you to configure it: https://tutorials.youphptube.com/video/10-min-youphptube-stream-server-installation This video does not include HLS support what is included on this tutorial
For new installations
git clone https://github.com/DanielnetoDotCom/YouPHPTube.git
Tutorial video: https://tutorials.youphptube.com/video/how-to-install-youphptube-in-a-fresh-ubuntu-server
Or if you already have YouPHPTube installed, you just need to update:
git pull
Tutorial Video: https://tutorials.youphptube.com/video/how-to-update-your-youphptube-version
I have follow this tutorial: https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp and this one https://www.vultr.com/docs/setup-nginx-on-ubuntu-to-stream-live-hls-video But if you do not want to read all of it, here is a nginx rtmp tutorial command compilation also I have added the needed php extension php7.0-xml:
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev php7.0-xml && sudo mkdir ~/build && cd ~/build && sudo git clone git://github.com/arut/nginx-rtmp-module.git && sudo wget http://nginx.org/download/nginx-1.12.0.tar.gz && sudo tar xzf nginx-1.12.0.tar.gz && cd nginx-1.12.0 && sudo ./configure --with-http_ssl_module --with-http_stub_status_module --add-module=../nginx-rtmp-module && sudo make && sudo make install && sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /usr/local/nginx/ssl/nginx.key -out /usr/local/nginx/ssl/nginx.crt && sudo /etc/init.d/apache2 restart
Just use the command below and go to step 4
sudo cp ~/build/nginx-rtmp-module/stat.xsl /usr/local/nginx/html && sudo mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.old && cd /usr/local/nginx/conf/ && sudo wget https://raw.githubusercontent.com/DanielnetoDotCom/YouPHPTube/master/plugin/Live/install/nginx.conf
Open the config file
sudo nano /usr/local/nginx/conf/nginx.conf
and edit the lines:
on_publish http://[YouPHPTubeURL]/plugin/Live/on_publish.php;
on_play http://[YouPHPTubeURL]/plugin/Live/on_play.php;
on_record_done http://[YouPHPTubeURL]/plugin/Live/on_record_done.php;
replacing the [YouPHPTubeURL] with your YouPHPTube address
If you finish the above commands just go to step 4 now. Or, if you not, just follow this tutorial: https://helping-squad.com/nginx-rtmp-setup-rtmp-statistics/.
First of all we have to copy the stat.xsl file, that comes with the nginx-rtmp-module sources, to nginx\html.
sudo cp ~/build/nginx-rtmp-module/stat.xsl /usr/local/nginx/html
Then edit again the config file: sudo nano /usr/local/nginx/conf/nginx.conf
add te sections rtmp stat and rtmp control on your file, after this your server section should looks like this.
server {
listen 81;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
# rtmp stat
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root html;
}
# rtmp control
location /control {
rtmp_control all;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
To set up RTMP support you need to add rtmp{}
section to nginx.conf
(can be found in PREFIX/conf/nginx.conf). Stock nginx.conf
contains only http{}
section.
sudo nano /usr/local/nginx/conf/nginx.conf
append the following code at the end of the file
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
on_publish http://[Your.YouPHPTube.url]/plugin/Live/on_publish.php;
}
}
}
I also change the default listen HTTP port, 80 to 81 because, in my case, Nginx is on the same server as Apache.
Go to menu->plugins and turn on the switch for Live and Live Chat
On the same screen as you turn on the switch click on the edit button of the Live Plugin. On the demo site we use this code:
{"button_title":"LIVE","server":"rtmp://[nigix-server]/live","playerServer":"https://[nigix-server]:444/live","stats":"http://[nigix-server]:81/stats"}
Click on the install database button
What those variables means:
server = Where your stream will be submited, usually it is used in the publisher software
playerServer = can be different or the same as server variable. It is in case you need to encode the incoming stream and send a different stream to the players
stats = it is the stats of Nginx-RTMP, this tutorial helps: https://helping-squad.com/nginx-rtmp-setup-rtmp-statistics/
Open an terminal from your webserver and type this command:
nohup php /[path-to-YouPHPTube]/plugin/LiveChat/chat-server.php &
and press Ctrl+C
sudo /usr/local/nginx/sbin/nginx
port is optional, in my case Nginx is on the same server as apache.
sudo nano /etc/apache2/mods-available/proxy.conf
Make the file looks like this
<IfModule mod_proxy.c>
ProxyPass /wss/ ws://127.0.0.1:8888/
</IfModule>
restart Apache
/etc/init.d/apache2 restart