directory

  • Install nginx
  • Start the nginx

[Introduction] Today we built a very simple streaming media server, using FFMPEG to push the stream to nGINx server, and using VLC player subscription media streaming out.

1. Install nginx

1.1 Pull nginx to the local PC and run the following command:

brew tap homebrew/nginx

If brew is not recognized, execute the following command:

Ruby – e “$(curl – fsSL raw.githubusercontent.com/Homebrew/in…). “

If there is an error:

Error: homebrew/nginx was deprecated. This tap is now empty as all its formulae were migrated.

Run the following command:

brew tap denji/nginx

1.2 Installing Nginx and related modules

To install nginx and RTMP protocol modules, run the following command:

brew install nginx-full –with-rtmp-module

If the following error message is displayed:

==> Installing nginx-full from denji/nginx

Error: Xcode alone is not sufficient on High Sierra.

Install the Command Line Tools:

  xcode-select –install

Then run the following command:

xcode-select –install

When the “Ask” popup appears, click “Agree” and the popup as shown in the picture will indicate that the installation is successful.

Note: The above screenshots are from the MAC system.

Then continue with the previous command and the result is as follows:

==> Installing nginx-full from denji/nginx ==> Installing dependencies for denji/nginx/nginx-full: pcre, openssl and rtmp-nginx-module ==> Installing denji/nginx/nginx-full dependency: Pcre = = > Downloading homebrew.bintray.com/bottles/pcr… # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # = = > 100.0% Pouring Pcre 8.42. High_sierra. Bottle. Tar. Gz? / usr/local/Cellar/pcre / 8.42:204 files, 5.3 MB = = > Installing denji/nginx/nginx – full dependency: Openssl = = > Downloading homebrew.bintray.com/bottles/ope… . # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # = = > 100.0% Pouring Openssl-1.0.2p.high_serra.bottle.tar. gz ==> Caveats A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs

and run /usr/local/opt/openssl/bin/c_rehash

openssl is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have openssl first in your PATH run: echo ‘export PATH=”/usr/local/opt/openssl/bin:$PATH”‘ >> ~/.bash_profile

For compilers to find openssl you may need to set: export LDFLAGS=”-L/usr/local/opt/openssl/lib” export CPPFLAGS=”-I/usr/local/opt/openssl/include”

For pkg-config to find openssl you may need to set: export PKG_CONFIG_PATH=”/usr/local/opt/openssl/lib/pkgconfig”

==> Summary ? / usr/local/Cellar/openssl / 1.0.2 p: 1793 files, 12.3 MB = = > Installing denji/nginx/nginx – full dependency: RTMP nginx – module = = > Downloading github.com/sergey-drya… = = > Downloading from codeload.github.com/sergey-drya… # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # = = > 100.0% Downloading github.com/sergey-drya… # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # = = > 100.0% Patching = = > Applying v1.1.7.10… 504b9ee.diff patching file .gitignore patching file README.md patching file config patching file dash/ngx_rtmp_dash_module.c patching file doc/README.md patching file doc/directives.md patching file hls/ngx_rtmp_hls_module.c patching file hls/ngx_rtmp_mpegts.c patching file hls/ngx_rtmp_mpegts.h patching file hls/ngx_rtmp_mpegts_crc.c patching file hls/ngx_rtmp_mpegts_crc.h patching file ngx_rtmp.c patching file ngx_rtmp_access_module.c patching file ngx_rtmp_amf.c patching file ngx_rtmp_auto_push_module.c patching file ngx_rtmp_cmd_module.h patching file ngx_rtmp_codec_module.c patching file ngx_rtmp_core_module.c patching file ngx_rtmp_eval.c patching file ngx_rtmp_exec_module.c patching file ngx_rtmp_handshake.c patching file ngx_rtmp_init.c patching file ngx_rtmp_live_module.c patching file ngx_rtmp_live_module.h patching file ngx_rtmp_netcall_module.c patching file ngx_rtmp_notify_module.c patching file ngx_rtmp_record_module.c patching file ngx_rtmp_record_module.h patching file ngx_rtmp_shared.c patching file ngx_rtmp_version.h ? / usr/local/Cellar/RTMP – nginx – the module / 1.1.7.11 – dev_3: 94 files, 1.4 MB, Built in 21 seconds ==> Installing denji/nginx/nginx-full –with-rtmp-module ==> Downloading nginx.org/download/ng… # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # = = > 100.0%. / configure /usr/local/Cellar/nginx-full/1.15.6 –with-http_ssl_mod ==> make install ==> /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

Tips Run port 80: Sudochownroot: wheel/usr/local/opt/nginx – full/bin/nginxsudo chown root: wheel / usr/local/opt/nginx – full/bin/nginxsudochownroot: wheel/usr/local/opt/nginx – full/bin/nginx sudo chmod u + s /usr/local/opt/nginx-full/bin/nginx Reload config: Nginx – sreloadReopenLogfile: nginx -s reload Reopen Logfile: nginx – sreloadReopenLogfile: nginx -s Reopen Stop process: Nginx – sstopWaitingonexitprocessnginx -s stop Waiting on the exit processnginx – sstopWaitingonexitprocess nginx -s quit

To have launchd start denji/nginx/nginx-full now and restart at login: brew services start denji/nginx/nginx-full Or, if you don’t want/need a background service you can just run: nginx ==> Summary ? / usr/local/Cellar/nginx – full / 1.15.6: 8 files, 1.2 MB, built in 1 minute ==> Caveats ==> openssl A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash openssl is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. If you need to have openssl first in your PATH run: echo ‘export PATH=”/usr/local/opt/openssl/bin: The PATH “‘ > > /. BashprofileForcompilerstofindopensslyoumayneedtoset: exportLDFLAGS = “- L/usr/local/opt/openssl/lib” exportCPPFLAGS = “- I/usr / local/opt/openssl/include “Forpkg – configtofindopensslyoumayneedtoset: exportPKGCONFIGPATH =”/usr/local/opt/openssl/lib/PKG Config “= = > nginx – fullDocrootis: / usr/local/var/wwwThedefaultporthasbeensetin/usr/local/etc/nginx/nginx confto8080sothatngi nxcanrunwithoutsudo.nginxwillloadallfilesin/usr/local/etc/nginx/servers/.TipsRunport80:PATH”‘ >> ~/.bash_profile For compilers to find openssl you may need to set: export LDFLAGS=”-L/usr/local/opt/openssl/lib” export CPPFLAGS=”-I/usr/local/opt/openssl/include” For pkg-config to find openssl you may need to set: export PKG_CONFIG_PATH=”/usr/local/opt/openssl/lib/pkgconfig” ==> nginx-full Docroot is: /usr/local/var/www The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo. nginx will load all files in /usr/local/etc/nginx/servers/. Tips Run port 80: The PATH “‘ > > /. BashprofileForcompilerstofindopensslyoumayneedtoset: exportLDFLAGS = “- L/usr/local/opt/openssl/lib” exportCPPFLAGS = “- I/usr / local/opt/openssl/include “Forpkg – configtofindopensslyoumayneedtoset: exportPKGCONFIGPATH =”/usr/local/opt/openssl/lib/PKG Config “= = > nginx – fullDocrootis: / usr/local/var/wwwThedefaultporthasbeensetin/usr/local/etc/nginx/nginx confto8080sothatngi nxcanrunwithoutsudo.nginxwillloadallfilesin/usr/local/etc/nginx/servers/.TipsRunport80: sudo chown root:wheel /usr/local/opt/nginx-full/bin/nginx Sudochmodu + s/usr/local/opt/nginx – full/bin/nginxReloadconfig: sudo chmod u + s/usr/local/opt/nginx – full/bin/nginx Reload Config: sudochmodu + s/usr/local/opt/nginx – full/bin/nginxReloadconfig: nginx -s reload Reopen Logfile: Nginx −sreopenStopprocess:nginx -s reopenStop Process: Nginx −sreopenStopprocess: nginx -s stop Waiting on exit process $ nginx -s quit To have launchd start denji/nginx/nginx-full now and restart at login: brew services start denji/nginx/nginx-full Or, if you don’t want/need a background service you can just run: nginx

2. Start the nginx

At this point, the Nginx streaming server is installed successfully. Next run nginx and run the following command:

nginx

To test whether the nginx server is available, open a browser, type http://localhost:8080 and press Enter.

If the following information appears, the Nginx server is available.

You can then push the RTMP video stream to the default port 1935.