码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx(二):Nginx基本安装

时间:2019-09-10 14:43:07      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:show   color   cal   expr   eve   zip   证书   ssi   准备   

基于Windows安装

 

 

 

基于Linux安装

环境准备

  • CentOS7  
  • Nginx1.9
  • gcc gcc-c++
  • PCRE库
  • OpenSSL库
  • zlib库

基本安装

1.安装gcc gcc-c++

安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境

$ yum install -y gcc gcc-c++

2.安装wget(如未安装,请先安装)

$ yum -y install wget

3.安装PCRE库

PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。

$ cd /usr/local/
$ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
$ tar -zxvf pcre-8.33.tar.gz
$ cd pcre-8.33
$ ./configure
$ make && make install

4.安装OpenSSL库

OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http)

$ cd /usr/local/
$ wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
$ tar -zxvf openssl-1.0.1j.tar.gz
$ cd openssl-1.0.1j
$ ./config
$ make && make install

5.安装zlib库

zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip

$ cd /usr/local/
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxvf zlib-1.2.11.tar.gz
$ cd zlib-1.2.11
$ ./configure
$ make && make install

6.安装nginx

$ cd /usr/local/
$ wget http://nginx.org/download/nginx-1.9.0.tar.gz
$ tar -zxvf nginx-1.9.0.tar.gz
$ cd nginx-1.9.0 
$ ./configure
$ make && make install

7.检测是否安装成功

$ cd  /usr/local/nginx/sbin
$ ./nginx -t

Nginx常用命令

1.显示帮助信息

$ /usr/local/nginx/sbin/nginx -h

帮助信息如下:

Options:
  -?,-h         : this help  (显示帮助信息)
  -v            : show version and exit  (打印nginx版本,编译信息等)
  -V            : show version and configure options then exit  (打印nginx版本,编译信息等)
  -t            : test configuration and exit  (检测语法)
  -q            : suppress non-error messages during configuration testing
#发送信号(立刻停止stop、优雅停止quit、重载配置文件reload、重新开始记日志reopen)
-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

2.启动nginx

$ /usr/local/nginx/sbin/nginx

3.查看进程

$ ps -aux | grep nginx

 4.停止 Nginx

$ /usr/local/nginx/sbin/nginx -s quit    #发送信号方式 优雅停止quit$ /usr/local/nginx/sbin/nginx -s stop    #发送信号方式 立刻停止stop

5.Nginx 重载配置

$ /usr/local/nginx/sbin/nginx -s reload  #发送信号方式 立刻停止stop

 

 

Nginx(二):Nginx基本安装

标签:show   color   cal   expr   eve   zip   证书   ssi   准备   

原文地址:https://www.cnblogs.com/kongliuyi/p/11494746.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!