Created
December 7, 2016 00:03
-
-
Save ralphievolt/77737cc87377c6b52d12da949efe73ca to your computer and use it in GitHub Desktop.
NGINX Installatation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## REFERENCE : https://medium.com/@tomgoldenberg/deploying-a-meteor-app-with-nginx-from-scratch-1332b32e99a5#.tme24q15r | |
| ## Install Forevever | |
| > npm install -g forever | |
| > forever list | |
| # terminal will show below | |
| # info: No forever process running | |
| # cd to you app directory and run | |
| # check package.json and ensure no space in between in { "name": "APP_NAME" ..... } to prevent error | |
| > npm install && meteor run | |
| # Install Nginx | |
| # download key here | |
| http://nginx.org/en/linux_packages.html#stable | |
| > sudo apt-key add nginx_signing.key | |
| # we open up the file /etc/apt/sources.list and append these 2 lines to the bottom with the proper codename | |
| deb http://nginx.org/packages/ubuntu/ codename nginx # codename trusty for Ubuntu 14.04 | |
| deb-src http://nginx.org/packages/ubuntu/ codename nginx # codename trusty for Ubuntu 14.04 xenial for Ubuntu 16.04 | |
| # install nginx | |
| > sudo apt-get update | |
| > sudo apt-get install nginx | |
| # terminal will show : Thanks for using nginx! | |
| # create two folders inside /etc/nginx | |
| sites-available | |
| sites-enabled | |
| #create a file inside site-available | |
| sites-available/app | |
| # paste this code inside app file | |
| # this section is needed to proxy web-socket connections | |
| map $http_upgrade $connection_upgrade { | |
| default upgrade; | |
| '' close; | |
| } | |
| # HTTP | |
| server { | |
| listen 80 default_server; | |
| listen [::]:80 default_server ipv6only=on; | |
| location = /favicon.ico { | |
| root /home/funai/portal/programs/web.browser/app; | |
| access_log off; | |
| } | |
| location ~* "^/[a-z0-9]{40}\.(css|js)$" { | |
| gzip_static on; | |
| root /home/funai/portal/programs/web.browser; | |
| access_log off; | |
| } | |
| location ~ "^/packages" { | |
| root /home/funai/portal/programs/web.browser; | |
| access_log off; | |
| } | |
| # pass requests to Meteor | |
| location / { | |
| proxy_pass http://127.0.0.1:8080; | |
| proxy_http_version 1.1; | |
| proxy_set_header Upgrade $http_upgrade; #for websockets | |
| proxy_set_header Connection $connection_upgrade; | |
| proxy_set_header X-Forwarded-For $remote_addr; | |
| proxy_set_header Host $host; | |
| } | |
| } | |
| # create a symbolic link to a file with the same name in “sites-enabled” | |
| # make sure you are in use root directory | |
| > sudo ln -s /etc/nginx/sites-available/app /etc/nginx/sites-enabled/app | |
| # Check that the symbolic link worked — | |
| > cat /etc/nginx/sites-enabled/app | |
| # You should see the same code from above. | |
| # Add this to the bottom of the /etc/nginx/nginx.conf file to include your changes | |
| > include /etc/nginx/sites-enabled/*; | |
| ## Run the Meteor app on port 8080 through Forever | |
| > sudo nginx -t | |
| # this should show that the nginx.conf syntax is okay and test is successful | |
| > sudo service nginx restart or stop or start | |
| # go to your server IP address in your browser and see default nginx site [ Welcome to nginx ] | |
| ** after restart this will show 502 Bad Gateway but don't worry we will have our meteor app running later | |
| # TO REMOVE NGINX COMPLETELY | |
| > sudo apt-get purge nginx nginx-common | |
| > sudo apt-get autoremove | |
| ** include /etc/nginx/conf.d/*.conf; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment