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变量, 你也可以称之为配置参数或配置键.使用统一的配置变量可以避免在程 ...
随机推荐
- ASP.NET微信公众号获取AccessToken
access_token是公众号的全局唯一接口调用凭据,公众号调用各接口时都需使用access_token.开发者需要进行妥善保存.access_token的存储至少要保留512个字符空间.acces ...
- 基于SOUI开发一个简单的小工具
基于DriectUI有很多库,比如 Duilib (免费) soui (免费) DuiVision (免费) 炫彩 (界面库免费,UI设计器付费,不提供源码) skinui (免费使用,但不开放源码, ...
- import tensorflow 报错: tf.estimator package not installed.
import tensorflow 报错: tf.estimator package not installed. 解决方案1: 安装 pip install tensorflow-estimator ...
- JAVA使用Logback发送日志到控制台、文件、ELK的最简单用法
一.简述 本文讲JAVA使用Logback发送日志到控制台.文件.ELK的最简单用法. 二.教程 1.新建pom.xml项目引入下列依赖: <dependencies> <!--Be ...
- failed to create process怎么解决
python 在cmd时,报错:failed to create process怎么解决 在cmd命令前加 : python -m 命令(如:python -m conda update conda)
- 【转】简单的解释XSS攻击
XSS 跨站点脚本 cross site script 怎么造成攻击? 举例:有一个公共的页面,所有用户都可以访问且可以保存内容,输入的时候若输入<script>alert('I am h ...
- WCF Restful Service Get / Post请求
Rest 它是用于创建分布式超文本媒体的一种架构方式,我们可以通过标准的HTTP(GET,POST,PUT,DELETE)操作来构建基于面向资源的软件架构方式(Resource-Oriented Ar ...
- Navicat Premium 12破解方法
来源网址:https://www.jianshu.com/p/42a33b0dda9c 1.按步骤安装Navicat Premium,如果没有可以去官网下载:http://www.navicat.co ...
- Atitit 最近资料文章列表r9 r8 月份 attilax总结
Atitit 最近资料文章列表r9 r8 月份 attilax总结 atitit tag标签标示规范 attilax总结 v2 r922.docx 2017-09-28 02:04 阅读(27) ...
- Tomcat服务器安装、配置、测试
Tomcat服务器安装.配置.测试(win7_64bit) 目录 1.概述 2.本文用到的工具 3.Tomcat服务器安装配置 4.Tomcat服务器简单测试 5.注意事项 >>看不清的图 ...