1.yum安装nginx

  1. 下载对应当前系统版本的nginx包(package)

    # wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

  2. 建立nginx的yum仓库

    # rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

  3. 下载并安装nginx

    # yum install nginx

  4.  

    启动nginx服务

    systemctl start nginx

  5.  

    配置

    默认的配置文件在 /etc/nginx 路径下,使用该配置已经可以正确地运行nginx;如需要自定义,修改其下的 nginx.conf或者conf.d/下的conf文件

  6.  

2.安装uwsgi

yum install python-devel
pip install uwsgi

3.nginx 配置https

一、生成私钥和证书

创建带密钥口令的私钥
root@mysqlmaster:/tmp# openssl genrsa -des3 -out ng.key 1024
Generating RSA private key, 1024 bit long modulus
........++++++
...........................................++++++
e is 65537 (0x10001)
Enter pass phrase for ng.key: 输入口令
Verifying - Enter pass phrase for ng.key: 确认口令
二、创建csr文件
root@mysqlmaster:/tmp# openssl req -new -key ng.key -out ng.csr
Enter pass phrase for ng.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:国家 如cn,hk
State or Province Name (full name) [Some-State]:州或省的名称 如Beijing
Locality Name (eg, city) []:什么地方级别,是城市还是乡镇
Organization Name (eg, company) [Internet Widgits Pty Ltd]:什么组织,如公司,政府
Organizational Unit Name (eg, section) []:组织单位名称
Common Name (eg, YOUR name) []:名字
Email Address []:邮件地址

Please enter the following 'extra' attributes 额外信息
to be sent with your certificate request
A challenge password []: 复杂密码
An optional company name []:

1,创建私钥(去除密钥口令)
openssl rsa -in ng.key -out server.key
输入口令

2,创建CA证书
openssl req -new -x509 -days 3650 -key server.key -out server.crt
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
Email Address []:
和上面的步骤差不多,根据提示输入证书的信息,国家,管理人邮件,姓名,城市等

将生成的证书放到/etc/nginx/conf.d/目录下,

root@mysqlmaster:/tmp# cp server.crt server.key /etc/nginx/conf.d

三、修改nginx配置文件

vi /etc/nginx/nginx/conf.d/default.conf


#let http  to https
server{
listen 80;
server_name localhost;
return 301 https://$server_addr$request_uri;
}
#https server
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /etc/nginx/conf.d/server.crt;
ssl_certificate_key /etc/nginx/conf.d/server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /xspeeder/xweb/xapp/templates/login;
index login.html;
uwsgi_pass 127.0.0.1:9000;
include uwsgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|ico|woff|ttf)$ {
root /xspeeder/xweb;
}
}

注意以上为nginx的配置文件,分为三部分,每一个server函数为一个部分,第一部分为http的配置,第二部分为https的部分,第三个部分是将http重写到https,也就是所有的走80端口的都强制他都443端口去。

sed -i "/listen 80;/{n;s/.*/        server_name 172.17.1.129;/g}" /etc/nginx/conf.d/default.conf

重写匹配

重启nginx 即可访问。

uwsgi --socket 127.0.0.1:9000 --chdir /xspeeder/xweb/ --wsgi-file xweb/wsgi.py --master --processes 2 --threads 2

centos7 nginx配置httpsCenos(6.6/7.1)下从源码安装Python+Django+uwsgi+nginx环境部署(二)的更多相关文章

  1. Cenos(6.6/7.1)下从源码安装Python+Django+uwsgi+nginx到写nginx的环境部署(一)

    梳理下这几个的关系: centos是redhat的社区版操作系统. Python2.7.5是开发语言(centos6.5下自带的python是2.6.6版本,所以需要源码更新,而centos7.1下面 ...

  2. python django uwsgi nginx安装

    python django uwsgi nginx安装 已安装完成python/django的情况下安装 pip install uwsgi cd /usr/share/nginx/html/ vim ...

  3. 源码安装python +NGINX 的坎坷路 +uwsgi安装 部署django 的CRM项目

    一.Nginx安装(基于ubuntu17.10 版本) 首先我们是基于源码安装,主要有如下步骤 1.安装依赖包 1.安装gcc g++的依赖库 sudo apt-get install build-e ...

  4. Python+django+uWSGI+Nginx

    Python3.5+Django+uWSGI 安装Django pip3.5 install django 安装 uWSGI pip install uwsgi 新建 django_wsgi.py # ...

  5. CentOS7.3环境下源码安装httpd

    CentOS7.3环境下源码安装httpd 本文在CentOS7.3下,源码安装apache服务httpd2.4. 1.下载好源码安装包 [root@localhost ~]#ll total 625 ...

  6. nginx源码安装教程(CentOS)

    1.说明 官方源码安装说明:http://nginx.org/en/docs/configure.html 源码包下载地址:http://nginx.org/en/download.html 版本说明 ...

  7. 源码安装nginx 方法二

    yum 仓库不能用大写字母 [root@oldboy conf.d]# gzip * 压缩当前目录下的所有文件 gzip ./* gzip . gzip./ # 关闭防火墙和selinux [root ...

  8. nginx在Centos7.5下源码安装和配置

    安装nginx 安装nginx依赖包 yum install -y pcre-devel zlib-devel openssl-devel wget gcc tree vim 进入目录/root/se ...

  9. centos7 中源码安装nginx

    使用nginx有一段时间了,还是有很多东西不懂的,在这里做一下自己学习过程中的一些整理,能使自己得到提升. 1.环境:centos7 1511  最小化安装 2.下载nginx,可以在系统中下载,也可 ...

随机推荐

  1. 使用Sublime Text 直接运行Quick-cocos2d-x 项目

    一.新建一个编译系统 { "cmd": "D:/WorkSoftWare/Quick/quick-cocos2d-x-3.3rc0/quick/samples/Runni ...

  2. JavaAnnotation和反射简化开发

    Part I 我并不是在卖弄自己的英语有多少的了不起,只不过对Annotation这一次的解释真的很懊恼,“注解”和“注释”这两个对Annotation的翻译我听着不爽,所以全文都用Annotatio ...

  3. php的字符串处理函数

    Strpos($str,”img”); //返回字符串的位置 Substr($str,int start,int length); 使用这两个函数可以截取字符串

  4. 用Scala实现集合中相邻元素间的差值

    欢迎转载,转载请注明出处,徽沪一郎. 概要 代码这东西,不写肯定不行,新学Scala不久,将实际遇到的一些问题记录下来,日后也好查找. 今天讲的是如何计算同一集合中元素两两之间的差值,即求开始集合(a ...

  5. MVC Pager 使用

    MVC Pager  4.0+     3.0版本使用  ,直接来点使用的.一看就明白 @Ajax.Pager(Model,pagerOptions,mvcAjaxOptions); @using W ...

  6. Java学习-044-文件拷贝

    不用说了,又是一个经常用到的方法,直接上码了...敬请各位小主参阅!若有不足,敬请指正,非常感谢! 文件拷贝源码: /** * <strong>文件拷贝</strong>< ...

  7. ios数据库SQLite实现

    SQLite嵌入式数据库 1.支持时间,不需要配置,不需要安装,不需要管理员; 2.支持大部分SQL92; 3.完整的数据库保存在磁盘上面的一个文件,同一个数据库文件可以在不同机器上面使用.最大支持数 ...

  8. Diablo2 1.13版&PlugY10.00 男巫存档

    下载地址: http://files.cnblogs.com/files/xiandedanteng/20160805D2113NanwuL83Backup.rar 解压后文件放到Diablo2游戏的 ...

  9. Spring 源码从github导入源码到idea2016

    步骤 安装git或者github客户端 java环境JDK安装(必须是1.8) gradle下载安装(选择的最新版3.1) git clone github上spring源码 import导入proj ...

  10. 配置安卓运行环境/安卓sdk

    收藏一个网站 http://www.php100.com/html/webkaifa/Android/de_news/2013/0221/12082.html