六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 46|回复: 0

nginx

[复制链接]

升级  8%

62

主题

62

主题

62

主题

举人

Rank: 3Rank: 3

积分
224
 楼主| 发表于 2013-2-7 17:02:44 | 显示全部楼层 |阅读模式
一,nginx的location设置
设置图片过期,既是设置http头的Expires和Cache-Control头,过期时间为一个月
 location ~* \.(gif|jpg|jpeg|png|ico|rar)$ {
        expires 1M;
    }
 
二,修改首页文件及重定向
如果输入地址栏的是目录路径,首先寻找xxx/xxx.html,未找到后再找index.html
index xxx/xxx.html index.html;
 
访问abc.com将301到def.com
server {
    server_name  abc.com;
    rewrite ^(.*) http://def.com$1 permanent;
}
 
三,nginx安装
1,
sudo ./configure --user=nginx --group=nginx --pid-path=/opt/nginx/nginx.pid --prefix=/opt/nginx --with-pcre --with-debug
 
出错:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决:
sudo apt-get install libpcre3 libpcre3-dev
 
出错:/configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
 
解决:
sudo apt-get install libssl-dev
 
2, sudo make  && sudo make install
 
3,启动
添加用户及用户组
sudo groupadd nginx
sudo useradd -g nginx nginx
 
sudo /opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表