zoukankan      html  css  js  c++  java
  • Nginx1.8 安装说明

      1 安装Nginx
      2 
      3 1、安装pcre
      4 
      5 cd /usr/local/src
      6 
      7 mkdir /usr/local/pcre
      8 
      9 tar zxvf pcre-8.36.tar.gz
     10 
     11 cd pcre-8.36
     12 
     13 ./configure --prefix=/usr/local/pcre
     14 
     15 make && make install
     16 
     17 2、安装openssl
     18 
     19 cd /usr/local/src
     20 
     21 mkdir /usr/local/openssl
     22 
     23 tar zxvf openssl-1.0.1h.tar.gz
     24 
     25 cd openssl-1.0.1h
     26 
     27 ./config --prefix=/usr/local/openssl
     28 
     29 make && make install
     30 
     31 vi /etc/profile
     32 
     33 export PATH=$PATH:/usr/local/openssl/bin
     34 
     35 :wq!
     36 
     37 source /etc/profile
     38 
     39 3、安装zlib
     40 
     41 cd /usr/local/src
     42 
     43 mkdir /usr/local/zlib
     44 
     45 tar zxvf zlib-1.2.8.tar.gz
     46 
     47 cd zlib-1.2.8
     48 
     49 ./configure --prefix=/usr/local/zlib
     50 
     51 make && make install
     52 
     53 4、安装Nginx
     54 
     55 groupadd www
     56 
     57 useradd -g www www -s /bin/false
     58 
     59 cd /usr/local/src
     60 
     61 tar zxvf nginx-1.8.0.tar.gz
     62 
     63 cd nginx-1.8.0
     64 
     65 mkdir -p /export/servers/nginx
     66 
     67 ./configure --prefix=/export/servers/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36
     68 
     69 注意:--with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36指向的是源码包解压的路径,而不是安装的路径,否则会报错
     70 
     71 make && make install
     72 
     73 /export/servers/nginx/sbin/nginx #启动Nginx
     74 
     75 设置nginx开机启动
     76 
     77 vi /etc/rc.d/init.d/nginx  #编辑启动文件添加下面内容
     78 
     79 
     80 ############################################################
     81 
     82 #!/bin/sh
     83 
     84 #
     85 
     86 # nginx - this script starts and stops the nginx daemon
     87 
     88 #
     89 
     90 # chkconfig: - 85 15
     91 
     92 # description: Nginx is an HTTP(S) server, HTTP(S) reverse 
     93 
     94 # proxy and IMAP/POP3 proxy server
     95 
     96 # processname: nginx
     97 
     98 # config: /etc/nginx/nginx.conf
     99 
    100 # config: /usr/local/nginx/conf/nginx.conf
    101 
    102 # pidfile: /usr/local/nginx/logs/nginx.pid
    103 
    104 # Source function library.
    105 
    106 . /etc/rc.d/init.d/functions
    107 
    108 # Source networking configuration.
    109 
    110 . /etc/sysconfig/network
    111 
    112 # Check that networking is up.
    113 
    114 [ "$NETWORKING" = "no" ] && exit 0
    115 
    116 nginx="/export/servers/nginx/sbin/nginx"
    117 
    118 prog=$(basename $nginx)
    119 
    120 NGINX_CONF_FILE="/export/servers/nginx/conf/nginx.conf"
    121 
    122 [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
    123 
    124 lockfile=/var/lock/subsys/nginx
    125 
    126 make_dirs() {
    127 
    128 # make required directories
    129 
    130 user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=([^ ]*).*/1/g' -`
    131 
    132 if [ -z "`grep $user /etc/passwd`" ]; then
    133 
    134 useradd -M -s /bin/nologin $user
    135 
    136 fi
    137 
    138 options=`$nginx -V 2>&1 | grep 'configure arguments:'`
    139 
    140 for opt in $options; do
    141 
    142 if [ `echo $opt | grep '.*-temp-path'` ]; then
    143 
    144 value=`echo $opt | cut -d "=" -f 2`
    145 
    146 if [ ! -d "$value" ]; then
    147 
    148 # echo "creating" $value
    149 
    150 mkdir -p $value && chown -R $user $value
    151 
    152 fi
    153 
    154 fi
    155 
    156 done
    157 
    158 }
    159 
    160 start() {
    161 
    162 [ -x $nginx ] || exit 5
    163 
    164 [ -f $NGINX_CONF_FILE ] || exit 6
    165 
    166 make_dirs
    167 
    168 echo -n $"Starting $prog: "
    169 
    170 daemon $nginx -c $NGINX_CONF_FILE
    171 
    172 retval=$?
    173 
    174 echo
    175 
    176 [ $retval -eq 0 ] && touch $lockfile
    177 
    178 return $retval
    179 
    180 }
    181 
    182 stop() {
    183 
    184 echo -n $"Stopping $prog: "
    185 
    186 killproc $prog -QUIT
    187 
    188 retval=$?
    189 
    190 echo
    191 
    192 [ $retval -eq 0 ] && rm -f $lockfile
    193 
    194 return $retval
    195 
    196 }
    197 
    198 restart() {
    199 
    200 #configtest || return $?
    201 
    202 stop
    203 
    204 sleep 1
    205 
    206 start
    207 
    208 }
    209 
    210 reload() {
    211 
    212 #configtest || return $?
    213 
    214 echo -n $"Reloading $prog: "
    215 
    216 killproc $nginx -HUP
    217 
    218 RETVAL=$?
    219 
    220 echo
    221 
    222 }
    223 
    224 force_reload() {
    225 
    226 restart
    227 
    228 }
    229 
    230 configtest() {
    231 
    232 $nginx -t -c $NGINX_CONF_FILE
    233 
    234 }
    235 
    236 rh_status() {
    237 
    238 status $prog
    239 
    240 }
    241 
    242 rh_status_q() {
    243 
    244 rh_status >/dev/null 2>&1
    245 
    246 }
    247 
    248 case "$1" in
    249 
    250 start)
    251 
    252 rh_status_q && exit 0
    253 
    254 $1
    255 
    256 ;;
    257 
    258 stop)
    259 
    260 rh_status_q || exit 0
    261 
    262 $1
    263 
    264 ;;
    265 
    266 restart|configtest)
    267 
    268 $1
    269 
    270 ;;
    271 
    272 reload)
    273 
    274 rh_status_q || exit 7
    275 
    276 $1
    277 
    278 ;;
    279 
    280 force-reload)
    281 
    282 force_reload
    283 
    284 ;;
    285 
    286 status)
    287 
    288 rh_status
    289 
    290 ;;
    291 
    292 condrestart|try-restart)
    293 
    294 rh_status_q || exit 0
    295 
    296 ;;
    297 
    298 *)
    299 
    300 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
    301 
    302 exit 2
    303 
    304 esac
    305 
    306 ############################################################
    307 
    308 :wq! #保存退出
    309 
    310 chmod 775 /etc/rc.d/init.d/nginx #赋予文件执行权限
    311 
    312 chkconfig nginx on #设置开机启动
    313 
    314 /etc/rc.d/init.d/nginx restart #重启
    315 
    316 
    317 
    318 
    319 
    320 log_format custom_log '[$status] || $time_local || $remote_addr || $http_x_forwarded_for || $request || $query_string || $body_bytes_sent || $http_referer || $request_time || $http_user_agent || $http_cookie || $host || up_addr:$upstream_addr || up_resp:$upstream_response_time || up_status:$upstream_status || $server_addr ';
    gomefinance
  • 相关阅读:
    Python-爬虫-解析库(pyquery)的使用
    Python-爬虫-解析库(Beautiful Soup)的使用
    Python-爬虫-基本库(requests)使用-抓取猫眼电影Too100榜
    Python-爬虫-基本库(requests)使用
    Go基础及语法(五)
    Go基础及语法(四)
    Go基础及语法(三)
    Go基础及语法(二)
    Go基础及语法(一)
    MySQL8.0随笔整理
  • 原文地址:https://www.cnblogs.com/liyongsan/p/7388774.html
Copyright © 2011-2022 走看看