【Ubuntu 16】安装nginx

近年来,nginx服务器程序由于负载均衡、反向代理、适于高并发的特性,获得越来越多互联网企业的青睐。在此为大家奉上nginx的安装过程,以供参考。

一、安装nginx

1.安装gcc\g++库

sudo apt-get install build-essential
sudo apt-get install libtool

2.安装prce库

sudo apt-get install libpcre3 libpcre3-dev

3.安装zlib依赖库

sudo apt-get install zlib1g-dev

4.安装ssl依赖库

sudo apt-get install openssl

5.切换到普通用户dream361

dream361@ubuntu:~$ pwd
/home/dream361/

6.解压nginx源码包

dream361@ubuntu:~$ tar xvf Downloads/nginx-1.10.3.tar.gz 

7.进入到nginx目录

dream361@ubuntu:~$ ./configure --prefix=/usr/local/nginx

8. #编译 make  # 安装 sudo make  install #

9.启动nginx

sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

二、nginx常用命令

启动

sudo /usr/local/nginx/sbin/nginx

停止

sudo /usr/local/nginx/sbin/nginx -s stop

重新加载

sudo /usr/local/nginx/sbin/nginx -s reload

指定配置文件

sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

查看版本

dream361@ubuntu:~$ /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.10.3

检查配置文件是否正确

dream361@ubuntu:~$ sudo /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

显示帮助信息

dream361@ubuntu:~$ /usr/local/nginx/sbin/nginx -h
nginx version: nginx/1.10.3
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/nginx/)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file



















 









 

 

转载于:https://www.cnblogs.com/zhengwenqiang/p/6804623.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值