网站部署nginx--uwsgi
网站代码写完之后就是项目部署,主要包括两个方面:
1.nginx安装与配置:
1、Nginx 安装
系统平台:CentOS release 6.6 (Final) 64位。
一、安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
二、首先要安装 PCRE
PCRE 作用是让 Nginx 支持 Rewrite 功能。
1、下载 PCRE 安装包,下载地址: http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
[root@bogon src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
2、解压安装包:
[root@bogon src]# tar zxvf pcre-8.35.tar.gz
3、进入安装包目录
[root@bogon src]# cd pcre-8.35
4、编译安装
[root@bogon pcre-8.35]# ./configure [root@bogon pcre-8.35]# make && make install
5、查看pcre版本
[root@bogon pcre-8.35]# pcre-config --version
安装 Nginx
1、下载 Nginx,下载地址:http://nginx.org/download/nginx-1.6.2.tar.gz
[root@bogon src]# wget http://nginx.org/download/nginx-1.6.2.tar.gz
2、解压安装包
[root@bogon src]# tar zxvf nginx-1.6.2.tar.gz
3、进入安装包目录
[root@bogon src]# cd nginx-1.6.2
4、编译安装
[root@bogon nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35 [root@bogon nginx-1.6.2]# make [root@bogon nginx-1.6.2]# make install
5、查看nginx版本
[root@bogon nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -v
到此,nginx安装完成。
2.nginx配置:
首先,进入文件 cd /usr/local/nginx/conf/nginx.conf 编辑带入如下:
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 80;server_name www.itcast.cn;#charset koi8-r;#access_log logs/host.access.log main;# location / {
# root html;
# index index.html index.htm;
# }
#根目录,注意html文件location / {root /var/www/ihome/static/html;index index.html;}
#uwsgi配置iplocation /api {uwsgi_pass 127.0.0.1:5000;include uwsgi_params;}
#静态文件配置,静态文件需要迁移到此文件下location /static {alias /var/www/ihome/static;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}}
注:需要拷贝static文件 :cp -r static /var/www/ihome/static
配置好uwsgi后启动nginx:sudo sbin/nginx
如需停止:sudo sbin/nginx -s stop
2.uwsgi文件创建与配置
1.进入虚拟环境:workon 虚拟环境名称
2.创建文件:touch uwsgi.ini
3.编辑文件:
[uwsgi]
#按照实际情况改动,这里只是举例
# uwsgi 启动时所使用的地址与端口
socket = 127.0.0.1:8001pidfile = uwsgi.pid
daemonize = uwsgi.log
# 指向网站目录
chdir = /home/python/Desktop/ihome/test4# python 启动程序文件
wsgi-file = test4.py# python 程序内用以启动的 application 变量名
callable = app# 处理器数
processes = 4# 线程数
threads = 2#每次修改代码自动reload,无需要手动重启
#py-autoreload = 1#状态检测地址
stats = 127.0.0.1:9001
4.启动uwsgi: uwsgi --ini uwsgi.ini
5.启动nginx
如需关闭uwsgi: uwsgi --stop uwsgi.pid
网站部署nginx--uwsgi相关推荐
- Centos 6.5部署nginx+uwsgi+django
Centos 6.5部署nginx+uwsgi+django 一.安装python3,系统默认是python2.6 1.安装依赖软件 yum -y install sqlite-devel yum - ...
- Django之部署NGINX+uWSGI
参考地址:http://www.cnblogs.com/CongZhang/p/6548529.html http://www.cnblogs.com/alex3714/p/6538374.html ...
- Ubuntu16.04下部署 nginx+uwsgi+django1.9.7(虚拟环境pyenv+virtualenv)
由于用的新版本系统,和旧的稍有差别,在网上搜了很多相关资料,搞了三天终于搞好在Ubuntu16.04下的部署,接下来就详细写写步骤以及其中遇到的问题.前提是安装有虚拟环境pyenv+virtualen ...
- Django 部署(Nginx+uwsgi)
使用 uwsgi 来部署 安装 uwsgi sudo pip install uwsgi --upgrade 使用 uwsgi 运行项目 uwsgi --http :8001 --chdir /pat ...
- Nginx + uWSGI + Python + Django部署实例
Nginx: Nginx 是一个高性能的 Web 和反向代理服务器, 它具有有很多非常优越的特性: 作为 Web 服务器:相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的 ...
- nginx+uWSGI + django部署项目
项目部署 nginx+uWSGI + django 1. WSGI WSGI是Web服务器网关接口.它是一个规范,描述了Web服务器(返回静态资源的就是web服务器,Nginx)如何与Web应用程序( ...
- Django+nginx+uwsgi+ubuntu18.04网站部署
Django网站的部署 原理 凡事都要讲个原理嘛.如图所示,就是整个原理啦.详细可以观看哔哩哔哩up主讲的真不错呀!!! 网站用户 网站服务器 socket uwsgi Django 图片来源于(ht ...
- 【转】Nginx+uWSGI 部署 Django 应用
原文来自: http://www.oschina.net/question/54100_30386 http://obmem.info/?p=703 常见的django webapp 部署方式采用FC ...
- nginx+uwsgi部署Django
本篇文章主要介绍了解决nginx+uwsgi部署Django的所有问题(小结),小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟随小编过来看看吧 最近,自己暑假写的小项目也算完毕了,想着投放 ...
- [转]Docker部署Django由浅入深系列(下): 八步部署Django+Uwsgi+Nginx+MySQL+Redis
在上篇教程中,我们手动构建了两个容器,一个容器放Django + Uwsgi,另一个容器放Nginx,成功部署了一个简单的Django项目.然而在实际的生产环境中,我们往往需要定义数量庞大的 dock ...
最新文章
- HDU-1299 Diophantus of Alexandria 素因子分解
- vue动态设置文字布局方式_详解Vue动态添加模板的几种方法
- NOIP2017TG D1T2 时间复杂度
- lr中winsock协议的脚本(转载51testing)
- python数据处理常用函数_pytorch中的自定义数据处理详解
- [Redux/Mobx] Context api可以取代Redux吗?为什么?
- java出现圅_java获取汉字拼音首字母A
- 小米无线路由器服务器用户名和密码忘了,小米路由器忘记密码怎么解决?设置新密码登陆方法介绍...
- layui表格下拉框无法显示
- PPT中图表不同粘贴方式的区别
- Ubuntu18.04系统安装及深度学习框架搭建
- Django使用MySQL数据库
- 了解线性分组码的编码原理并编程实现C语言,线性分组码的编译码(DOC).doc
- 搭建网校平台的方式有哪些?
- 台式计算机和笔记本电脑的设计架构名称是,笔记本电脑内部结构
- RK3399平台开发系列讲解(内核调试篇)2.50、嵌入式产品启动速度优化
- win10+ubuntu双系统安装踩坑
- Typora——好用极简免费的跨平台Markdown编辑器
- 绩效管理流程是什么?
- 源码分析如何注解使用AOP