温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Linux下nginx编译安装教程

发布时间:2021-08-26 20:15:33 来源:亿速云 阅读:108 作者:chen 栏目:建站服务器

本篇内容介绍了“Linux下nginx编译安装教程”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

一、必要软件准备
1.安装pcre

为了支持rewrite功能,我们需要安装pcre
复制代码 代码如下:# yum install pcre* //如过你已经装了,请跳过这一步

2.安装openssl

需要ssl的支持,如果不需要ssl支持,请跳过这一步
复制代码 代码如下:# yum install openssl*

3.gzip 类库安装

复制代码 代码如下:yum install zlib zlib-devel

4.安装wget

下载nginx使用,如果已经安装,跳过这一步
复制代码 代码如下:# yum install wget

二、安装nginx

1.下载
复制代码 代码如下:wget  http://nginx.org/download/nginx-1.7.0.tar.gz
2.解压
复制代码 代码如下:
tar -zxvf nginx-1.7.0.tar.gz

3.编译和安装
执行如下命令:
复制代码 代码如下:

cd nginx-1.7.0

./configure --prefix=/usr/local/nginx-1.7.0 \

–with-http_ssl_module --with-http_spdy_module 
–with-http_stub_status_module --with-pcre
–with-http_stub_status_module:支持nginx状态查询
–with-http_ssl_module:支持https
–with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
–with-pcre:为了支持rewrite重写功能,必须制定pcre

最后输出如下内容,表示configure OK了。

复制代码 代码如下:
checking for zlib library … found
creating objs/Makefile
Configuration summary

  • using system PCRE library

  • using system OpenSSL library

  • md5: using OpenSSL library

  • sha1: using OpenSSL library

  • using system zlib library
    nginx path prefix: “/usr/local/nginx-1.7.0”
    nginx binary file: “/usr/local/nginx-1.7.0/sbin/nginx”
    nginx configuration prefix: “/usr/local/nginx-1.7.0/conf”
    nginx configuration file: “/usr/local/nginx-1.7.0/conf/nginx.conf”
    nginx pid file: “/usr/local/nginx-1.7.0/logs/nginx.pid”
    nginx error log file: “/usr/local/nginx-1.7.0/logs/error.log”
    nginx http access log file: “/usr/local/nginx-1.7.0/logs/access.log”
    nginx http client request body temporary 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”
    nginx http scgi temporary files: “scgi_temp”

make //确定你的服务器有安装make,如果没有安装请执行yum install make

make install

三、启动、关闭、重置nginx

启动:直接执行以下命令,nginx就启动了,不需要改任何配置文件,nginx配置多域名虚拟主机请参考后续文章.
复制代码 代码如下:/usr/local/nginx-1.7.0/sbin/nginx
试试访问:直接使用curl命令来读取web信息
复制代码 代码如下:
[root@ns conf]

curl -s  http://localhost  | grep  nginx.com

nginx.com .
关闭:
复制代码 代码如下:/usr/local/nginx-1.7.0/sbin/nginx -s stop

“Linux下nginx编译安装教程”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI