nginx+wsgi+flask configuration
wsgi configuration file
<code>vim uwsgi.ini [uwsgi] <span>socket</span> = /tmp/t1.sock <span>pidfile</span> = /tmp/t1.pid <span>plugins</span> = python <span>pythonpath</span> = /var/www <span>#项目python环境</span><span>virtualenv</span> = /var/www/env <span>#项目的跟路径</span><span>pythonpath</span> = /var/www/my_flask <span>chdir</span> = /var/www/my_flask <span>#日志文件</span><span>daemonize</span> = /var/www/my_flask/web.log chmod-socket = 666 <span>master</span> = true <span>#启动的进程</span><span>processes</span> = 4 <span>#环境变量</span><span>env</span>=PYTH/t1 <span>env</span>=LANG=zh_CN.UTF-8 <span>env</span>=LC_ALL=zh_CN.UTF-8 <span>#flask app的 py文件</span><span>module</span> = index <span>#app的 py文件里面的app对象</span><span>callable</span> = app max-requests = 500000 <span>#运行的用户</span><span>gid</span> = www-data <span>uid</span> = www-data ignore-sigpipe = true enable-threads = true</code>
tested index.py
<code><span>from</span> flask <span>import</span> Flask app = Flask(__name__) <span>@app.route("/")</span><span><span>def</span><span>hello</span><span>()</span>:</span><span>return</span><span>"Hello World!</span></code>
run
<code><span>#以www-data用户运行 uwsgi </span> sudo -u www-data uwsgi --ini uwsgi.ini <span>#运行后会生成socket文件</span>root<span>@ubuntu</span><span>:/var/www/my_flask</span><span># ll /tmp/t1*</span> -rw-r--r-- <span>1</span> www-data www-data <span>5</span><span>Mar</span><span>21</span><span>10</span><span>:</span><span>13</span> /tmp/t1.pid srw-rw-rw- <span>1</span> www-data www-data <span>0</span><span>Mar</span><span>21</span><span>10</span><span>:</span><span>13</span> /tmp/t1.sock=</code>
nginx configuration
<code>server { <span>...</span> location / { include uwsgi_params; uwsgi_pass unix:///tmp/t1.sock; <span>#这为生成的sock文件</span> } <span>...</span> }</code>
The above introduces the nginx+wsgi+flask configuration, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Most of the .tmp files are files left behind due to abnormal shutdown or crash. These temporary scratch disks have no use after you restart the computer, so you can safely delete them. When you use the Windows operating system, you may often find some files with the suffix TMP in the root directory of the C drive, and you will also find a TEMP directory in the Windows directory. TMP files are temporary files generated by various software or systems. , also known as junk files. Temporary files generated by Windows are essentially the same as virtual memory, except that temporary files are more targeted than virtual memory and only serve a certain program. And its specificity has caused many novices to be intimidated by it and not delete it.

How to use React and Flask to build simple and easy-to-use web applications Introduction: With the development of the Internet, the needs of web applications are becoming more and more diverse and complex. In order to meet user requirements for ease of use and performance, it is becoming increasingly important to use modern technology stacks to build network applications. React and Flask are two very popular frameworks for front-end and back-end development, and they work well together to build simple and easy-to-use web applications. This article will detail how to leverage React and Flask

Django and Flask are both leaders in Python Web frameworks, and they both have their own advantages and applicable scenarios. This article will conduct a comparative analysis of these two frameworks and provide specific code examples. Development Introduction Django is a full-featured Web framework, its main purpose is to quickly develop complex Web applications. Django provides many built-in functions, such as ORM (Object Relational Mapping), forms, authentication, management backend, etc. These features allow Django to handle large

Starting from scratch, I will teach you step by step how to install Flask and quickly build a personal blog. As a person who likes writing, it is very important to have a personal blog. As a lightweight Python Web framework, Flask can help us quickly build a simple and fully functional personal blog. In this article, I will start from scratch and teach you step by step how to install Flask and quickly build a personal blog. Step 1: Install Python and pip Before starting, we need to install Python and pi first

Flask framework installation tutorial: Teach you step by step how to correctly install the Flask framework. Specific code examples are required. Introduction: Flask is a simple and flexible Python Web development framework. It's easy to learn, easy to use, and packed with powerful features. This article will lead you step by step to correctly install the Flask framework and provide detailed code examples for reference. Step 1: Install Python Before installing the Flask framework, you first need to make sure that Python is installed on your computer. You can start from P

There is a lot of garbage in the tmp directory in the centos7 system. If you want to clear the garbage, how should you do it? Let’s take a look at the detailed tutorial below. To view the list of files in the tmp file directory, execute the command cdtmp/ to switch to the current file directory of tmp, and execute the ll command to view the list of files in the current directory. As shown below. Use the rm command to delete files. It should be noted that the rm command deletes files from the system forever. Therefore, it is recommended that when using the rm command, it is best to give a prompt before deleting the file. Use the command rm-i file name, wait for the user to confirm deletion (y) or skip deletion (n), and the system will perform corresponding operations. As shown below.

FlaskvsFastAPI: The best choice for efficient development of WebAPI Introduction: In modern software development, WebAPI has become an indispensable part. They provide data and services that enable communication and interoperability between different applications. When choosing a framework for developing WebAPI, Flask and FastAPI are two choices that have attracted much attention. Both frameworks are very popular and each has its own advantages. In this article, we will look at Fl

Flask application deployment: Comparison of Gunicorn vs suWSGI Introduction: Flask, as a lightweight Python Web framework, is loved by many developers. When deploying a Flask application to a production environment, choosing the appropriate Server Gateway Interface (SGI) is a crucial decision. Gunicorn and uWSGI are two common SGI servers. This article will describe them in detail.
