Linux Django项目测试

步骤

django项目:

依赖包
[root@web01 ~]# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ openssl-devel zlib zlib-devel -y .安装python3
[root@web01 ~]# wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
[root@web01 ~]# tar xf Python-3.6..tgz
[root@web01 ~]# cd Python-3.6./
[root@web01 Python-3.6.]# ./configure --prefix=/usr/local/
[root@web01 Python-3.6.]# make && make install
[root@web01 Python-3.6.]# ./configure && make && make install .安装Django框架和uwsgi vim re.txt
asn1crypto==0.24.
beautifulsoup4==4.6.
bs4==0.0.
certifi==2018.4.
cffi==1.11.
chardet==3.0.
Click==7.0
cryptography==2.3.
Django==1.11.
Flask==1.0.
Flask-Cors==3.0.
gevent==1.3.
greenlet==0.4.
idna==2.7
ItsDangerous==1.1.
Jinja2==2.10
lxml==4.2.
MarkupSafe==1.0
numpy==1.15.
Pillow==5.3.
pycparser==2.18
PyMySQL==0.9.
pytz==2018.7
requests==2.19.
selenium==3.141.
six==1.11.
urllib3==1.23
virtualenv==16.1.
Werkzeug==0.14.
wordcloud==1.5. pip3 install -i https://pypi.doubanio.com/simple/ -r re.txt
pip3 install -i https://pypi.doubanio.com/simple/ uwsgi .测试uwsgi是否正常,新建 test.py文件,内容如下:
[root@web01 ~]# vim test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello Django"] #然后在终端运行:
.cd 到test.py目录
uwsgi --http : --wsgi-file test.py & .测试django是否正常,运行:
[root@web01 ~]# django-admin.py startproject demosite
[root@web01 ~]# cd demosite
[root@web01 demosite]# vim settings.py
修改ALLOWED_HOSTS = ['*']
[root@web01 demosite]# python3 manage.py runserver 0.0.0.0:
在浏览器内输入:http://服务器ip:8002,检查django是否运行正常。 .配置uwsgi
[root@web01 demosite]# vim /root/demosite/uwsgi.ini
[uwsgi]
socket = 127.0.0.1:
master = true
workers = #多少个并发处理
max-requests = #请求数响应
buffer-size = #内存使用
pidfile = /run/uwsgi.pid
daemonize = /var/log/uwsgi.log uwsgi --ini /root/demosite/uwsgi.ini & .配置Nginx
[root@web01 demosite]# vim /etc/nginx/conf.d/py.conf
server {
listen ;
server_name 10.0.0.100;
client_max_body_size 100M; location / {
index index.html;
include uwsgi_params;
uwsgi_pass 127.0.0.1:;
uwsgi_param UWSGI_SCRIPT demosite.wsgi;
uwsgi_param UWSGI_CHDIR /root/demosite;
}
} 重启nginx
上一篇:javasrcipt日期一些方法和格式转化


下一篇:快速熟悉python 下使用mysql(MySQLdb)