与本应用相关的nginx配置文件放在当前部署文件夹下

(1)首先在current文件夹下新建服务有关的nginx配置文件nginx.conf

upstream news_server {
  server unix:/tmp/unicorn.news.sock fail_timeout=0;
}

server {
  listen 8888;
  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_timeout 5;

  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_page 500 502 503 504 /500.html;
  location = /500.html {
    root /opt/app/ruby/news/current/public;
  }
}

(2)在服务器检查下nginx语法,顺便查看位置

[[email protected] opt]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

查看nginx的配置

vim /etc/nginx/nginx.conf

找到默认conf配置文件放的位置

user  nginx;
worker_processes  8;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

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_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

从最后一句话中我们可以得知,所有/etc/nginx/conf.d/下的后缀名为.conf的配置文件都会被include进来,

所以需要做一个软链接,将我们应用部署目录下的nginx配置文件链到这个文件夹下,重启检测下语法 并重启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/
总用量 8
-rw-r--r-- 1 root root 1097 9月  16 2014 default.conf
-rw-r--r-- 1 root root  427 9月  16 2014 example_ssl.conf
lrwxrwxrwx 1 root root   44 9月  18 10:56 new.conf -> /opt/app/ruby/news/current/config/nginx.conf
[[email protected] opt]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[[email protected] opt]# nginx -s reload
[[email protected] opt]# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:xxxx            0.0.0.0:*               LISTEN      8591/nginx: worker
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      8591/nginx: worker
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2656/sshd
tcp        0      0 0.0.0.0:xxxx            0.0.0.0:*               LISTEN      8591/nginx: worker
tcp        0      0 0.0.0.0:xxxx            0.0.0.0:*               LISTEN      14200/python
tcp6       0      0 :::3306                 :::*                    LISTEN      15326/mysqld
tcp6       0      0 :::21                   :::*                    LISTEN      5186/vsftpd
tcp6       0      0 :::22                   :::*                    LISTEN      2656/sshd         
时间: 2024-08-06 11:54:07

与本应用相关的nginx配置文件放在当前部署文件夹下的相关文章

Android 使用存放在存assets文件夹下的SQLite数据库

因为这次的项目需要自带数据,所以就就把数据都放到一个SQLite的数据库文件中了,之后把该文件放到了assets文件夹下面.一开始打算每次都从assets文件夹下面把该文件夹拷贝到手机的SD卡或者手机自身的存储上之后再使用,后来考虑到每次都拷贝的话效率不高,并且如果涉及到对数据库的修改操作的话拷贝之后数据就被恢复了. 因此就写了该封装,该封装只是在第一次使用数据库文件的时候把该文件夹拷贝到手机的/data/data/应用程序报名/database文件夹下,之后就直接从这个地方使用了.并且它允许你

【转】五步教你实现使用Nginx+uWSGI+Django方法部署Django程序(下)

五步教你实现使用Nginx+uWSGI+Django方法部署Django程序(下) By Django中国社区 at 2013-05-18 04:38 在上一篇文章<五步教你实现使用Nginx+uWSGI+Django方法部署Django程序(上)>中,阐述了如何只使用uWSGI来部署Django程序. 当然,单单只有uWSGI是不够的,在实际的部署环境中,Nginx是必不可少的工具. 在本篇文章中,我将一直延用“N步法”的风格来阐述如何将uWSGI与Nginx做连接来部署Django程序.并

Example.ftl把它放在WebRoot下的Template文件夹下

啥是模板引擎.为啥要用模板引擎 一个简略的FreeMarkerDemo .导入Jar包:Struts2里面有这个Jar包.    FreeMarker需要freemarker-2.3.19.jar包.>.编写模板文件 FreeMarker模板文件的后缀名是ftl这里是写的一个Example.ftl把它放在WebRoot下的Template文件夹下. Example大家好,名字叫${name},家住在${address},本年${age}岁了! 模板的解析 FreeMarker数据模型也是模板中配

在电脑上找到这个路径:D:\jakarta-tomcat-6\conf\Catalina,将localhost目录直接删除掉,再一运行,就没事了! 因为配置文件中配置了启动程序,而webapps文件夹下却没有此应用程序,所以出现了上述错误。

java.lang.IllegalArgumentException: Document base D:\appservers\apache-tomcat-6.0.20\webapps\megaeyes_enterprise_manager does not exist or is not a readable directory 2010-05-20 15:28:31|  分类: tomcat|举报|字号 订阅 2010-5-20 15:22:44 org.apache.catalina.co

使用Nginx+uWSGI+Django方法部署Django程序(下)

在上一篇文章<五步教你实现使用Nginx+uWSGI+Django方法部署Django程序(上)>中,阐述了如何只使用uWSGI来部署Django程序. 当然,单单只有uWSGI是不够的,在实际的部署环境中,Nginx是必不可少的工具. 在本篇文章中,我将一直延用“N步法”的风格来阐述如何将uWSGI与Nginx做连接来部署Django程序.并在最后,会较为完整的阐述本社区的部署方法. 本文大纲: 环境介绍 配置uWSGI 配置Nginx Nginx+uWSGI+Django的实现方式 一些建

supersocket中quickstart文件夹下的MultipleCommandAssembly的配置文件分析

首先确认下配置文件中的内容 第一部分configSections[需要注意的是name=superSocket] <configSections> <section name="superSocket" type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine"/> </configSections> 第二部

Linux--对文件夹下的配置文件批量改动IP

sed -i 's/10.1.1.1/10.1.1.2/g' `grep -ir 10.1.1.1 * |grep -E '.xml:|.cfg:|.ini:|.wsdl:|.properties:' | awk -F: '{print $1}' | uniq ` 注:当中1为原IP,2为新IP :要扫描的配置文件请依据实际须要.

获取文件夹下所有文件(包括子文件)放在list&lt;File&gt;中

public static List<File> getAllFileList(File rootFile) { return getAllFileList(rootFile.getAbsolutePath(), null); } /** * 获取文件夹下所有文件(包括子文件) * * @param filePath * @param fileList * @return */ public static List<File> getAllFileList(String fileP

Android Studio App文件夹下这个Module的gradle配置文件

// 声明是Android程序 apply plugin: 'com.android.application' android { // 编译SDK的版本 compileSdkVersion 21 // build tools的版本 buildToolsVersion "21.1.1" defaultConfig { // 应用的包名 applicationId "me.storm.ninegag" minSdkVersion 14 targetSdkVersion