为了玩Lua、Redis和Nginx,做好准备
安装
假设已经安装了Redis。
cd /usr/local/src
# luaのinstall
wget -O lua-nginx-module.tar.gz https://github.com/chaoslawful/lua-nginx-module/tarball/master
tar zxvf lua-nginx-module.tar.gz
# luajitのinstall
wget http://luajit.org/download/LuaJIT-2.0.0.tar.gz
tar zxvf LuaJIT-2.0.0.tar.gz
cd LuaJIT-2.0.0
make
#lua-nginx-moduleのダウンロード
git clone https://github.com/chaoslawful/lua-nginx-module.git
#nginxのダウンロード
wget http://nginx.org/download/nginx-1.3.6.tar.gz
tar zxvf nginx-1.3.6.tar.gz
cd nginx-1.3.6
# 必要なモジュールintall
yum -y install pcre-devel libxml2 libxml2-devel libxslt libxslt-devel gd-devel GeoIP-devel perl-devel
#configure
./configure \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module \
--with-http_image_filter_module \
--with-http_geoip_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_degradation_module \
--with-http_stub_status_module \
--with-debug \
--add-module=/usr/local/src/lua-nginx-module \
--add-module=/usr/local/src/ngx_http_redis-0.3.6 \
--add-module=/usr/local/src/ngx_cache_purge-2.0 \
--add-module=/usr/local/src/agentzh-headers-more-nginx-module-27bcbd2
make
make install
启动周围等
创建一个名为/nginx的执行文件,内容如下:/etc/init.d/nginx。
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/usr/local/nginx/logs/nginx.lock
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
随后,进行以下设置以自动启动。
chmod +x /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
service nginx start
我会尝试玩各种游戏。
请参考
http://d.hatena.ne.jp/jimsei/20120926/1348683140 – 请点击此链接以阅读文中内容。
http://www.happytrap.jp/blogs/2012/02/23/8243/ – 请点击此链接以查看详细信息。
顺便提一句
我曾尝试安装with-http-perl-module,但由于perl版本不兼容而放弃了。然后,我实际上还安装了cache_perge和headers_more模块。