https://pypi.python.org/pypi/setuptools#downloads
https://www.python.org/ftp/python/
开机 加入 uwsgi nginx 自启动
echo "/etc/init.d/nginx restart" >>/etc/rc.local
echo "/usr/bin/setsid /data/soft_ware/uwsgi-1.9.6/uwsgi /data/soft_ware/s10day11/demo.ini " >>/etc/rc.local
setsid 是后台挂起不受hungup 信号的影响。 进程号为1 与init相同
一 centos python是2.6 版本所以我们需要 装python2.7.9 请看之前的博客
查看python的版本
- #python -V
- Python 2.6.6
1.下载Python-2.7.3
- #wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
附带 3.5.1 https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz
2.解压
- #tar -jxvf Python-2.7.3.tar.bz2
3.更改工作目录
- #cd Python-2.7.3
4.安装
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
- #./configure
- #make all
- #make install
- #make clean
- #make distclean
5.查看版本信息
- #/usr/local/bin/python2.7 -V
6.建立软连接,使系统默认的 python指向 python2.7
- #mv /usr/bin/python /usr/bin/python2.6.6
- #ln -s /usr/local/bin/python2.7 /usr/bin/python
7.重新检验Python 版本
- #python -V
8解决系统 Python 软链接指向 Python2.7 版本后,因为yum是不兼容 Python 2.7的,所以yum不能正常工作,我们需要指定 yum 的Python版本
- #vi /usr/bin/yum
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6.6
http://www.zhangchun.org/the-centos6-3-upgrade-python-to-2-7-3-
这篇教程就到这里了,但是不久就突然发现输入法图标不见了,然后打字没有候选框!iBus 崩了!再次进行搜索,又是版本问题 iBus也是不支持Python2.7的啊!
于是。。。
以前在使用Python的时候,都是使用root用户安装好的全局python,现在,因为root用户安装的Python版本太低,同时自己没有root权限去对全局Python升级,所以要在非root用户下安装自己指定的Python。因此,就重新整理了一份如何在Linux环境下使用非root用户安装python及其相关的库,以备不时之需。
安装python
python版本库https://www.python.org/ftp/python/,此处我选择2.7.5版本的,在安装python的时候,使用--prefix
指定安装路径即可,命令如下:
wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tar -xzf Python-2.7.5.tgz
cd Python-2.7.5
mkdir -p /home/liudiwei/software/python27
./configure --prefix="/home/liudiwei/software/python27"
make
make install
[liujianzuo@sy01-db3 pip-8.1.1]$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=/home/liujianzuo/bin/python/bin:$PATH:$HOME/bin
export PATH
[liujianzuo@sy01-db3 ~]$ . .bash_profile
[liujianzuo@sy01-db3 ~]$ which python
~/bin/python/bin/python
安装setuptools
setuptools主要是为安装pip做准备的,下面是从下载到安装的全部命令,使用上面安装的指定路径的python/home/liudiwei/software/python27/bin/python
进行安装:
https://pypi.python.org/pypi/setuptools页面最下面的有它的安装链接 cd /home/work/prober/src/lib/thirdparty
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-12.0.3.tar.gz#md5=f07e4b0f4c1c9368fcd980d888b29a65
tar xvf setuptools-12.0..tar.gz
cd setuptools-12.0.
python setup.py install
cd ..
wget --no-check-certificate https://pypi.python.org/packages/41/27/9a8d24e1b55bd8c85e4d022da2922cb206f183e2d18fee4e320c9547e751/pip-8.1.1.tar.gz#md5=6b86f11841e89c8241d689956ba99ed7
tar -xzf pip-8.1..tar.gz
cd pip-8.1.
python setup.py install
cd ..
# 升级pip
python -m pip install --upgrade pip
安装pip
使用pip来安装python相关库,方便简单,此处将python setup.py install
的python换成自己安装的指定路径下的python/home/liudiwei/software/python27/bin/python setup.py install
.
wget --no-check-certificate https://pypi.python.org/packages/41/27/9a8d24e1b55bd8c85e4d022da2922cb206f183e2d18fee4e320c9547e751/pip-8.1.1.tar.gz#md5=6b86f11841e89c8241d689956ba99ed7
tar -xzf pip-8.1.1.tar.gz
cd pip-8.1.1
python setup.py install
安装相关库
进入python安装目录的bin路径下,安装下面相关库,经测试,下列库均可安装。
- simplejson
- redis
- numpy
- scipy
- sklearn
安装命令:
cd /home/liudiwei/software/python27/bin/
./pip install simplejson
./pip install redis
./pip install numpy
./pip install scipy
./pip install sklearn
关于matplotlib的安装,因为系统有些依赖包没有安装而导致matplotlib安装失败,如libpng, freetype等,待后续安装完成后,再来完善。
9.配置iBus
分别用 vi 打开下面两个文件,找到 exec python 那一行,把exec python 改为 exec python2.6 保存,退出。iBus在重启后就恢复正常了!是不是很开心?
- #vi /usr/bin/ibus-setup
- #vi/usr/libexec/ibus-ui-gtk
二 、centos 安装django python支持的mysql模块
yum -y install mysql-devel
[root@ayibang-server ~]# yum install -y MySQL-python
安装uwsgi 尽量别装 2版本 会报错。 当然用如下方法装2 版本 指定python版本安装uwsgi也行。 待测。
重装 uwsgi1.9版本 指定python版本 python2.7
[root@ayibang-server soft_ware]# tar zxf uwsgi-1.9.6.tar.gz
[root@ayibang-server soft_ware]# cd uwsgi-1.9.6
[root@ayibang-server uwsgi-1.9.6]# python
python python-config python2 python2-config python2.7 python2.7-config
[root@ayibang-server uwsgi-1.9.6]# python2.7 uwsgiconfig.py --build
装django
[root@ayibang-server soft_ware]# tar zxvf Django-1.8.4.tar.gz
cd Django-1.8.4 之后 如果执行 安装 就是python版本问题
[root@ayibang-server Django-1.8.4]# python setup.py install
Traceback (most recent call last):
File "setup.py", line 32, in <module>
version = __import__('django').get_version()
File "/data/soft_ware/Django-1.8.4/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/data/soft_ware/Django-1.8.4/django/utils/version.py", line 7, in <module>
from django.utils.lru_cache import lru_cache
File "/data/soft_ware/Django-1.8.4/django/utils/lru_cache.py", line 28
fasttypes = {int, str, frozenset, type(None)},
^
SyntaxError: invalid syntax
解决
[root@ayibang-server soft_ware]# wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
接下来就是 第一步的操作; 安装2.7版本python
四 报错 没装settools
[root@ayibang-server Django-1.8.4]# python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import find_packages, setup
ImportError: No module named setuptools
1. 下载setuptools及pip的源码包
setuptools与pip都是python的模块
setuptools源码包: https://pypi.python.org/pypi/setuptools
pip源码包: https://pypi.python.org/pypi/pip#downloads
2. 安装setuptools与pip
目前下载的版本是setuptools-12.0.5.tar.gz与pip-6.0.6.tar.gz
先安装setuptools, 进行setuptools的源码根目录下, 执行以下命令进行setuptools模块的安装:
- # python setup.py install
安装完setuptools后, 接着安装pip, 进入pip的源码包根目录下, 执行以下命令进行安装:
- # python setup.py build
- # python setup.py install
安装完pip后. 看看pip都安装在哪里. 执行以下命令:
- # whereis pip
然后再执行 # pip 命令并回车, 如果无法用pip命令, 则可通过创建pip软链接, 执行以下命令:
重装django 检测
五 5.关联django到nginx 服务器已经在跑PHP站点,现在新生成一个虚拟服务器
[root@ayibang-server ~]# cat /etc/nginx/conf.d/django.conf
server {
listen 8000;
server_name 192.168.1.200;
location / {
include uwsgi_params;
uwsgi_pass 0.0.0.0:9000;
}
}
完成后重启下nginx服务
$ sudo /etc/init.d/nginx restart
六 配置 uwsgi 启动文件 这里有个错 ,网上文章有错误 网上的文件写的可能是早期的 版本。
1 py文件启动
[root@ayibang-server ~]# cd /data/soft_ware/mysite/ #进到项目目录
[root@ayibang-server mysite]# ls
app01 db.sqlite3 demo.ini demo.py demo.pyc manage.py mysite
编辑一个py文件
[root@ayibang-server mysite]# cat demo.py
#!/usr/bin/env python
#coding:utf-8
import os
from django.core.wsgi import get_wsgi_application #网上的大都导入的其他模块 这个版本1.9 uwsgi 1.8 django 可能就不支持了
os.environ['DJANGO_SETTINGS_MODULE']='mysite.settings' #项目名 mysite 记得改 ; setting
application = get_wsgi_application()
启动 uwsgi 如下端口 对应 你的nginx的pass 端口 记住应用 你自己安装的 uwsg 看前面的第2三4补
[root@ayibang-server mysite]# /data/soft_ware/uwsgi-1.9.6/uwsgi -s 0.0.0.0:9000 -w demo
2 ini 文件启动
[root@ayibang-server ~]# cd /data/soft_ware/mysite/ #进到项目目录
[root@ayibang-server mysite]# ls
[uwsgi]
socket = 0.0.0.0:9000
processes = 3 #进程数
chdir = /data/soft_ware/mysite/ #项目名 mysite 记得改
pythonpath = /usr/local/bin/python
env = DJANGO_SETTINGS_MODULE=mysite.settings #项目名 mysite 记得改 ; setting
module = django.core.wsgi:get_wsgi_application()
ini 文件 启动方式
[root@ayibang-server s10day11]# /data/soft_ware/uwsgi-1.9.6/uwsgi demo.ini
对比 我的 另一个项目 的不同
[root@ayibang-server ~]# cd /data/soft_ware/s10day11/
[root@ayibang-server s10day11]# ls
app01 app03 app04 db.sqlite3 demo.ini demo.py demo.pyc manage.py s10day11 statics templates test
[root@ayibang-server s10day11]# cat demo.py
#!/usr/bin/env python
#coding:utf-8
import os
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE']='s10day11.settings'
application = get_wsgi_application()
[root@ayibang-server s10day11]# cat demo.ini
[uwsgi]
socket = 0.0.0.0:9000
processes = 9
chdir = /data/soft_ware/s10day11/
pythonpath = /usr/local/bin/python
env = DJANGO_SETTINGS_MODULE=s10day11.settings
module = django.core.wsgi:get_wsgi_application()
[root@ayibang-server s10day11]# /data/soft_ware/uwsgi-1.9.6/uwsgi demo.ini
[uWSGI] getting INI configuration from demo.ini
*** Starting uWSGI 1.9.6 (64bit) on [Thu Dec 3 15:02:25 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-4) on 03 December 2015 12:59:57
os: Linux-2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013
nodename: ayibang-server
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /data/soft_ware/s10day11
detected binary path: /data/soft_ware/uwsgi-1.9.6/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 30853
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address 0.0.0.0:9000 fd 3
Python version: 2.7.9 (default, Dec 3 2015, 01:04:49) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xd129b0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 654264 bytes (638 KB) for 9 cores
*** Operational MODE: preforking ***
added /usr/local/bin/python to pythonpath.
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xd129b0 pid: 23478 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 23478, cores: 1)
spawned uWSGI worker 2 (pid: 23485, cores: 1)
spawned uWSGI worker 3 (pid: 23486, cores: 1)
spawned uWSGI worker 4 (pid: 23487, cores: 1)
spawned uWSGI worker 5 (pid: 23488, cores: 1)
spawned uWSGI worker 6 (pid: 23489, cores: 1)
spawned uWSGI worker 7 (pid: 23490, cores: 1)
spawned uWSGI worker 8 (pid: 23491, cores: 1)
spawned uWSGI worker 9 (pid: 23492, cores: 1)
3 xml 文件启动方式
如安装了libxml2,也可用如下方法处理:
在app目录创建个django.xml文件
[root@ayibang-server s10day11]# sudo vi django.xml
内容如下:
127.0.0.1:9090
2
/var/www/erp/erp
..
DJANGO_SETTINGS_MODULE=mysite.settings
django.core.wsgi:get_wsgi_application()
启动方式:
[root@ayibang-server s10day11]# uwsgi -x django.xml
FAQ 总结
报错1 python版本不一致
[root@ayibang-server s10day11]# uwsgi -s 0.0.0.0:9999 -w demo
*** Starting uWSGI 2.0.6 (64bit) on [Thu Dec 3 12:29:00 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-4) on 03 December 2015 00:55:54
os: Linux-2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013
nodename: ayibang-server
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /data/soft_ware/s10day11
detected binary path: /usr/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 30853
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:9999 fd 3
Python version: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1a33780
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72768 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
Traceback (most recent call last):
File "./demo.py", line 2, in <module>
import django.core.handlers.wsgi
ImportError: No module named django.core.handlers.wsgi
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 26436, cores: 1)
开始 解决报错1 python 版本不一致
先pip uninstall uwsgi,然后yum install -y pcre pcre-devel pcre-static
安装pip
[root@ayibang-server soft_ware]# tar zxf pip-6.0.6.tar.gz
[root@ayibang-server soft_ware]# cd pip-
-bash: cd: pip-: No such file or directory
[root@ayibang-server soft_ware]# cd pip-6.0.6
[root@ayibang-server pip-6.0.6]# python setup.py build
[root@ayibang-server pip-6.0.6]# python setup.py install
创建项目 app
[root@ayibang-server soft_ware]# python /usr/local/bin/django-admin.py startproject mysite
[root@ayibang-server soft_ware]# python manage.py startapp app01
原来是 uwsgi是识别的 python2.6 而2.6 对django1.8不支持太好
[root@ayibang-server uwsgi-2.0.6]# ls /usr/bin/python*
/usr/bin/python /usr/bin/python2 /usr/bin/python2.6-config
/usr/bin/python-config /usr/bin/python2.6 /usr/bin/python2.6.6
[root@ayibang-server uwsgi-2.0.6]# vim /usr/bin/python-config
[root@ayibang-server uwsgi-2.0.6]# ls /usr/local/bin/python*
/usr/local/bin/python /usr/local/bin/python2 /usr/local/bin/python2.7
/usr/local/bin/python-config /usr/local/bin/python2-config /usr/local/bin/python2.7-config
重装 uwsgi1.9版本 指定python版本 python2.7
[root@ayibang-server soft_ware]# tar zxf uwsgi-1.9.6.tar.gz
[root@ayibang-server soft_ware]# cd uwsgi-1.9.6
[root@ayibang-server uwsgi-1.9.6]# python
python python-config python2 python2-config python2.7 python2.7-config
[root@ayibang-server uwsgi-1.9.6]# python2.7 uwsgiconfig.py --build
执行1.9版本报错 缺少lib 解决yum libyaml
[root@ayibang-server uwsgi-1.9.6]# ./uwsgi --version
./uwsgi: error while loading shared libraries: libyaml-0.so.2: cannot open shared object file: No such file or directory
[root@ayibang-server uwsgi-1.9.6]# yum install libyaml
[root@ayibang-server uwsgi-1.9.6]# which uwsgi
/usr/sbin/uwsgi
[root@ayibang-server uwsgi-1.9.6]# uwsgi --version
2.0.6
重新启动
[root@ayibang-server mysite]# /data/soft_ware/uwsgi-1.9.6/uwsgi -s 127.0.0.1:9000 -w demo
*** Starting uWSGI 1.9.6 (64bit) on [Thu Dec 3 13:05:55 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-4) on 03 December 2015 12:59:57
os: Linux-2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013
nodename: ayibang-server
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /data/soft_ware/mysite
detected binary path: /data/soft_ware/uwsgi-1.9.6/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 30853
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address 127.0.0.1:9000 fd 3
Python version: 2.7.9 (default, Dec 3 2015, 01:04:49) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x2844750
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72696 bytes (70 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x2844750 pid: 1772 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 1772, cores: 1)
报错2 解决
http://blog.163.com/rihui_7/blog/static/21228514320151353149688/
uwsgi+django报错django.core.exceptions.AppRegistryNotReady
uwsgi+django报错django.core.exceptions.AppRegistryNotReady
File “/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py”, line 187, in __call__
response = self.get_response(request)
File “/usr/lib/python2.7/site-packages/django/core/handlers/base.py”, line 199, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File “/usr/lib/python2.7/site-packages/django/core/handlers/base.py”, line 236, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File “/usr/lib/python2.7/site-packages/django/views/debug.py”, line 91, in technical_500_response
html = reporter.get_traceback_html()
File “/usr/lib/python2.7/site-packages/django/views/debug.py”, line 350, in get_traceback_html
return t.render(c)
File “/usr/lib/python2.7/site-packages/django/template/base.py”, line 148, in render
return self._render(context)
File “/usr/lib/python2.7/site-packages/django/template/base.py”, line 142, in _render
return self.nodelist.render(context)
File “/usr/lib/python2.7/site-packages/django/template/base.py”, line 844, in render
bit = self.render_node(node, context)
File “/usr/lib/python2.7/site-packages/django/template/debug.py”, line 80, in render_node
return node.render(context)
File “/usr/lib/python2.7/site-packages/django/template/debug.py”, line 90, in render
output = self.filter_expression.resolve(context)
File “/usr/lib/python2.7/site-packages/django/template/base.py”, line 624, in resolve
new_obj = func(obj, *arg_vals)
File “/usr/lib/python2.7/site-packages/django/template/defaultfilters.py”, line 769, in date
return format(value, arg)
File “/usr/lib/python2.7/site-packages/django/utils/dateformat.py”, line 343, in format
return df.format(format_string)
File “/usr/lib/python2.7/site-packages/django/utils/dateformat.py”, line 35, in format
pieces.append(force_text(getattr(self, piece)()))
File “/usr/lib/python2.7/site-packages/django/utils/dateformat.py”, line 268, in r
return self.format(‘D, j M Y H:i:s O’)
File “/usr/lib/python2.7/site-packages/django/utils/dateformat.py”, line 35, in format
pieces.append(force_text(getattr(self, piece)()))
File “/usr/lib/python2.7/site-packages/django/utils/encoding.py”, line 85, in force_text
s = six.text_type(s)
File “/usr/lib/python2.7/site-packages/django/utils/functional.py”, line 144, in __text_cast
return func(*self.__args, **self.__kw)
File “/usr/lib/python2.7/site-packages/django/utils/translation/__init__.py”, line 83, in ugettext
return _trans.ugettext(message)
File “/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py”, line 325, in ugettext
return do_translate(message, ‘ugettext’)
File “/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py”, line 306, in do_translate
_default = translation(settings.LANGUAGE_CODE)
File “/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py”, line 209, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File “/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py”, line 189, in _fetch
“The translation infrastructure cannot be initialized before the ”
django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don’t make non-lazy gettext calls at import time.
参照网上用uwsgi+nginx配置python环境时,报了这么个错,google发现是WSGI application的问题,好象是因为django升级,配置有所变化。
原来:
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
改成:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
重启一下uwsgi。
网上找来的解决办法,希望有帮助。
后补:也可能是python版本和django版本不兼容问题,重新安装django并选定安装的版本就可以了
原来的 是如下 方式写的 不过我的改成上面 黄色部分 如下是老版本的 调用方法
配置并运行一个简单的python页面
$ cd /var/www/mysite
/var/www/mysite$ sudo vi demo.py
输入如下代码:
import os
import django.core.handlers.wsgi
os.environ['DJANGO_SETTINGS_MODULE']='mysite.settings'
application=django.core.handlers.wsgi.WSGIHandler()
/var/www/mysite$ uwsgi -s 127.0.0.1:9090 -w demo
如安装了libxml2,也可用如下方法处理:
在app目录创建个django.xml文件
/var/www/mysite$ sudo vi django.xml
内容如下:
127.0.0.1:9090
2
/var/www/erp/erp
..
DJANGO_SETTINGS_MODULE=mysite.settings
django.core.handlers.wsgi:WSGIHandler()
启动方式:
/var/www/mysite$ uwsgi -x django.xml
另一种配置方式,用于没有安装libxml2:
ini配置文件
/var/www/mysite$ sudo vi django.ini
[uwsgi]
socket = 127.0.0.1:9090
processes = 2
chdir = /var/www/mysite/mysite/
pythonpath = ..
env = DJANGO_SETTINGS_MODULE=mysite.settings
module = django.core.handlers.wsgi:WSGIHandler()
启动方式:
/var/www/mysite$ uwsgi django.ini
服务成功启动后访问 http://127.0.0.1:8000,如能看到欢迎信息,就说明运行环境配置好了。更多的设置可以看下The_Django_Book
千里之行,始于足下。慢慢设计你的website吧...
经过各种坑之后centos+ uwsgi + nginx +django 终于配好了的更多相关文章
-
uWSGI + Nginx + Django 部署
1. uWSGI 服务器 Django 默认使用 WSGI(Python Web Server Gateway ) 作为 Web 服务器,一般仅用来作为测试使用,实际生产环境而是使用 uWSGI 和 ...
-
linux上uwsgi+nginx+django发布项目
在发布项目前首先将部署环境进行搭建,尤其是依赖包一定需要提前安装. 一.虚拟环境的搭建 1.建议在linux下新建一个虚拟环境,这样有独立干净的环境. mkvirtualenv -p python3 ...
-
uWSGI+nginx+django+virtualenv+supervisor部署项目
一.前言 在部署项目前,你已有一个能够在你本机测试过,能正常启动的Django项目(毕竟本文主要讲解部署Django项目),以及掌握了Linux系统的一些基本命令. 相关链接: Centos7安装py ...
-
centos+uwsgi+nginx+python+django服务器安装配置
1.ssh登录后使用fdisk –l查看需要格式化硬盘的名称: 2.运行fdisk /dev/vdb,对数据盘进行分区,按照提示,依次输入n,p,1,两次回车,wq,分区开始.(注意数据盘的名称,和阿 ...
-
uwsgi+nginx+django生产环境部署
1.升级python到2.7版本 2.安装uwsgi 出现uwsgi未找到 yum groupinstall "Development tools"yum install zlib ...
-
centOS+uwsgi+nginx 部署flask项目,问题记录
用flask做的项目想要部署到centOS系统上,填了一些坑,终于成功了,记录一下遇到的问题: 此次部署主要是按照这个博客进行的 https://www.cnblogs.com/Ray-liang/p ...
-
ubuntu初始化python3+postgresql+uwsgi+nginx+django
一. postgresql 数据库 安装 apt-get update apt-get install postgresql 进入psql客户端 sudo -u postgres psql 创建数据库 ...
-
Django服务器布置(Ubuntu+uwsgi+nginx+Django)
一.安装Python apt install python3 二.安装pip apt install python3-pip 三.创建目录 创建虚拟服务目录 mkdir -p /data/env 创建 ...
-
CentOS+Uwsgi+Nginx发布Flask开发的WebAPI
1.WebAPI 开发工具VS 于Windows环境中开发完成后使用SFTP进行同步文件到Centos中使用 2.重点:WebAPI触发的方法是为了发送Celery异步调度任务 Celery框架使用涉 ...
随机推荐
-
基于.NET平台常用的框架整理
自从学习.NET以来,优雅的编程风格,极度简单的可扩展性,足够强大开发工具,极小的学习曲线,让我对这个平台产生了浓厚的兴趣,在工作和学习中也积累了一些开源的组件,就目前想到的先整理于此,如果再想到,就 ...
-
恢复 git reset -hard 的误操作
有时候使用Git工作得小心翼翼,特别是涉及到一些高级操作,例如 reset, rebase 和 merge.甚至一些很小的操作,例如删除一个分支,我都担心数据丢失. 不 久之前,我在做一些大动作(re ...
-
2014 Hangjs 见闻流水账第二天
前言 第一天传送门: 2014 Hangjs 见闻流水账第一天 写作风格跟第一天还是一样的. Slide 每个slide我都会根据自己的理解重新命名一次,用于表达自己的第一看法,主观意见,不喜可吐槽, ...
-
Maven 私有库 Nexus的安装
1.下载 Nexus下载地址:http://www.sonatype.org/nexus/go/ # wget https://sonatype-download.global.ssl.fastly. ...
-
nmap使用详解
nmap是一个网络探测和安全扫描程序, 系统管理者和个人可以使用这个软件扫描大型的网络,获取那台主机正在运行以及提供什么服务等信息.nmap支持很多扫描技术,例如:UDP.TCP connect(). ...
-
基于perl面向对象开发的微信机器人
<pre name="code" class="html">[root@wx03 lib]# ls -ltr total 40 -rw-r--r-- ...
-
Footer固定在页面底部(CSS)
<style type="text/css"> #wapper{ position: relative; /*重要!保证footer是相对于wapper位置绝对*/ h ...
-
Javascript学习一
//学习moocjs1 JavaScript-警告(alert 消息对话框) <script type="text/javascript"> var mynum = 3 ...
-
洛谷AT2342 Train Service Planning(思维,动态规划,珂朵莉树)
洛谷题目传送门 神仙思维题还是要写点东西才好. 建立数学模型 这种很抽象的东西没有式子描述一下显然是下不了手的. 因为任何位置都以\(k\)为周期,所以我们只用关心一个周期,也就是以下数都在膜\(k\ ...
-
G711 G723 G729线路占多少带宽问题
G.711 G.711 也称为PCM(脉冲编码调制),是国际电信联盟订定出来的一套语音压缩标准,主要用于电话.它主要用脉冲编码调制对音频采样,采样率为8k每秒.它利用一个 64Kbps 未压缩 ...