部署centos系统

前端之家收集整理的这篇文章主要介绍了部署centos系统前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
1 登陆系统

ssh -i /path/to/dymx102 -p 22 root@114.67.130.26

2 安装Python

一、添加epel


yum install epel-release


二、安装Python3.4,装完再升级

yum install python34

三、安装pip3

yum install python34-setuptools

easy_install-3.4 pip

之后就可以使用pip3了,如:


yum search python3 | grep devel

python34-devel.i686 : Libraries and header files needed for Python 3 development

python34-devel.x86_64 : Libraries and header files needed for Python 3

: development

yum install -y unzip zip

yuminstall-ygccgcc-c++

yum search python3 | grep devel


3 安装MysqL

#yum install MysqL

#yum install MysqL-server

#yum install MysqL-devel



MysqL -u root -p

service MysqLd restart

flush privileges;


4 安装jango

pip3 install django

5 安装rest-framework

pip install djangorestframework
pip install markdown       # Markdown support for the browsable API.
pip install django-filter  # Filtering support
6 安装 uwsgi

pip install uwsgi

配置uwsgi 文件如下。


[uwsgi]
socket = 127.0.0.1:8000
chdir = /workCode/CookBookServer/fsweb
wsgi-file = fsweb/wsgi.py
processes = 1
threads = 1

Nginx 配置


user root;#如果报403错误一定要加这个


server {

listen 8080;

server_name 192.168.1.117;


#charset koi8-r;


#access_log logs/host.access.log main;


location / {

include uwsgi_params;

uwsgi_pass 127.0.0.1:8000;

}

location /static {

alias /workCode/CookBookServer/fsweb/fsweb/static;

}

location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$ {

root /workCode/CookBookServer/fsweb/fsweb;

if (-f $request_filename) {

expires 1d;

break;

}




alias /workCode/CookBookServer/fsweb/fsweb/static;

}

location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$ {

root /workCode/CookBookServer/fsweb/fsweb;

if (-f $request_filename) {

expires 1d;

break;

}

}


location ~.*\.(js|css)$ {

root /workCode/jxnx/jxnxweb;

if (-f $request_filename) {

expires 1d;

break;

}

}


7 django 静态化


修改setting.py
STATIC_URL = '/static/' STATIC_ROOT = os.path.join(os.path.dirname(__file__),'static')
# STATICFILES_DIRS = (
    ('css',os.path.join(STATIC_ROOT,'css').replace('\\','/') ),('js','js').replace('\\',('images','images').replace('\\',('upload','upload').replace('\\',)



修改urls.py

添加

urlpatterns += staticfiles_urlpatterns()
原文链接:https://www.f2er.com/centos/375788.html

猜你在找的CentOS相关文章