centos的nginx+https配置
2016-02-27 14:16
726 查看
1. 在已经安装了nginx下,通过/usr/local/nginx/sbin/nginx -V 来查看编译nginx时候的参数,看是否存在“
--with-http_ssl_module ”参数,该参数是启动nginx的ssl模块,如果不存在,就需要重新编译nginx了
2.如果需要重新编译的话,新解压nginx安装包,进入nginx安装文件夹,复制上一步查看到的配置参数项,并且加上--with-http_ssl_module(如果原先的参数中存在了“ --with-openssl “参数,需要先去除,否则make编译不通过),然后make 重新编译,到此就结束了,不需要mak install 命令安装, 在重新编译后,会在nginx安装文件夹中产生一个叫”objs“的文件夹,编译的nginx执行文件就在该目录中,
将新的执行文件替换掉之前的nginx安装目录的旧执行文件
命令如下:
./configure --user=root --group=root --prefix=/usr/local/nginx --with-http_stub_status_module
--with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.30 --with-zlib=/usr/local/src/zlib-1.2.3
make
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_bak # 备份旧的nginx
cp /usr/local/src/[b]nginx-1.7.9/objs/nginx /usr/local/nginx/sbin/nginx #替换旧的nginx[/b]
/usr/local/nginx/sbin/nginx -s stop #关闭nginx
[b]/usr/local/nginx/sbin/nginx #重启新的nginx[/b]
[b]3. 生成证书[/b]
[b] 进入到nginx的conf目录中,执行以下命令:[/b]
[b] openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr #其中需要填写的数据,可参看网上资料
openssl rsa -in server.key -out server_nopwd.key
openssl x509 -req -days 365 -in server.csr -signkey server_nopwd.key -out server.crt[/b]
[b]4. 配置对应的host文件[/b]
[b] vim /usr/local/nginx/conf/vhosts/redis.conf [/b]
[b]
[/b]
重启nginx :
/usr/local/nginx/sbin/nginx -t #检查配置文件是否正确,如果提示“[emerg] 10464#0: unknown directive "ssl" in /usr/local/nginx-0.6.32/conf/nginx.conf:74”则说明没有刚刚没有将ssl模块编译进nginx
!!
/usr/local/nginx/sbin/nginx -s reload
5.开启防火墙的443端口(https对应的是443)
vim /etc/sysconfig/iptables #打开防火墙文件,在里面添加端口:-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT,让后保存!!
service iptables stop
service iptables start #重启防火墙,让443生效
[b][b][/b][/b]
[b][b] [/b][/b]
[b][b] [/b][/b]
[b][b] [/b][/b]
--with-http_ssl_module ”参数,该参数是启动nginx的ssl模块,如果不存在,就需要重新编译nginx了
2.如果需要重新编译的话,新解压nginx安装包,进入nginx安装文件夹,复制上一步查看到的配置参数项,并且加上--with-http_ssl_module(如果原先的参数中存在了“ --with-openssl “参数,需要先去除,否则make编译不通过),然后make 重新编译,到此就结束了,不需要mak install 命令安装, 在重新编译后,会在nginx安装文件夹中产生一个叫”objs“的文件夹,编译的nginx执行文件就在该目录中,
将新的执行文件替换掉之前的nginx安装目录的旧执行文件
命令如下:
./configure --user=root --group=root --prefix=/usr/local/nginx --with-http_stub_status_module
--with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.30 --with-zlib=/usr/local/src/zlib-1.2.3
make
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_bak # 备份旧的nginx
cp /usr/local/src/[b]nginx-1.7.9/objs/nginx /usr/local/nginx/sbin/nginx #替换旧的nginx[/b]
/usr/local/nginx/sbin/nginx -s stop #关闭nginx
[b]/usr/local/nginx/sbin/nginx #重启新的nginx[/b]
[b]3. 生成证书[/b]
[b] 进入到nginx的conf目录中,执行以下命令:[/b]
[b] openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr #其中需要填写的数据,可参看网上资料
openssl rsa -in server.key -out server_nopwd.key
openssl x509 -req -days 365 -in server.csr -signkey server_nopwd.key -out server.crt[/b]
[b]4. 配置对应的host文件[/b]
[b] vim /usr/local/nginx/conf/vhosts/redis.conf [/b]
[b]
[/b]
重启nginx :
/usr/local/nginx/sbin/nginx -t #检查配置文件是否正确,如果提示“[emerg] 10464#0: unknown directive "ssl" in /usr/local/nginx-0.6.32/conf/nginx.conf:74”则说明没有刚刚没有将ssl模块编译进nginx
!!
/usr/local/nginx/sbin/nginx -s reload
5.开启防火墙的443端口(https对应的是443)
vim /etc/sysconfig/iptables #打开防火墙文件,在里面添加端口:-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT,让后保存!!
service iptables stop
service iptables start #重启防火墙,让443生效
[b][b][/b][/b]
[b][b] [/b][/b]
[b][b] [/b][/b]
[b][b] [/b][/b]
相关文章推荐
- 神经网络分类
- Wireshark基本介绍和学习TCP三次握手
- httpclient以post方式发送body
- 如何查看自己电脑的IP和网络运营商
- [神经网络]2.1-How the backpropagation algorithm works-Warm up: a fast matrix-based approach ...(翻译)
- 自己写的一个简单的BP神经网络代码
- 安装andriod studio时出现Internal error. Please report to https://code.google.com/p/an
- okHttp的用法
- 使用windows2003多台服务器网络负载平衡注意事项
- 【高性能】Extreme交换机从头到尾配置
- 业绩暴涨200%的4大策略,店长必学
- 网络流(最大流):POJ 1149 PIGS
- vm克隆linux系统 后连接网络
- HttpClient 和 HttpUrlConnection 区别
- 【网络基本功系列四】细说交换机细说路由(上)
- 网络流(最小费用最大流):POJ 2135 Farm Tour
- Vmvare 10 中安装centos7 出现 没有可用的网络设备
- 网络的四层架构与网站的数据库的用户信息表的设计
- 【bzoj2502】清理雪道 有上下界的网络流
- flume 读取tcp写到hdfs