python2.7安装和uwsgi

python2.7安装和uwsgi 

tar zxf Python-2.7.13xxxx# 这里,必须用–enable-shared,生成动态库,否则会遇到wsgi不能编译的问题。

 

Bonus: multiple Python versions for the same uWSGI binary

As we have seen, uWSGI is composed of a small core and various plugins. Plugins can be embedded in the binary or loaded dynamically. When you build uWSGI for Python, a series of plugins plus the Python one are embedded in the final binary.

This could be a problem if you want to support multiple Python versions without building a binary for each one.

The best approach would be having a little binary with the language-independent features built in, and one plugin for each Python version that will be loaded on-demand.

In the uWSGI source directory:

make PROFILE=nolang

This will build a uwsgi binary with all the default plugins built-in except the Python one.

Now, from the same directory, we start building Python plugins:

PYTHON=python3.4 ./uwsgi --build-plugin "plugins/python python34"
PYTHON=python2.7 ./uwsgi --build-plugin "plugins/python python27" PYTHON=python2.6 ./uwsgi --build-plugin "plugins/python python26" 

You will end up with three files: python34_plugin.so, python27_plugin.so, python26_plugin.so. Copy these into your desired directory. (By default, uWSGI searches for plugins in the current working directory.)

Now in your configurations files you can simply add (at the very top) the plugins-dir and plugin directives.

[uwsgi]
plugins-dir = <path_to_your_plugin_directory>
plugin = python26 

This will load the python26_plugin.so plugin library from the directory into which you copied the plugins.

转载于:https://www.cnblogs.com/sundahua/p/7140389.html

安装uwsgi,可以按照以下步骤进行操作: 1. 首先,在项目中创建一个包含项目依赖的requirements.txt文件。你可以使用以下两种方法来生成该文件: - 执行命令 `pip freeze > requirements.txt`,这会将所有环境的依赖包都导出到requirements.txt文件中。 - 安装pipreqs,并执行命令 `pipreqs ./ --encoding=utf-8`,这会仅仅导出项目所依赖的包。 2. 修改代码,将项目传到Linux服务器上。确保已经调整好了代码,例如将app的创建改为 `app = create_app('product')`。 3. 在Linux服务器上启动uwsgi服务。可以通过以下命令进行启动: - `uwsgi --ini uwsgi.ini`,这会直接进入控制台启动uwsgi服务器。 - `nohup uwsgi --ini uwsgi.ini &`,这会在后台启动uwsgi服务器。 4. 如果需要重启uwsgi服务,可以使用以下命令: - `uwsgi --reload uwsgi.pid`,这会重新加载uwsgi服务。 5. 如果需要停止uwsgi服务,可以使用以下命令: - `uwsgi --stop uwsgi.pid`,这会停止uwsgi服务。 请注意,如果需要直接关闭uwsgi服务,可以使用 `kill -9 pid` 命令,其中pid是uwsgi的进程ID。 对于在CentOS上安装uwsgi,可以按照以下步骤进行操作: 1. 首先,安装所需的依赖库。可以使用以下命令来安装: ``` yum groupinstall "Development tools" yum install zlib-devel bzip2-devel pcre-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel python-devel ``` 2. 使用pip来安装uwsgi: ``` pip install uwsgi ``` 如果你没有使用虚拟环境,你可能需要手动将uwsgi的路径添加到sys.path中。例如: ``` import sys sys.path.append('/usr/lib/python2.7/site-packages') sys.path.append('/usr/lib64/python2.7/site-packages') ``` 这样就可以使用pip来安装uwsgi了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [关于uWSGI服务器的安装和启动(一)](https://blog.csdn.net/YZL40514131/article/details/123462528)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [pip 安装uwsgi](https://blog.csdn.net/weixin_34414650/article/details/92462413)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值