nginx 1.6 on centos 6.5

原创
2014/05/18 15:01
阅读数 530

<h2 style="-webkit-print-color-adjust: exact; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px; -webkit-font-smoothing: antialiased; cursor: text; position: relative; font-size: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #cccccc; font-family: Helvetica, arial, sans-serif; margin-top: 0px !important;">nginx 1.6 on centos 6.5</h2> <blockquote style="-webkit-print-color-adjust: exact; margin: 15px 0px; border-left-color: #dddddd; padding: 0px 15px; color: #777777; font-family: Helvetica, arial, sans-serif; font-size: 14px; line-height: 22px;"> <p style="-webkit-print-color-adjust: exact; margin: 0px;">这部分当做笔记,这里日常使用直接塞到脚本里即可</p> </blockquote> <h5 style="-webkit-print-color-adjust: exact; margin: 20px 0px 10px; padding: 0px; -webkit-font-smoothing: antialiased; cursor: text; position: relative; font-size: 14px; font-family: Helvetica, arial, sans-serif; line-height: 22px;">系统环境</h5> <pre style="-webkit-print-color-adjust: exact; margin: 15px 0px; background-color: #f8f8f8; border: 1px solid #cccccc; font-size: 13px; line-height: 19px; overflow: auto; padding: 6px 10px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="-webkit-print-color-adjust: exact; margin: 0px; padding: 0px; border: none; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">Distribution : CentOS 6.5 minimal <br />nginx version : 1.6.0 <br />Init system : sysvinit </code></pre> <h5 style="-webkit-print-color-adjust: exact; margin: 20px 0px 10px; padding: 0px; -webkit-font-smoothing: antialiased; cursor: text; position: relative; font-size: 14px; font-family: Helvetica, arial, sans-serif; line-height: 22px;">安装之前</h5> <pre style="-webkit-print-color-adjust: exact; margin: 15px 0px; background-color: #f8f8f8; border: 1px solid #cccccc; font-size: 13px; line-height: 19px; overflow: auto; padding: 6px 10px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="-webkit-print-color-adjust: exact; margin: 0px; padding: 0px; border: none; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">1.时间同步 <br />ntpdate 202.112.10.36 <br /><br />2.关闭selinux </code></pre> <h5 style="-webkit-print-color-adjust: exact; margin: 20px 0px 10px; padding: 0px; -webkit-font-smoothing: antialiased; cursor: text; position: relative; font-size: 14px; font-family: Helvetica, arial, sans-serif; line-height: 22px;">1、安装依赖</h5> <pre style="-webkit-print-color-adjust: exact; margin: 15px 0px; background-color: #f8f8f8; border: 1px solid #cccccc; font-size: 13px; line-height: 19px; overflow: auto; padding: 6px 10px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="-webkit-print-color-adjust: exact; margin: 0px; padding: 0px; border: none; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">yum groupinstall 'Development Tools' <br />yum -y install pcre-devel openssl-devel \\openssl-devel是为了后面的启用了ssl认证的功能 <br />groupadd -r nginx <br />useradd -r -g nginx nginx </code></pre> <h5 style="-webkit-print-color-adjust: exact; margin: 20px 0px 10px; padding: 0px; -webkit-font-smoothing: antialiased; cursor: text; position: relative; font-size: 14px; font-family: Helvetica, arial, sans-serif; line-height: 22px;">2、编译安装</h5> <pre style="-webkit-print-color-adjust: exact; margin: 15px 0px; background-color: #f8f8f8; border: 1px solid #cccccc; font-size: 13px; line-height: 19px; overflow: auto; padding: 6px 10px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="-webkit-print-color-adjust: exact; margin: 0px; padding: 0px; border: none; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">wget http://nginx.org/download/nginx-1.6.0.tar.gz <br />tar zxf nginx-1.6.0.tar.gz <br />cd nginx-1.6.0 <br />./configure \ <br /> --prefix=/usr/local/nginx \<br /> --sbin-path=/usr/local/nginx/sbin/nginx \<br /> --conf-path=/etc/nginx/nginx.conf \<br /> --error-log-path=/var/log/nginx/error.log \<br /> --http-log-path=/var/log/nginx/access.log \<br /> --pid-path=/var/run/nginx/nginx.pid \<br /> --lock-path=/var/lock/nginx.lock \<br /> --user=nginx \<br /> --group=nginx \<br /> --with-http_ssl_module \<br /> --with-http_flv_module \<br /> --with-http_stub_status_module \<br /> --with-http_gzip_static_module \<br /> --http-client-body-temp-path=/var/tmp/nginx/client/ \<br /> --http-proxy-temp-path=/var/tmp/nginx/proxy/ \<br /> --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \<br /> --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \<br /> --http-scgi-temp-path=/var/tmp/nginx/scgi \<br /> --with-pcre <br />make &amp;&amp; make install &amp;&amp; echo $? </code></pre> <h5 style="-webkit-print-color-adjust: exact; margin: 20px 0px 10px; padding: 0px; -webkit-font-smoothing: antialiased; cursor: text; position: relative; font-size: 14px; font-family: Helvetica, arial, sans-serif; line-height: 22px;">3、给定启动脚本</h5> <blockquote style="-webkit-print-color-adjust: exact; margin: 15px 0px; border-left-color: #dddddd; padding: 0px 15px; color: #777777; font-family: Helvetica, arial, sans-serif; font-size: 14px; line-height: 22px;"> <p style="-webkit-print-color-adjust: exact; margin: 0px;">这里根据刚才编译的选项需要做适当的修改</p> </blockquote> <pre style="-webkit-print-color-adjust: exact; margin-top: 15px; margin-right: 0px; margin-left: 0px; background-color: #f8f8f8; border: 1px solid #cccccc; font-size: 13px; line-height: 19px; overflow: auto; padding: 6px 10px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; margin-bottom: 0px !important;"><code style="-webkit-print-color-adjust: exact; margin: 0px; padding: 0px; border: none; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">#!/bin/sh <br /># <br /># nginx - this script starts and stops the nginx daemon <br /># <br /># chkconfig: - 85 15 <br /># description: Nginx is an HTTP(S) server, HTTP(S) reverse \ <br /># proxy and IMAP/POP3 proxy server <br /># processname: nginx <br /># config: /etc/nginx/nginx.conf <br /># config: /etc/sysconfig/nginx <br /># pidfile: /var/run/nginx.pid <br /># Source function library. <br />. /etc/rc.d/init.d/functions <br /><br /># Source networking configuration. <br />. /etc/sysconfig/network <br /><br /># Check that networking is up. <br />[ "$NETWORKING" = "no" ] &amp;&amp; exit 0 <br /><br />nginx="/usr/local/nginx/sbin" #这里的路径需要和编译的相符合 <br />prog=$(basename $nginx) <br /><br />NGINX_CONF_FILE="/etc/nginx/nginx.conf" #这里同上 <br /><br />[ -f /etc/sysconfig/nginx ] &amp;&amp; . /etc/sysconfig/nginx <br /><br />lockfile=/var/lock/subsys/nginx <br /><br />make_dirs() { <br /> # make required directories <br /> user=`nginx -V 2&gt;&amp;1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -` <br /> options=`$nginx -V 2&gt;&amp;1 | grep 'configure arguments:'` <br /> for opt in $options; do <br /> if [ `echo $opt | grep '.*-temp-path'` ]; <br /> then value=`echo $opt | cut -d "=" -f 2` <br /> if [ ! -d "$value" ]; then <br /> # echo "creating" $value <br /> mkdir -p $value &amp;&amp; chown -R $user $value <br /> fi <br /></code><span style="background-color: transparent;"> fi <br /> done <br />} <br /><br />start() { <br /> [ -x $nginx ] || exit 5 <br /> [ -f $NGINX_CONF_FILE ] || exit 6 <br /> make_dirs <br /> echo -n $"Starting $prog: " <br /> daemon $nginx -c $NGINX_CONF_FILE <br /> retval=$? <br /> echo <br /> [ $retval -eq 0 ] &amp;&amp; touch $lockfile <br /> return $retval <br />} <br /><br />stop() { <br /> echo -n $"Stopping $prog: " <br /> killproc $prog -QUIT <br /> retval=$? <br /> echo <br /> [ $retval -eq 0 ] &amp;&amp; rm -f $lockfile <br /> return $retval <br />} <br /><br />restart() { <br /> configtest || return $? <br /> stop <br /> sleep 1 <br /> start <br />} <br /><br />reload() { <br /> configtest || return $? <br /> echo -n $"Reloading $prog: " <br /> killproc $nginx -HUP <br /> RETVAL=$? <br /> echo <br />} <br /><br />force_reload() { <br /> restart <br />} <br /><br />configtest() { <br /> $nginx -t -c $NGINX_CONF_FILE <br />} <br /><br />rh_status() { <br /> status $prog <br />} <br /><br />rh_status_q() { <br /> rh_status &gt;/dev/null 2&gt;&amp;1 <br />} <br /><br />case "$1" in <br /> start) <br />rh_status_q &amp;&amp; exit 0 <br />$1 <br />;; <br /> stop) <br />rh_status_q || exit 0 <br />$1 <br />;; <br /> restart|configtest) <br />$1 <br />;; <br /> reload) <br />rh_status_q || exit 7 <br />$1 <br />;; <br /> force-reload) <br />force_reload <br />;; <br /> status) <br />rh_status <br />;; <br /> condrestart|try-restart) <br />rh_status_q || exit 0 <br />;; <br /> *) <br />echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" <br />exit 2 <br />esac <br /><br />#添加开启启动 <br />chmod +x /etc/init.d/nginx <br />chkconfig --add nginx <br />chkconfig nginx on <br />service nginx start</span></pre>

展开阅读全文
加载中

作者的其它热门文章

打赏
1
1 收藏
分享
打赏
3 评论
1 收藏
1
分享
返回顶部
顶部