Nginx编译安装
来源:互联网 发布:淘宝卖家插件哪个好 编辑:程序博客网 时间:2024/06/17 13:23
1. 下载Nginx, 从官网 http://nginx.org/en/download.html , 我下载的版本为, nginx-1.12.1.tar.gz
2. 解压 tar -zxvf nginx-1.12.1.tar.gz
3. 进入解压目录, 执行./configure 是Nginx的重要组成部件,它检查各种系统参数、命令行参数和依赖库,根据这些参数生成定制的Makefile和一些c源码文件. 我们可通过指定参数将nginx安装到指令目录下,我们现在通过—prefix=/opt/nginx, 将nginx安装到/opt/nginx目录下:
./configure --prefix=/opt/nginx
4. 在执行过程中我这里出现了一个错误:
re: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre=<path> option.
原因就是缺少PCRE依赖库, 我们只需要安装依赖库即可.
sudo apt-get install libpcre3 libpcre3-dev
PCRE是何物:
PCRE(PerlCompatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。这些在执行正规表达式模式匹配时用与Perl 5同样的语法和语义是很有用的。Boost太庞大了,使用boost regex后,程序的编译速度明显变慢。测试了一下,同样一个程序,使用boost::regex编译时需要3秒,而使用pcre不到1秒。因此改用pcre来解决C语言中使用正则表达式的问题。PCRE被广泛使用在许多开源软件之中,最著名的莫过于Apache HTTP服务器和PHP脚本语言、R脚本语言,此外,正如从其名字所能看到的,PCRE也是perl语言的缺省正则库。PCRE是用C语言实现的,其C++实现版本是PCRE++。
5. 再次执行命令:
./configure --prefix=/opt/nginx配置汇总信息为:
Configuration summary
+ using system PCRE library
+ OpenSSLlibrary is not used
+ using system zlib library
nginx path prefix:"/opt/nginx"
nginx binary file:"/opt/nginx/sbin/nginx"
nginx modules path:"/opt/nginx/modules"
nginx configuration prefix:"/opt/nginx/conf"
nginx configuration file:"/opt/nginx/conf/nginx.conf"
nginx pid file:"/opt/nginx/logs/nginx.pid"
nginx error log file:"/opt/nginx/logs/error.log"
nginx http access log file:"/opt/nginx/logs/access.log"
nginx http client request bodytemporary files:"client_body_temp"
nginx http proxy temporary files:"proxy_temp"
nginx http fastcgi temporary files:"fastcgi_temp"
nginx http uwsgi temporary files:"uwsgi_temp"
nginxhttp scgi temporary files:"scgi_temp"这个暂时不影响我们使用,但是我们还是配置上, 从官网下载 https://www.openssl.org/source/, 将其解压至/usr/local/lib目录下:
./configure --prefix=/opt/nginx --with-openssl=/usr/local/lib/openssl-1.0.2l
增加--with-openssl指定下载的openssl的解压目录即可.再次配置输出汇总信息如下:
Configuration summary
+ using system PCRE library
+ usingOpenSSL library: /usr/local/lib/openssl-1.0.2l
+ using system zlib library
nginx path prefix: "/opt/nginx"
nginx binary file: "/opt/nginx/sbin/nginx"
nginx modules path: "/opt/nginx/modules"
nginx configuration prefix: "/opt/nginx/conf"
nginx configuration file: "/opt/nginx/conf/nginx.conf"
nginx pid file: "/opt/nginx/logs/nginx.pid"
nginx error log file: "/opt/nginx/logs/error.log"
nginx http access log file: "/opt/nginx/logs/access.log"
nginx http client request bodytemporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginxhttp scgi temporary files: "scgi_temp"配置之后目录为, 多了一个objs目录,并且Makefile文件.
补充ssl为何物:
SSL是Secure Sockets Layer(安全套接层协议)的缩写,可以在Internet上提供秘密性传输。Netscape公司在推出第一个Web浏览器的同时,提出了SSL协议标准。其目标是保证两个应用间通信的保密性和可靠性,可在服务器端和用户端同时实现支持。已经成为Internet上保密通讯的工业标准。
Eric A. Young和Tim J. Hudson自1995年开始编写后来具有巨大影响的OpenSSL软件包,这是一个没有太多限制的开放源代码的软件包。Eric A. Young 和Tim J. Hudson是加拿大人,后来由于写OpenSSL功成名就之后就到大公司里赚大钱去了。1998年,OpenSSL项目组接管了OpenSSL的开发工作,并推出了OpenSSL的0.9.1版,到目前为止,OpenSSL的算法已经非常完善,对SSL2.0、SSL3.0以及TLS1.0都支持。
OpenSSL采用C语言作为开发语言,这使得OpenSSL具有优秀的跨平台性能,这对于广大技术人员来说是一件非常美妙的事情,可以在不同的平台使用同样熟悉的东西。OpenSSL支持Linux、Windows、BSD、Mac、VMS等平台,这使得OpenSSL具有广泛的适用性。6. 编译安装
makemake install
sudo /opt/nginx/sbin/nginx查看nginx是否启动
ps -aux | grep nginx
nginx启动一个master继承,一个worker进程。master进程主要来管理worker进程,监视worker进程的工作状态.
8. 打开浏览器输入 localhost
9. 安装完毕!
- 编译安装nginx [Ubuntu]
- ubuntu 编译安装nginx
- 手工编译安装nginx
- nginx编译安装
- 编译安装nginx
- CentOS6编译安装Nginx
- 编译安装Nginx
- nginx 编译安装
- mac编译安装nginx
- Nginx的编译安装
- 编译安装nginx
- nginx---编译安装
- 编译安装Nginx
- NGINX编译安装
- Nginx编译安装
- ubuntu 编译安装 nginx
- 编译安装Nginx
- Nginx + php 编译安装
- 7-26 单词长度(15 分)
- CentOS7之常用服务
- jQuery学习入门(一)
- python decorator
- Object-C的编译命令
- Nginx编译安装
- hdfs——hadoop文件读写操作
- 在共享内存实现 Redis(上)
- HDU 5783 Divide the Sequence——贪心
- shiro中的请求参数
- android UiAutomator生成测试报告的基本方法封装
- BZOJ4538 网络 [树链剖分]
- Powershell原生支持的cURL
- java基础——java api各包概述