The Nginx configuration file associated with this application is placed under the current deployment folder

Source: Internet
Author: User

(1) First create a new service-related nginx configuration file under the current folder nginx.conf

upstream News_server {server Unix:/tmp/unicorn.news.sock fail_timeout=0;} server {Listen8888; Access_log/opt/app/ruby/news/current/log/Nginx.access.log; Error_log/opt/app/ruby/news/current/log/Nginx.error.log;   Client_max_body_size 4G; Keepalive_timeout5; Root/opt/app/ruby/news/current/Public ; Location^~/assets/{gzip on;    Expires Max; Add_header Cache-Control public; } try_files $uri/index.html $uri @unicorn;    Location @unicorn {proxy_redirect off;    Proxy_set_header Host $http _host; Proxy_set_header X-forwarded-For $proxy _add_x_forwarded_for; Proxy_set_header X-real-IP $remote _addr; Proxy_pass http://News_server; } error_page500 502 503 504/500. html; Location=/500. html {root/opt/app/ruby/news/current/Public ; }}

(2) In the server check the Nginx syntax, the way to view the location

[[email protected] opt] # nginx-t  is   is successful

View Nginx's configuration

Vim/etc/nginx/nginx.conf

Find the location where the default conf configuration file is placed

User Nginx;worker_processes8; Error_log/var/log/nginx/Error.log warn;pid/var/run/nginx.pid;events {worker_connections1024;} 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_timeout65; #gzip on;include/etc/nginx/conf.d/*.conf;

From the last word we can tell that all/etc/nginx/conf.d/under the suffix named. conf will be included in the file.

So we need to make a soft link, link the nginx configuration file in our application deployment directory to this folder, restart the detection syntax and restart Nginx

[[email protected] opt]#ln-s/opt/app/ruby/news/current/config/nginx.conf/etc/nginx/conf.d/new.conf[[email protected] opt]#ll/etc/nginx/conf.d/Total dosage 8-rw-r--r--1 root root 1097 September 16 2014default.conf-rw-r--r--1 root root 427 September 16 2014example_ssl.conflrwxrwxrwx1 root root 44 September 10:56 new.conf-/opt/app/ruby/news/current/config/Nginx.conf[[email protected] opt]#nginx-tNginx:the Configuration file/etc/nginx/nginx.conf Syntax isoknginx:configuration File/etc/nginx/nginx.conf Test isSuccessful[[email protected] opt]#Nginx-s Reload[[email protected] opt]#NETSTAT-TLNPActive Internet connections (only servers) Proto Recv-Q send-q Local address Foreign address State Pid/Program name TCP 0 00.0.0.0:xxxx 0.0.0.0:* LISTEN 8591/nginx:worker TCP 0 00.0.0.0:80 0.0.0.0:* LISTEN 8591/nginx:worker TCP 0 00.0.0.0:22 0.0.0.0:* LISTEN 2656/sshd TCP 0 00.0.0.0:xxxx 0.0.0.0:* LISTEN 8591/nginx:worker TCP 0 00.0.0.0:xxxx 0.0.0.0:* LISTEN 14200/python tcp6 0 0: ::3306:::* LISTEN 15326/mysqld tcp6 0 0: ::£ º::* LISTEN 5186/vsftpd tcp6 0 0: ::LISTEN:::* 2656/sshd

The Nginx configuration file associated with this application is placed under the current deployment folder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.