发表于 2018-11-11 06:57:04

CentOS6.9+Nginx1.12+PHP5.6.32+mysql5.7.20安装笔记

tar xf nginx-1.12.2.tar.gz  cd nginx-1.12.2
  新建nginx用户
  groupadd -g 118-r nginx
  useradd -u 118 -g nginx nginx -s /bin/false
  mkdir /usr/local/nginx
  ./configure --user=nginx--group=nginx   --with-pcre=/usr/local/src/pcre-8.41--with-openssl=/usr/local/src/openssl-1.0.2n--with-zlib=/usr/local/src/zlib-1.2.11 --prefix=/usr/local/nginx--sbin-path=/usr/local/nginx/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--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_gunzip_module   --with-http_gzip_static_module--with-http_random_index_module--with-http_secure_link_module   --with-http_stub_status_module--with-http_auth_request_module--with-file-aio
  make && make install
  chown -R root:nginx /usr/local/nginx/*
  制作启动控制文件
  vim/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
  # config:      /etc/nginx/nginx.conf
  # config:      /etc/sysconfig/nginx
  # pidfile:   /var/run/nginx.pid
  # 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"#注意nginx文件位置
  prog=$(basename $nginx)
  NGINX_CONF_FILE="/etc/nginx/nginx.conf"
  [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
  lockfile=/var/lock/subsys/nginx
  make_dirs() {
  # make required directories
  user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
  options=`$nginx -V 2>&1 | grep 'configure arguments:'`
  for opt in $options; do
  if [ `echo $opt | grep '.*-temp-path'` ]; then
  value=`echo $opt | cut -d "=" -f 2`
  if [ ! -d "$value" ]; then
  # echo "creating" $value
  mkdir -p $value && chown -R $user $value
  fi
  fi
  done
  }
  start() {
  [ -x $nginx ] || exit 5
  [ -f $NGINX_CONF_FILE ] || exit 6
  make_dirs
  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
  chkconfig --list nginx
  nginx         0:off   1:off   2:on    3:on    4:on    5:on    6:off
  启动nginx
  service nginx start
  警告,权限不够:
  chown: missing operand after `/var/cache/nginx/client_temp'
  Try `chown --help' for more information.
  chown: missing operand after `/var/cache/nginx/proxy_temp'
  Try `chown --help' for more information.
  chown: missing operand after `/var/cache/nginx/fastcgi_temp'
  Try `chown --help' for more information.
  chown: missing operand after `/var/cache/nginx/uwsgi_temp'
  Try `chown --help' for more information.
  chown: missing operand after `/var/cache/nginx/scgi_temp'
  Try `chown --help' for more information.
  service nginx stop
  #修改/var/cache/nginx 目录权限:
  chown -R nginx:nginx /var/cache/nginx
  再次启动;
  service nginx start
  Starting nginx:                                          
  检查端口信息
  netstat -ntulp
  Active Internet connections (only servers)
  Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
  tcp      0      0 0.0.0.0:111               0.0.0.0:*                   LISTEN      1503/rpcbind
  tcp      0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      860/nginx
  tcp      0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      32556/sshd
  tcp      0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1581/cupsd
  tcp      0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      9527/master
  tcp      0      0 0.0.0.0:58940               0.0.0.0:*                   LISTEN      1525/rpc.statd
  tcp      0      0 :::45128                  :::*                        LISTEN      1525/rpc.statd
  tcp      0      0 :::111                      :::*                        LISTEN      1503/rpcbind
  tcp      0      0 :::22                     :::*                        LISTEN      32556/sshd
  tcp      0      0 ::1:631                     :::*                        LISTEN      1581/cupsd
  tcp      0      0 ::1:25                      :::*                        LISTEN      9527/master
  udp      0      0 127.0.0.1:853               0.0.0.0:*                               1525/rpc.statd
  udp      0      0 0.0.0.0:111               0.0.0.0:*                               1503/rpcbind
  udp      0      0 0.0.0.0:631               0.0.0.0:*                               1581/cupsd
  udp      0      0 0.0.0.0:50942               0.0.0.0:*                               1525/rpc.statd
  udp      0      0 0.0.0.0:830               0.0.0.0:*                               1503/rpcbind
  udp      0      0 :::111                      :::*                                    1503/rpcbind
  udp      0      0 :::36005                  :::*                                    1525/rpc.statd
  udp      0      0 :::830                      :::*                                    1503/rpcbind
  测试
  http://192.168.1.112/

页: [1]
查看完整版本: CentOS6.9+Nginx1.12+PHP5.6.32+mysql5.7.20安装笔记