linux部署的flask项目配置static
环境:
- Python2.7
- flask
- nginx
- linux的系统是Ubantu
Python:我的是linux已经有的。
flask:pip install flask
nginx:sudo apt-get install nginx
具体步骤请看前几篇博客。
以上过程结束后,进行如下操作:
sudo vim /etc/nginx/sites-available/default
进入编辑:
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
## # Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server; # SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf; root /var/www/html;
location /allstatic {
alias /zzy/zzy/atatic;
} # Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html; server_name _; location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
在配置文件里面增加:
root /var/www/html;
location /allstatic {
alias /zzy/zzy/atatic;
}
即可!
参考http://wiki.ubuntu.org.cn/Nginx
linux部署的flask项目配置static的更多相关文章
- 使用Nginx+Uwsgi部署Python Flask项目
第一次用Flask做Web(也是第一次用Python做Web),在部署的时候遇到了不少问题,现在将过程就下来,供在这方面也有疑惑的人参考.(PS:使用Apache+mod_wsgi部署模式的可以参考另 ...
- 【Centos】【Python】【Flask】阿里云上部署一个 flask 项目
1. 安装 python3 和 pip3 参考:http://www.cnblogs.com/mqxs/p/8692870.html 2.安装 lnmpa 集成开发环境 参考:http://www.c ...
- Linux 部署.Net Core 项目
前面也有说到,我学习Linux 主要因为要学习一下部署.NET CORE项目到Linux 系统,这里就记录一下部署的详细步骤吧. 主要需要安装以下几个工具 1..NET CORE SDK 2.Jexu ...
- linux部署.net Core项目
首篇笔记,多多关照.方便回忆和给新手指导,大神绕道 首先在Linux系统部署.net Core项目首先准备一个Linux系统的服务器,百度云,阿里云都行. 1.net core 部署在Linux系统上 ...
- [傻瓜式一步到位] 阿里云服务器Centos上部署一个Flask项目
网络上关于flask部署Centos的教程有挺多,不过也很杂乱. 在我第一次将flask上传到centos服务器中遇到了不少问题,也费了挺大的劲. 在参考了一些教程,并综合了几个教程之后才将flask ...
- 【Azure 应用服务】App Service For Linux 部署PHP Laravel 项目,如何修改首页路径为 wwwroot\public\index.php
问题描述 参考官方文档部署 PHP Laravel 项目到App Service for Linux环境中,但是访问应用时候遇见了500 Server Error 错误. 从部署的日志中,可以明确看出 ...
- centos 6.x 部署uwsgi+flask项目
一.项目背景 1. 公司需求要做一个在线统计页面; 2. 统计在线人数,进行人数数据展示; 3. 类似QQ官网在线人数 二.测试环境 [root@linux-node2 ~]# cat /etc/*r ...
- 一个jetty部署多个项目配置之方法一
https://my.oschina.net/wangyongqing/blog/115647 Jetty用户经常想配置他们的web应用到不同的虚拟主机. 通常情况下,一个单一的IP地址的机器有不同的 ...
- 【flask】flask项目配置 app.config
[理论] 在很多情况下,你需要设置程序的某些行为,这时你就需要使用配置变量.在Flask中,配置变量就是一些大写形式的Python变量, 你也可以称之为配置参数或配置键.使用统一的配置变量可以避免在程 ...
随机推荐
- pygame 笔记-8 背景音乐&子弹音效
游戏哪能没有音效?这节我们研究下如何加背景音乐,其实也很简单: # 加载背景音乐 pygame.mixer.music.load(music_base_path + "music.mp3&q ...
- ARMv8寄存器手册
这份手册是从DS5里拷贝出来的,他是以网页的形式用浏览器打开,方面查看寄存器. ARMv8_regs_xhtml.tar.gz
- Python3 与 NetCore 基础语法对比(List、Tuple、Dict、Set专栏)
Jupyter最新版:https://www.cnblogs.com/dotnetcrazy/p/9155310.html 在线演示:http://nbviewer.jupyter.org/githu ...
- 中国大学MOOC-陈越、何钦铭-数据结构-2017春
中国大学MOOC-陈越.何钦铭-数据结构-2017春 学习地址 详细学习内容 Github记录地址 欢迎fork和star,有惊喜值得学习! 参考学习笔记 参考AC代码 数据结构和算法学习笔记 学习内 ...
- n2n的编译和运行、配置
交叉编译: cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/CMakeToolchainFileMingw32.cmake -build ./ ../ 1.n2n 基于p ...
- Docker入门 - 001 CentOS Docker 安装
Docker支持以下的CentOS版本: CentOS 7 (64-bit) CentOS 6.5 (64-bit) 或更高的版本 前提条件 目前,CentOS 仅发行版本中的内核支持 Docker. ...
- java 获取当天(今日)零点零分零秒
两种方法 一种得到的是时间戳,一种得到是日期格式: 1.日期格式的 Calendar calendar = Calendar.getInstance(); calendar.setTime(new D ...
- sql中的left join以及on、where关键字的区别
创建两张表并插入一些数据 create table class( class_id int, class_name ), class_grade ) ); ,'语文','A'); ,'数学','B') ...
- MySQL执行计划解析
前言 在实际数据库项目开发中,由于我们不知道实际查询时数据库里发生了什么,也不知道数据库是如何扫描表.如何使用索引的,因此,我们能感知到的就只有SQL语句的执行时间.尤其在数据规模比较大的场景下,如何 ...
- IntelliJIdea 2016.2 使用 tomcat 8.5 调试spring的web项目时,bean被实例化两次导致timer和thread被启动了两遍的问题的解决
今天新搭建了一个spring的web项目,项目启动时会启动一个线程,线程里定时执行任务,另外还启动了一个定时器,每秒钟统计系统吞吐量等业务性能数据.但是调试的时候惊奇的发现定时器和线程均被启动了两次. ...