NGINX 中文站

NGINX安装,最新下载,配置,优化等

  • 首页
  • About NGINX
  • NGINX 最新版本下载
  • 看看都有哪些网站在使用Nginx

存档

‘Nginx 安装使用’ 分类的存档

nginx 在 centos 环境下安装

2011年5月12日 iNginx 没有评论
yum install mysql mysql-server php php-mysql php-gd
cp /var/lib/mysql /www/mysql
mysql_install_db 
service mysql start
安装nginx
安装 nginx 出错 缺少 PCRE library 库
安装 openssl-devel
./configure –prefix=/www/nginx –prefix=/www/nginx
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
sudo chown www:www -R /www
sudo ./nginx
killall – s HUP nginx
nginx 安装成功!
~/spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi

 

分类: Nginx 安装使用 标签:

DirectAdmin安装Nginx方法

2010年9月20日 iNginx 没有评论

下载nginx。
下载 后,编译。
tar zxvf nginx-0.7.66.tar.gz
cd nginx-0.7.66
./configure –prefix=/usr/local/nginx –user=nginx –group=nginx –with-http_stub_status_module –with-http_ssl_module
make
make install
然后先不要启动nginx,对conf文件做一些修改,主要是对缓存部分的设置。
vi /usr/local/nginx/conf/nginx.conf
里面对缓存的设置部分如下。写在http段里
proxy_temp_path /usr/local/nginx/proxy_temp;
proxy_cache_path /usr/local/nginx/proxycache levels=1:2 keys_zone=CachePool:300m inactive=1d max_size=3g;

server {
listen 真实的公网IP:80;
server_name localhost;

location / {
proxy_pass http://127.0.0.2;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header FORWARDED-FOR $remote_addr;
proxy_set_header Host $host;

location ~* \.(js|css|gif|png|bmp|jpeg|jpg|swf)$ {
proxy_pass http://127.0.0.2;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;

proxy_cache CachePool;
#proxy_cache_key $host$request_uri$http_if_modified_since;
proxy_cache_key $host$request_uri;
proxy_cache_valid 5m;
}
}
一些解释
max_size=3g 缓存占用的最大空间3G
proxy_pass http://127.0.0.2 回头我们要把apache的监听改成监听这个IP的80端口。当然,也可以用其他端口和其他IP,这个自由设置。
proxy_cache_valid 5m; 缓存生存时间5分钟。这个时间的设置也要根据主机上的站点来具体设置,没有任何可以作为标准的说法。

设置完后,先停止 httpd。
/etc/init.d/httpd stop
/etc/init.d/directadmin stop
directadmin 也一定是要停的,不然会自动启动httpd进程。
修改文件
/etc/httpd/conf/extra/httpd-vhosts.conf
对应添加修改成
LogFormat “%O \”%r\”" homedir
NameVirtualHost 127.0.0.2:80
NameVirtualHost 真实公网IP:443

ServerAdmin webmaster@localhost
AliasMatch ^/~([^/]+)(/.*)* /home/$1/public_html$2
DocumentRoot /var/www/html
ServerName localhost
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
CustomLog /var/log/httpd/homedir.log homedir

然 后安装一个apache需要的小模块。
wget http://www.openinfo.co.uk/apache/extract_forwarded-2.0.2.tar.gz
tar zxvf extract_forwarded-2.0.2.tar.gz
cd extract_forwarded
apxs -c -i -a mod_extract_forwarded.c
结束后修改/etc/httpd/conf/httpd.conf

ServerRoot “/etc/httpd”
Listen 127.0.0.2:80

#LoadModule dummy_module /usr/lib/apache/mod_dummy.so
#LoadModule php5_module /usr/lib/apache/libphp5.so
LoadModule extract_forwarded_module /usr/lib/apache/mod_extract_forwarded.so
MEForder refuse,accept
MEFrefuse all
MEFaccept 127.0.0.2
Include /etc/httpd/conf/extra/httpd-phpmodules.conf
FileETag none

User apache
Group apache

ServerAdmin admin@localhost
DocumentRoot “/var/www/html”

接下来是修改directadmin里已经建立的用户的对应配置。
cd /usr/local/directadmin/data/users
find -name ‘*.conf’ | xargs perl -pi -e ’s|真实公网IP|127.0.0.2|g’
然后修改directadmin的模板,让以后新添加的用户也自动启用对应的设置。
进 入/usr/local/directadmin/data/templates/custom 自定义模板的地方
里面需要从上层目录拷贝6个 文件进来。
ips_virtual_host.conf
virtual_host2.conf
virtual_host.conf
redirect_virtual_host.conf
virtual_host2_sub.conf
virtual_host_sub.conf
然后对应修改这六个文件中的部 分,主要就是类似的地方修改成,让directadmin生成用户配置文件的时候不写入真实IP,直接用127.0.0.2来代替。
然后就可 以了,检查确认无误。
/etc/init.d/httpd start
/usr/local/nginx/sbin/nginx (启动nginx)
检查进程,里面已经有nginx和httpd同时在跑了。初次的缓存生成后,用户再次读取静态文件的时候,就不需要麻烦 apache去了。
nginx的高级设置,这个就另外自行查看资料了。

分类: Nginx 安装使用 标签: DirectAdmin

使用nginx 给你的网站绑定独立IP

2010年4月12日 iNginx 没有评论

对于多个域名多个IP的服务器,有时候我们需要用户不能通过的IP直接访问网站。这有的时候是因为IDC机房的需要,有的时候是我们为了将网站直接隔绝开的需要。本文是想讨论Nginx下如何实现这样的设置。

如果是Apache的话比较好设定,可以用NameVirtualHost来指定哪个IP绑定哪个域名,但是nginx应该如何把ip绑定到域名商呢?Slicehost论坛上也有人讨论过如何绑定ip的问题。核心的问题就是,如果直接输入ip,nginx会把这个ip对应到哪个域名上呢?答案是随机的。如果想要在某个域名做为catchall的,可以设定如下规则:

server{
listen 80 default;
....
}

那么如何绑定独立IP呢?由于ip信息其实是在在NGINX官方HTTPcore Listen的说明文档上也提到了这个是用方法,可以比较方便的是使用如下

server{
listen 99.69.16.3:80;
server_name www.inginx.com
....
}

也可以直接这样写:

server{
listen 114.163.186.110;
server_name www.abc.com
....
}
server{
listen 99.69.16.3;
server_name www.abe.com
....
}

这样独立的ip就被绑定到固定的域名上去了。

分类: Nginx 安装使用 标签: 独立IP

Nginx 升级

2010年3月24日 iNginx 1 条评论

因为最近作者指出nginx一直以来都存在一个安全漏洞,因此今天升级了nginx

[root@unixhater ~]# cd /opt/nginx/
[root@unixhater nginx]# sbin/nginx -V #查看版本
nginx version: nginx/0.7.61
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-44)
configure arguments: –user=www –group=www –prefix=/opt/nginx –with-http_stub_status_module –with-http_ssl_module #注意这里的编译项
[root@unixhater nginx]# wget http://sysoev.ru/nginx/nginx-0.7.62.tar.gz #下载
[root@unixhater nginx]# tar xzvf nginx-0.7.62.tar.gz #解压缩
[root@unixhater nginx]# cd nginx-0.7.62

[root@unixhater nginx-0.7.62]# ./configure –user=www –group=www –prefix=/opt/nginx –with-http_stub_status_module –with-http_ssl_module #按原来的选项configure
[root@unixhater nginx-0.7.62]# make #编译
[root@unixhater nginx-0.7.62]# mv /opt/nginx/sbin/nginx /opt/nginx/sbin/nginx.old #移动旧版本
[root@unixhater nginx-0.7.62]# cp objs/nginx /opt/nginx/sbin/ #复制新版本nginx过去
[root@unixhater nginx-0.7.62]# make upgrade #无缝升级,当前连接不会断

[root@unixhater nginx-0.7.62]# cd ..
[root@unixhater nginx]# sbin/nginx -V
nginx version: nginx/0.7.62
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-44)
configure arguments: –user=www –group=www –prefix=/opt/nginx –with-http_stub_status_module –with-http_ssl_module
[root@unixhater nginx]# rm -rf nginx-0.7.62 nginx-0.7.62.tar.gz #清理

分类: Nginx 安装使用 标签: 升级

Nginx限制IP,限制目录访问的设置

2010年3月9日 iNginx 没有评论
location /private/ {
    allow 192.168.1.0/24;
    deny all;
}
location ~ ^/private/.*\.php$ {
    allow 192.168.1.0/24;
    deny all;
    include conf/enable_php5.conf;
}
location ~ \.php$ {
    include conf/enable_php5.conf;
}

这样就可以实现目录private只允许192.168.1.0/24的访问了

分类: Nginx 安装使用 标签: ip, 限制
Page 1 of 3123»
订阅
  • Google
  • 有道
  • 鲜果
  • 抓虾
  • My Yahoo!
  • newsgator
  • Bloglines
  • 哪吒

最新文章

  • nginx 在 centos 环境下安装
  • nginx轻松搭建自己的flv流媒体服务器
  • DirectAdmin安装Nginx方法
  • Nginx 最新版本 0.8.38 发布
  • Nginx重大漏洞,文件类型错误解析
  • Nginx 目录访问末尾自动加斜线 /
  • Nginx电子书下载:《实战Nginx:取代Apache的高性能Web服务器》pdf电子书下载
  • nginx负载均衡器处理session共享的几种方法
  • Apache Rewrite伪静态规则转换为Nginx Rewrite
  • Nginx出现“413 Request Entity Too Large”错误解决方法

标签云

上传 下载 中文URL 升级 密码 新闻 漏洞 独立IP 目录浏览 缓存 编码 脚本 虚拟主机 认证 负载均衡 配置文件 重定向 错误 防盗链 限制 301 404 502 apache cache conf DirectAdmin discuz fastcgi ip Mysql Nginx nginx电子书 nginx log PHP rewrite supesite URL vps WEB服务器 windows wordpress

分类

  • Nginx 优化技巧
  • Nginx 安装使用
  • Nginx 成功分享
  • Nginx 最新下载
  • Nginx 疑难解决

链接

  • Nginx 官方网站
  • UnixBeta.com
  • Pagerank
  • Flash game

存档

  • 2011年五月
  • 2010年九月
  • 2010年五月
  • 2010年四月
  • 2010年三月
  • 2010年二月

Meta

  • 注册
  • 登录
回到顶部
版权所有 © 2010 NGINX 中文站
Powered by wordpress. Theme by NeoEase . 通过 XHTML 1.1 和 CSS 3 验证.