与本应用相关的nginx配置文件放在当前部署文件夹下
来源:互联网 发布:常用的组态软件 编辑:程序博客网 时间:2024/05/21 16:26
(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语法,顺便查看位置
[root@localhost opt]# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: 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
[root@localhost opt]# ln -s /opt/app/ruby/news/current/config/nginx.conf /etc/nginx/conf.d/new.conf[root@localhost 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.conflrwxrwxrwx 1 root root 44 9月 18 10:56 new.conf -> /opt/app/ruby/news/current/config/nginx.conf[root@localhost opt]# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful[root@localhost opt]# nginx -s reload[root@localhost opt]# netstat -tlnpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:8080 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:8888 0.0.0.0:* LISTEN 8591/nginx: worker tcp 0 0 0.0.0.0:8000 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
0 0
- 与本应用相关的nginx配置文件放在当前部署文件夹下
- 在myeclipse下,把jar包部署到其他文件夹,而不是放在WEB-INF/lib的文件夹下
- Eclipse下,把jar包部署到其他文件夹,而不是放在WEB-INF/lib的文件夹下
- 在Myeclipse中开发WEB应用新建文件夹的必须放在WebRoot下
- 01_Nginx安装,nginx下部署项目,nginx.conf配置文件修改,相关文件配置
- workspace放在nfs的个人文件夹下
- J2EE开发配置文件放在src目录下的好处
- Nginx在Linux下的安装部署
- eclipse如何把多个项目放在文件夹下,用文件夹分开不同的项目
- shape的使用创建步骤文件要放在drawable文件夹下如果放在layout下会报错
- 编译src目录下的源文件,然后放在compile文件夹下,接着把compile下的class文件打包,放在dist文件夹下
- 编译src目录下的源文件,然后放在compile文件夹下,接着把compile下的class文件打包,放在dist文件夹下,并设置清单
- Nginx ----- Windows下Nginx的安装与部署
- 让Mac 默认在当前文件夹下搜索的方法
- Nginx在windows下的简单应用
- 编译src目录下的源文件,然后放在compile文件夹下
- Libs文件夹下的Jar文件为什么不会自动放在Android Private Libraries目录下
- 在普通文件夹下部署ASP.NET程序的方法
- crf++-0.58用于分词
- opencv用鼠标在窗口中画方形的程序
- CSS 两列布局
- 安装完Java虚拟机后,在cmd命令提示符窗口中使用DOS命令,提示“不是内部或外部命令,也不可运行的程序”的解决办法
- Gradle-使用Gradle构建和测试-2-GradleTasks(一)
- 与本应用相关的nginx配置文件放在当前部署文件夹下
- Java编程思想第四版读书笔记——第一章 对象导论
- Spring Websocket 开发
- 数据结构中的排序
- C++STL 编程技巧1 STL中各种排序算法的实现
- Java成果之简易计算器——NetBeans
- Cocos2d-x 屏幕适配
- tab网页制作
- C# datagrid加载不了数据