(2013-3-4)使用nginx反向代理blogger博客配置

(2013-3-4)使用nginx反向代理blogger博客配置

概述

本文详细描述了如何在Centos下安装nginx反向代理blogger博客,这样就可以从国内访问blogger平台的博客

本文HTML永久地址 doc

ningx安装

环境配置

yum install -y \
gcc gcc-c++ glibc glibc-devel glib2 glib2-devel unzip make automake autoconf \
ncurses ncurses-devel libjpeg libjpeg-devel libpng libpng-devel \
freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel bzip2 \
bzip2-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel \
libidn libidn-devel openssl openssl-devel openldap openldap-devel \
nss_ldap openldap-clients openldap-servers xinetd sudo \
pcre pcre-devel subversion

下载substitutions4nginx模块

cd /usr/src/
svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ substitutions4nginx-read-only
wget http://nginx.org/download/nginx-1.2.5.tar.gz
tar zxvf nginx-1.2.5.tar.gz
cd nginx-1.2.5

添加nginx用户和用户组

groupadd nginx
useradd -g nginx nginx

预编译选项参考 http://wiki.nginx.org/InstallOptions

./configure \
--prefix=/etc/nginx/ \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx --group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-http_sub_module \
--add-module=/usr/src/substitutions4nginx-read-only 

安装和编译

make
make install

配置开机启动

cd /etc/init.d/
wget -N http://lihaixin.googlecode.com/svn/trunk/conf/nginx/nginx
chmod +x nginx
chkconfig --add nginx
chkconfig --level 345 nginx on

启动:

nginx -V

配置缓存存放在内存上

mkdir /dev/shm/nginx
chmod 1777 /dev/shm/nginx
mkdir -p /var/cache/nginx
chmod -R 777 /var/cache/nginx
chown -R nginx:nginx /var/cache/nginx
mkdir -p /var/cache/nginx/client_temp
mount  -o noatime --bind /dev/shm/nginx  /var/cache/nginx/
echo "mount  -o noatime --bind /dev/shm/nginx  /var/cache/nginx/" >> /etc/rc.local

下载配置文件

cd /etc/nginx/
wget -N http://lihaixin.googlecode.com/svn/trunk/conf/nginx/nginx.conf
mkdir -p /etc/nginx/conf.d/
cd /etc/nginx/conf.d/
wget -N http://lihaixin.googlecode.com/svn/trunk/conf/nginx/http.conf
wget -N http://lihaixin.googlecode.com/svn/trunk/conf/nginx/splash.conf
wget -N http://lihaixin.googlecode.com/svn/trunk/conf/nginx/15099.net.conf
wget -N http://lihaixin.googlecode.com/svn/trunk/conf/nginx/lihaixin.name.conf
wget -N http://lihaixin.googlecode.com/svn/trunk/conf/nginx/vps-review.org.conf
wget -N http://lihaixin.googlecode.com/svn/trunk/conf/nginx/lixun.name.conf

编辑本地hosts文件

vi .bash_profile

rm -rf /etc/hosts
cd /etc/
wget -nv -N http://lihaixin.googlecode.com/svn/trunk/linux/hosts
cd

启动

nginx -t
/etc/init.d/nginx start

添加授权帐号

cd /etc/nginx/
printf "admin:$(openssl passwd -crypt blogger)\n" > htpasswd #加密admin帐号

没有评论 :

发表评论