下载和安装Nginx

在安装Nginx服务器之前必须先安装一些库和工具

编译工具GCC 基本上系统已自带

PCRE库:Nginx Rewitre模块和HTTP核心模块会用到PRCE正则表达式语法,需要安装该库

安装该库,需要安装两个pcre:提供编译版本的库  pcre-devel:开发者使用的头文件等源代码

Ubuntu下 apt-get install libpcre3 libpcre3-dev

Zilb 库:提供了开发人员的压缩算法,在Nginx的各种模块中需要使用gzip压缩。

zlib zlib-devel  库和他的源文件

OpenSSL:传输层安全协议

openssl openssl-dev


开始下载Nginx源码

在官网下载下来的源代码解压后

./configure 确定系统的环境,检测所需必要环境

make 开始编译源代码

make install 复制编译后的文件到安装目录 默认下是/usr/local/nginx  


具体的./configure 加上选项可以配置安装路径、配置文件路径、日志路径各种路径

另外在所需的库文件或二进制文件(如GCC)没有按标准路径安装时,可以在./configure告诉他这些东西的位置

模块选项,在编译之前确定需要的模块


./configure会生成一个Makefile,make会编译,如果出错一般需要对前面的配置重新配置


make install会执行Makefile的安装部分,基本不会出错,可能的话是存储空间不够


安装后Nginx的各种配置查看 nginx -V

regulus@ubuntu:~$ nginx -V
nginx version: nginx/1.4.6 (Ubuntu)
built by gcc 4.8.2 (Ubuntu 4.8.2-16ubuntu6) 
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module

--prefix==/usr/share/nginx 指定安装nginx的基础目录

--sbin-path== nginx二进制文件安装的路径


 nginx -V==sbinpath/nginx -V 使用绝对路径


nginx -h

nginx version: nginx/1.4.6 (Ubuntu)
Usage: nginx [-?hvVtq] [-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
  -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/share/nginx/)
  -c filename   : set configuration file (default: /etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file


启动nginx

直接在命令行nginx


添加nginx作为系统服务,让nginx以系统服务的形式启动,在系统启动时自动启动

init脚本是一个启动服务的脚本


如果nginx是一个服务我们可以使用service nginx start命令或者/etc/init.d/nginx start命令来启动和停止服务

那么首先就是的先有关于这个服务的init脚本,即在/etc/initl.d中存在nginx文件,这个文件就是带有启动参数的脚本,init进程将会运行这个脚本




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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值