Fighting!
欲戴皇冠,必承其重!
本文章已收录于:
分类:
作者同类文章
X
版权声明:本文为博主原创文章,未经博主允许不得转载。
阿里云nginx服务器多站点的配置
今天配置了一下多站点,记录一下配置的过程...
- 首先要找到nginx 配置文件之所在,阿里云上的nginx.conf 文件上 /alidata/server/nginx-1.4.4/conf 中。
- 然后在conf目录下创建一个vhosts 目录, 这个目录是用来存放不同站点的配置文件的。
- 然后呢, 在nginx.conf 最后 加入一行 include /alidata/server/nginx/conf/vhosts/*.conf;
- user www www;
- worker_processes 1;
- error_log /alidata/log/nginx/error.log crit;
- pid /alidata/server/nginx/logs/nginx.pid;
- #Specifies the value for maximum file descriptors that can be opened by this process.
- worker_rlimit_nofile 65535;
- events
- {
- use epoll;
- worker_connections 65535;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- #charset gb2312;
- server_names_hash_bucket_size 128;
- client_header_buffer_size 32k;
- large_client_header_buffers 4 32k;
- client_max_body_size 8m;
- sendfile on;
- tcp_nopush on;
- keepalive_timeout 60;
- tcp_nodelay on;
- fastcgi_connect_timeout 300;
- fastcgi_send_timeout 300;
- fastcgi_read_timeout 300;
- fastcgi_buffer_size 64k;
- fastcgi_buffers 4 64k;
- fastcgi_busy_buffers_size 128k;
- fastcgi_temp_file_write_size 128k;
- gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_http_version 1.0;
- gzip_comp_level 2;
- gzip_types text/plain application/x-javascript text/css application/xml;
- gzip_vary on;
- #limit_zone crawler $binary_remote_addr 10m;
- log_format '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
- # 加入下面一行 表示将 vhosts 下面所有的 conf 文件包含进来
- include /alidata/server/nginx/conf/vhosts/*.conf;
- }
user www www; worker_processes 1; error_log /alidata/log/nginx/error.log crit; pid /alidata/server/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; #charset gb2312; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; #limit_zone crawler $binary_remote_addr 10m; log_format '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; # 加入下面一行 表示将 vhosts 下面所有的 conf 文件包含进来 include /alidata/server/nginx/conf/vhosts/*.conf; }
- 然后,就是在vhosts 目录下写 你对应站点的 conf 文件了。下面给出一个范例
- server {
- listen 80;
- # 这个表示 网站域名, 可以是二级甚至多级域名
- server_name localhost demo.com www.demo.com test.demo.com;
- # 表示默认索引文件
- index index.html index.htm index.php;
- # 该站点对应的网站根目录所在
- root /alidata/www/demo;
- location ~ .*\.(php|php5)?$
- {
- #fastcgi_pass unix:/tmp/php-cgi.sock;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fastcgi.conf;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
- {
- expires 30d;
- }
- location ~ .*\.(js|css)?$
- {
- expires 1h;
- }
- # 伪静态规则
- include /alidata/server/nginx/conf/rewrite/phpwind.conf;
- access_log /alidata/log/nginx/access/phpwind.log;
- }
server { listen 80; # 这个表示 网站域名, 可以是二级甚至多级域名 server_name localhost demo.com www.demo.com test.demo.com; # 表示默认索引文件 index index.html index.htm index.php; # 该站点对应的网站根目录所在 root /alidata/www/demo; location ~ .*\.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } # 伪静态规则 include /alidata/server/nginx/conf/rewrite/phpwind.conf; access_log /alidata/log/nginx/access/phpwind.log; }
- 如果还要继续添加, 直接复制文件。然后修改一下 server_name, root, 和access_log(如果有必要的话) 就OK了。
- 然后,不要立马重启nginx,应该要先测试一下nginx 配置文件是否正常. 找到nginx 的 sbin目录。 注意, 这个地方是nginx 的sbin 目录(这个目录与nginx 的conf 目录是同级目录)。linux 下有许多与sbin同名的目录。 容易搞错。 在阿里云服务器上一般默认的目录是 /alidata/server/nginx-1.4.4/sbin。
- 输入 cd /alidata/server/nginx-1.4.4/sbin,然后输入 ./nginx -t ,如果控制台显示下面两行,则表示配置成功了,否则请根据提示继续检查配置文件。
nginx: the configuration file /alidata/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /alidata/server/nginx/conf/nginx.conf test is successful
- 配置成功之后, 就 需要重启 nginx 服务器。 在sbin目录下输入命令:./nginx -s reload, 然后整个过程就完成了。
- 启动
- ./nginx
- 重启
- ./nginx -s reload
- 关闭
- ps -ef | grep nginx # 查询nginx主进程号
- 从容停止 kill -QUIT 主进程号
- 快速停止 kill -TERM 主进程号
- 强制停止 kill -9 nginx
- 若nginx.conf配置了pid文件路径,如果没有,则在logs目录下
- kill -信号类型 '/usr/local/nginx/logs/nginx.pid'
- 判断配置文件是否正确
- ./nginx -t
启动
./nginx
重启
./nginx -s reload
关闭
ps -ef | grep nginx # 查询nginx主进程号
从容停止 kill -QUIT 主进程号
快速停止 kill -TERM 主进程号
强制停止 kill -9 nginx
若nginx.conf配置了pid文件路径,如果没有,则在logs目录下
kill -信号类型 '/usr/local/nginx/logs/nginx.pid'
判断配置文件是否正确
./nginx -t
-
顶
- 1
-
踩
- 0
我的同类文章
http://blog.csdn.net
- •让ThinkPHP3.2.3 支持对Oracle LOB数据的操作2016-12-12
- •ThinkPHP 3.2.3+ORACLE插入数据BUG修复及支持获取自增Id的上次记录2016-12-09
- •Oracle数据库中日期格式的转换2016-12-11
- •POST & GET & Ajax 全解2016-03-29
关闭
核心技术类目
全部主题
Hadoop
AWS
移动游戏
Java
Android
iOS
Swift
智能硬件
Docker
OpenStack
VPN
Spark
ERP
IE10
Eclipse
CRM
JavaScript
数据库
Ubuntu
NFC
WAP
jQuery
BI
HTML5
Spring
Apache
.NET
API
HTML
SDK
IIS
Fedora
XML
LBS
Unity
Splashtop
UML
components
Windows Mobile
Rails
QEMU
KDE
Cassandra
CloudStack
FTC
coremail
OPhone
CouchBase
云计算
iOS6
Rackspace
Web App
SpringSide
Maemo
Compuware
大数据
aptech
Perl
Tornado
Ruby
Hibernate
ThinkPHP
HBase
Pure
Solr
Angular
Cloud Foundry
Redis
Scala
Django
Bootstrap
- 个人资料
-
- 访问:159368次
- 积分:4138
- 等级:
- 排名:第6482名
- 原创:231篇
- 转载:10篇
- 译文:0篇
- 评论:28条
- 文章搜索
- 文章分类
- ------>>ACM<<------(60)
- ACM____数据结构(66)
- ACM____单调栈/单调队列(6)
- ACM____树链剖分(3)
- ACM____主席树(4)
- ACM____Splay/Treap(0)
- ACM____图 论(24)
- ACM____网络流(0)
- ACM____二分图匹配(1)
- ACM____一般图匹配(0)
- ACM____强联通分量(5)
- ACM____搜 索(9)
- ACM____回 溯(1)
- ACM____二分/三分(16)
- ACM____数 论(34)
- ACM____高精度(2)
- ACM____矩阵快速幂(9)
- ACM____高斯消元(3)
- ACM____动态规划(36)
- ACM____数位DP(3)
- ACM____博 弈(6)
- ACM____莫队/分块(3)
- ACM____FFT&NTT(1)
- ACM____贪 心(2)
- ACM____STL(9)
- ACM____暴 力/模拟(7)
- ACM____水 题(14)
- ACM____思维题(16)
- ACM____套 题(3)
- ACM____模 板(16)
- CCF(4)
- ------>>实验室<<------(1)
- C/C++学习(3)
- 小作品(2)
- PHP(5)
- WEB(5)
- Java(4)
- 杂谈(5)
- Matlab(2)
- 文章存档
- 阅读排行
- Sublime 字体设置(5616)
- 第七次CCF计算机软件能力认证题解(3150)
- ACM 常用几何基本数学公式(3041)
- Matlab 图像平移、旋转、缩放、镜像(2363)
- 欧几里得 & 拓展欧几里得算法 讲解 (Euclid & Extend- Euclid Algorithm)(2352)
- php封装生成验证码VerifyImage类(2086)
- hdu 2579 Dating with girls(2) 【经典三维BFS】(1969)
- POJ 3694 Network Tarjan求边双连通+LCS+并查集(1888)
- 2015年长春区域网络赛 hdu 5441 Travel【并查集】(1861)
- 2010年辽宁省赛 NBUT 1218【DFS实现树的遍历与更新】(1794)
- 评论排行
- csu 1685: Entertainment Box【湖南省多校对抗赛3.6】multiset妙用(3)
- [Codeforces #369 (Div. 2)E. ZS and The Birthday Paradox]勒让德定理+逆元(3)
- 第七次CCF计算机软件能力认证题解(2)
- POJ 2828 - Buy Tickets 【线段树】(2)
- 2015 CSUST校赛 - 超级快速幂【费马小定理】+【快速幂取模】(2)
- Poj 1321 棋盘问题 【回溯、类N皇后】(2)
- [SPOJ INS14G Kill them All]数学、排列组合(2)
- csu 1774 慷慨的奖励[双向链表](2)
- POJ 3071 Football 【概率DP】(2)
- poj 2406 Power Strings 【KMP + 技巧处理】(1)
- 最新评论
- [SPOJ INS14G Kill them All]数学、排列组合
xxw1996:这个照片我是当时在Acfun群里面看到的。书名我也不知道...
- UVA 12657 Boxes in a Line 【双向链表】
Good_night_Sion_:啊哈哈。。果不其然的进入坑了。。。感谢一下
- [SPOJ INS14G Kill them All]数学、排列组合
z597797222:咦咦咦,博主这是什么书
- 第七次CCF计算机软件能力认证题解
xxw1996:@AboutChristina:我那个是"|=", 所以可以不加条件判断了的。
- 第七次CCF计算机软件能力认证题解
aboutchristina:第二题,pirnt函数应该再加一个判断。 if(GBUF!=1) ...
- [Codeforces #369 (Div. 2)E. ZS and The Birthday Paradox]勒让德定理+逆元
xxw1996:@zcj5027:因为∏i=Ki=1(2N−i+1)与(K−1)!. 的分解式中2的指数相同,所以可...
- [Codeforces #369 (Div. 2)E. ZS and The Birthday Paradox]勒让德定理+逆元
xxw1996:@zcj5027:嗯嗯。已经更正啦。谢谢指正~
- [Codeforces #369 (Div. 2)E. ZS and The Birthday Paradox]勒让德定理+逆元
黑猫5027:观察分子,∏i=Ki=1(2N−i+1)就等价于(K−1)!. 对于这句话,博主写错了吧?,加入我...
- hdu 1254 推箱子 BFS
77458:好是好,就是代码太密
- csu 1774 慷慨的奖励[双向链表]
xxw1996:@qq_31841403:只能把文字copy了。
收藏助手
暂无评论