ubuntu16.04 安装 nginx 服务器

摘要:
Nginx使用zlib来gzi http包的内容pwgethttp://www.openssl.org/source/openssl-1.0.2n.tar.gztar-zxvfopenssl-1.0.2n.tar.gz安装步骤1。安装源代码1。下载nginx压缩包wgethttps:

版本

  • ubunt16.04
  • nginx-1.8.1
  • gcc-4.8.4
  • pcre-8.38
  • zlib-1.2.11
  • openssl-1.0.2n

前置环境配置

进入到 /usr/local 目录下执行下面1 2 3 4,此处路劲与之后安装nginx对应,需要注意*

1、gcc

源码编译依赖环境

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

// gcc --version 查看gcc版本
// gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
2、PCRE ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure  
make  
make install 
3、zlib http://zlib.net

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

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 
4、penssl https://www.openssl.org/source/

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

wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz
tar -zxvf openssl-1.0.2n.tar.gz

安装步骤

一、源码安装

1.下载 nginx 压缩包
wget https://nginx.org/download/nginx-1.8.1.tar.gz

这里写图片描述

2.解压 nginx-1.8.1.tar.gz
tar -zxvf nginx-1.8.1.tar.gz

这里写图片描述

5.解压后 我们通过 cd 命令进入到nginx-1.8.1文件夹下面

安装nginx到 /usr/local/nginx目录下

cd nginx-1.8.1

// 配置nginx
./configure --sbin-path=/usr/local/nginx/nginx 
--conf-path=/usr/local/nginx/nginx.conf 
--pid-path=/usr/local/nginx/nginx.pid 
--with-http_ssl_module 
--with-pcre=/usr/local/pcre-8.38 
--with-zlib=/usr/local/zlib-1.2.11 
--with-openssl=/usr/local/openssl-1.0.2n
// 编译
make
// 安装
make install

至此nginx安装完成!

如果使用 nginx 访问 ftp 站点内容,需要将 nginx user设置为对应 ftp user 不然会因权限不足报 403 错误


6.启动nginx

建议使用第一种启动,否则可能会出现如下错误

nginx: [error] open() "/***/***/***/nginx.pid" failed (2: No such file or directory)

第一种

cd /usr/local/nginx

./nginx -c ./nginx.conf

第二种

/usr/local/nginx/nginx

这里写图片描述

重新加载配置

./nginx -s reload

二、在线安装

apt-get install nginx

启动程序文件在/usr/sbin/nginx

日志放在了/var/log/nginx中,分别是access.log和error.log

并已经在/etc/init.d/下创建了启动脚本nginx

在线安装启动nginx
/etc/init.d/nginx start

更多 nginx 学习 推荐 : http://www.nginx.cn

免责声明:文章转载自《ubuntu16.04 安装 nginx 服务器》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Burp Suite设置代理c++设计模式:装饰者模式(Decorator Pattern)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Nginx 泛域名解析配置

#默认配置 server{ } #泛域名解析 server { listen 80; server_name rs.ruanx.club; #要转发的地址.这里的rs可以使用通配符*代替,可匹配所有. location / { # 泛域名开始配置 proxy_pass http://172.16.0.15:...

Nginx的启动、停止与重启

启动启动代码格式:nginx安装目录地址 -c nginx配置文件地址 例如: [root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 停止nginx的停止有三种方式: 从容停止   1、查看进程号 [root@LinuxServe...

zlib的应用

主要分析应用的demo,有空再分析底层实现 官方demo位于zlib-1.2.11contribminizip 对官方代码的分析 /*miniunz.c Version 1.1, February 14h, 2010 sample part of the MiniZip project - ( http://www.winimage.com/...

NGINX 从入门到精通,学会这些就够了

https://learnku.com/articles/46237 工作这么多年一直用的都是 NGINX,也一直想写总结,不过之前都是在上班,下班后就比较懒了,所以一直搁置着,趁着现在离职了有时间,就想把之前欠下的都补上,也算是对自己近年来工作技能的总结,希望这篇文章能帮助到你。 什么是 nginxNginx(发音同 “engine X”)是异步框架的网...

学习 NGINX

At a high level, configuring NGINX Plus as a web server is a matter of defining which URLs it handles and how it processes HTTP requests for resources at those URLs. At a lower le...

nginx高并发优化

一、一般来说nginx 配置文件中对优化比较有作用的为以下几项: 1.  worker_processes 8; nginx 进程数,建议按照cpu 数目来指定,一般为它的倍数 (如,2个四核的cpu计为8)。 2.  worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 0...