标签:code 进程 修改 启动 orm 查看 please RoCE everyone
环境gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar -xvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
# 添加Nginx组
groupadd nginx
# 添加Nginx用户
useradd nginx -g nginx -s /sbin/nologin -M
./configure --user=nginx \ # 设置用户名
--group=nginx \ # 设置用户组
--prefix=/usr/local/nginx \ # 设置安装位置
--pid-path=/var/run/nginx/nginx.pid \ #进程文件
--lock-path=/var/lock/nginx.lock \ #锁
--error-log-path=/var/log/nginx/error.log \ #日志
--http-log-path=/var/log/nginx/access.log \ #日志
--with-http_stub_status_module \ # 用来监控 Nginx 的当前状态
--with-http_ssl_module \ # 打开HTTPS功能
--with-http_realip_module \ # 允许改变客户端请求头中X-Real-IP 或 X-Forwarded-For等, 可用于记录客户IP
--with-http_gzip_static_module \ #预压缩文件传前检查,防止文件被重复压缩
--http-client-body-temp-path=/var/temp/nginx/client \ # #客户端请求临时文件路径
--http-proxy-temp-path=/var/temp/nginx/proxy \ #设置http proxy临时文件路径
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ #设置http fastcgi临时文件路径
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ #设置uwsgi 临时文件路径
--http-scgi-temp-path=/var/temp/nginx/scgi #设置scgi 临时文件路径
make && make install
#切换到安装位置,也就是之前配置configure的
cd /usr/local/nginx/sbin/
#启动
#注:nginx.conf 是 nginx 的默认配置文件。也可以使用 nginx -c 指定配置文件启动
./nginx
#启动失败
按照提示创建对应client目录
mkdir -r /var/temp/nginx/client # 自己创建的 ,对应目录
#启动成功查看nginx进程(master进程和worker进程)
ps -ef | grep nginx
停止nginx
方式1,快速停止:
cd /usr/local/nginx/sbin
./nginx -s stop
此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
方式2,完整停止(建议使用):
cd /usr/local/nginx/sbin
./nginx -s quit
此方式停止步骤是待nginx进程处理任务完毕进行停止。
重启nginx
方式1,先停止再启动(建议使用):
对nginx进行重启相当于先停止nginx再启动nginx,即先执行停止命令再执行启动命令。
如下:
./nginx -s quit
./nginx
方式2,重新加载配置文件:
./nginx -s reload
当nginx的配置文件nginx.conf修改后,要想让配置生效需要重启nginx,使用-s reload不用先停止nginx再启动nginx即可将配置 信息在
将下面的文件, 写到/etc/init.d/nginx
中
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
#
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it‘s not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/var/run/nginx/nginx.pid
RETVAL=0
prog="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
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog: "
$nginxd -s reload
#if your nginx version is below 0.8, please use this command: "kill -HUP `cat ${nginx_pid}`"
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL
chmod 755 /etc/init.d/nginx
chkconfig --level 345 nginx on
标签:code 进程 修改 启动 orm 查看 please RoCE everyone
原文地址:https://blog.51cto.com/13767724/2372294