nginx指定配制文件

nginx启动:

未指定配制文件:
./nginx

指定配制文件:
/usr/local/nginx/sbin/nginx -c /home/deploy/nginx-wz/conf/nginx.conf

nginx重启

./nginx -s reload

验证nginx.conf是否正确

./nginx -t

nginx -t -c /usr/local/nginx/conf/nginx.conf

 Nginx安装:

1:安装插件:
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
2:下载并解压到指定目录:
wget http://nginx.org/download/nginx-1.15.5.tar.gz
tar -zxvf  nginx-1.15.5.tar.gz
cd nginx-1.15.5/
3:配制nginx
a:默认配置
   ./configure
b:自定义配置
  ./configure 
--prefix=/usr/local/nginx 
--conf-path=/usr/local/nginx/conf/nginx.conf 
--pid-path=/usr/local/nginx/conf/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_gzip_static_module 
--http-client-body-temp-path=/var/temp/nginx/client 
--http-proxy-temp-path=/var/temp/nginx/proxy 
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi 
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi 
--http-scgi-temp-path=/var/temp/nginx/scg
c:支持https
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf   --with-http_ssl_module
4:编译安装
make
make install
5、设置nginx开机并启动,添加到系统服务
 vi /etc/init.d/nginx
#!/bin/sh  
# chkconfig: 2345 85 15  
# Startup script for the nginx Web Server  
# description: nginx is a World Wide Web server.   
# It is used to serve HTML files and CGI.  
# processname: nginx  
# pidfile: /usr/local/nginx/logs/nginx.pid  
# config: /usr/local/nginx/conf/nginx.conf  
  
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin  
DESC="nginx deamon"  
NAME=nginx  
DAEMON=/usr/local/nginx/sbin/$NAME  
SCRIPTNAME=/etc/init.d/$NAME  
  
test -x $DAEMON || exit 0  
  
d_start(){  
  $DAEMON || echo -n "already running"  
}  
  
d_stop(){  
  $DAEMON -s quit || echo -n "not running"  
}  
  
  
d_reload(){  
  $DAEMON -s reload || echo -n "can not reload"  
}  
  
case "$1" in  
start)  
  echo -n "Starting $DESC: $NAME"  
  d_start  
  echo "."  
;;  
stop)  
  echo -n "Stopping $DESC: $NAME"  
  d_stop  
  echo "."  
;;  
reload)  
  echo -n "Reloading $DESC conf..."  
  d_reload  
  echo "reload ."  
;;  
restart)  
  echo -n "Restarting $DESC: $NAME"  
  d_stop  
  sleep 2  
  d_start  
  echo "."  
;;  
*)  
  echo "Usage: $ScRIPTNAME {start|stop|reload|restart}" >&2  
  exit 3  
;;  
esac  
  
exit 0 
6:添加开机启动并配制权限
# 给启动文件添加执行权限
 chmod +x /etc/init.d/nginx  
 
# 添加开机自动启动nginx服务
 chkconfig --add nginx 
 
# 修改服务启动设置
 chkconfig nginx on/off  
 
# 显示开机可以自动启动的服务
 chkconfig --list nginx  
nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
原文地址:https://www.cnblogs.com/feiyun126/p/5457524.html