nginx1.14.0下载及安装nginx
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
./configure --prefix=/home/program/nginx //安装到此目录,默认安装目录为:/usr/local/nginx,这里的安装目录是个隐藏目录,安装完成以后是看不见的!默认路径便可以!浏览器
./configure
make & make install安全
启动单个nginx服务器
cd /usr/local/nginx/sbin
./nginx 启动nginx,经常使用方法。后面带上-c参数的,是指定nginx.conf文件ui
./nginx -c /usr/local/nginx/conf/nginx.conf //启动nginx -c表示指定nginx.conf的文件。若是不指定,默认为NGINX_HOME/conf/nginx.confspa
./nginx -h //得到帮助blog
验证启动成功:进程
在浏览器里输入IP,默认端口号为80,能够不用输入,若是是跨主机访问,需关闭nginx所在服务器的防火墙:get
./nginx -t 验证nginx.conf 文件配置是否正确:it
中止nginx
cd /usr/local/nginx/sbin
./nginx -s stop 中止
./nginx -s quit 退出
./nginx -s reload 从新启动,加载nginx.conf。只有nginx进程已存在的状况下才能够用reload。
第二种方式中止(推荐):
ps -ef|grep nginx 查询nginx进程
kill -QUIT 进程号 进程请求处理完成后中止进程,比较安全的中止方式
kil -TERM 进程号 这个跟kill -9 同样,当即中止进程