Nginx 的安装, 环境是CentOS
2015-10-17 22:41
399 查看
nginx is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP proxy server.
官网地址为:http://nginx.org/en/
下面是在CentOS7上面安装Nginx步骤,供参考
环境准备
Nginx有几个依赖的包,分别是:
1). openssl, nginx的ssl功能需要此组件,实现一些安全方面的业务。
资源地址: http://www.openssl.org/
2). zlib, 提供相关数据压缩服务。
资源地址: http://www.zlib.net/
3). pcre, 提供Nginx请求拦截时的正则匹配功能。
介绍在此: http://www.pcre.org/
下载地址: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
最后是Nginx的源码安装文件,http://nginx.org/en/download.html
安装步骤
1) 安装openssl依赖
2) 安装zlib依赖
3) 安装pcre依赖
4) 最后就是安装主角,Nginx咯,关于nginx的编译安装,关于nginx的编译配置可以参考前面所给的官方地址里的介绍,这里只给出一个配置示例
5) 最后验证下Nginx是否安装成功,
6) 如果每次都进去Nginx的目录去启动或者重启,重载配置那也太麻烦了吧,那我们可以建立一个软连接,那也就可以在任意地方调用Nginx服务命令了啊
官网地址为:http://nginx.org/en/
下面是在CentOS7上面安装Nginx步骤,供参考
环境准备
Nginx有几个依赖的包,分别是:
1). openssl, nginx的ssl功能需要此组件,实现一些安全方面的业务。
资源地址: http://www.openssl.org/
2). zlib, 提供相关数据压缩服务。
资源地址: http://www.zlib.net/
3). pcre, 提供Nginx请求拦截时的正则匹配功能。
介绍在此: http://www.pcre.org/
下载地址: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
最后是Nginx的源码安装文件,http://nginx.org/en/download.html
安装步骤
1) 安装openssl依赖
[hinsteny@localhost nginx]$ tar -zxf openssl-1.0.2d.tar.gz [hinsteny@localhost openssl-1.0.2d]$ sudo ./config [hinsteny@localhost openssl-1.0.2d]$ sudo make [hinsteny@localhost openssl-1.0.2d]$ sudo make install
2) 安装zlib依赖
[hinsteny@localhost nginx]$ tar -xf zlib-1.2.8.tar.gz [hinsteny@localhost zlib-1.2.8]$ sudo ./configure [hinsteny@localhost zlib-1.2.8]$ sudo make [hinsteny@localhost zlib-1.2.8]$ sudo make install
3) 安装pcre依赖
[hinsteny@localhost nginx]$ tar -xzf pcre-8.37.tar.gz [hinsteny@localhost pcre-8.37]$ sudo ./configure [hinsteny@localhost pcre-8.37]$ sudo make [hinsteny@localhost pcre-8.37]$ sudo make install
4) 最后就是安装主角,Nginx咯,关于nginx的编译安装,关于nginx的编译配置可以参考前面所给的官方地址里的介绍,这里只给出一个配置示例
[hinsteny@localhost nginx]$ tar -xzf nginx-1.9.5.tar.gz [hinsteny@localhost nginx-1.9.5]$ sudo ./configure --with-http_ssl_module --with-openssl=../openssl-1.0.2d --with-pcre=../pcre-8.37 --with-zlib=../zlib-1.2.8 [hinsteny@localhost nginx-1.9.5]$ sudo make [hinsteny@localhost nginx-1.9.5]$ sudo make install
5) 最后验证下Nginx是否安装成功,
[hinsteny@localhost nginx-1.9.5]$ cd /usr/local/nginx/sbin/ [hinsteny@localhost sbin]$ sudo ./nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [hinsteny@localhost sbin]$ sudo ./nginx (启动Nginx) [hinsteny@localhost sbin]$ netstat -ntlp (查看端口) (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN - tcp6 0 0 :::22 :::* LISTEN - tcp6 0 0 ::1:631 :::* LISTEN - tcp6 0 0 ::1:25 :::* LISTEN -
6) 如果每次都进去Nginx的目录去启动或者重启,重载配置那也太麻烦了吧,那我们可以建立一个软连接,那也就可以在任意地方调用Nginx服务命令了啊
[hinsteny@localhost sbin]$ sudo ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx [hinsteny@localhost bin]$ sudo nginx -s reload (重启)
相关文章推荐
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- MySQL复制解决方案(Replication Solutions)
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Nginx 学习笔记(一)
- 网站502与504错误分析
- 艰难完成 nginx + puma 部署 rails 4的详细记录
- 把Lua编译进nginx步骤方法
- web 应用中常用的各种 cache详解
- Linux系统上配置Nginx+Ruby on Rails+MySQL超攻略
- window+nginx+php环境配置 附配置搭配说明
- Apache SSL服务器配置SSL详解
- 配置apache默认使用ssl的方法