# 我的Ubuntu上自带的python3.5,所以安装一下 python3.6
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

装完可以检查一下版本

>> python3 -V

# install pip3

sudo apt install python3-pip

# install Django
sudo pip3 install Django

装完可以检查一下django版本

>> python3

>> import django

>> django.VERSION
 
 

# framework 一般要用到Restful API,需要安装
sudo -H pip3 install djangorestframework
sudo -H pip3 install markdown
sudo -H pip3 install django-filter

# 下面装mysql
sudo apt-get -y install python3-mysqldb
sudo apt-get -y install mysql-server mysql-client
sudo apt-get -y install libmysqlclient-dev
sudo -H pip3 install mysqlclient
sudo -H apt-get -y install python3-pymysql
sudo pip3 install requests

# 配置数据库mysql command
connect: mysql -u root -p
create database: create database 数据库名 default charset=utf8;
create user: create user 你的用户名 identified by '你的密码';
grant: grant all privileges on 数据库名.* to 你的用户名@'%' identified by '你的密码';
show grants for '数据库名';

以下配置apache

# Install Apache & WSGI, disable unneeded VirtualHosts
sudo apt-get update
sudo apt-get -y install apache2 libapache2-mod-wsgi-py3
sudo a2enmod wsgi
sudo service apache2 restart
sudo a2dissite 000-default
sudo service apache2 restart

# Add Project User and Add Yourself to His Group
sudo adduser lmy
sudo usermod --lock lmy
sudo mkdir /home/lmy/grouped
sudo chmod u=rwx,g=srwx,o=x /home/lmy/grouped
sudo chown -R lmy.lmy /home/lmy/

 

sudo find /home/lmy/grouped/ -type f -exec chmod -v ug=rw {} \;
sudo find /home/lmy/grouped/ -type d -exec chmod -v u=rwx,g=srwx {} \;

sudo adduser $(whoami) lmy
newgrp lmy

# Create a New VirtualHost for WSGI Django
sudoedit /etc/apache2/sites-available/项目名称.conf

<VirtualHost *:80>
ServerName www.example.com

WSGIDaemonProcess 用户名 user=用户名 group=用户名 threads=5 python-path="/home/用户名/grouped/项目名/"
WSGIScriptAlias / /home/用户名/grouped/项目名/项目名/wsgi.py
<Directory /home/用户名/grouped/项目名/>
WSGIProcessGroup 用户名
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Require all granted
</Directory>
</VirtualHost>

sudo a2ensite 项目名
sudo service apache2 restart

以上,就已经配置完了

如果服务器遇到500错误

cat /var/log/apache2/error.log

或 tail -f /var/log/apache2/error.log

# 初始化数据库
sudo -H python3 manage.py makemigrations
sudo -H python3 manage.py migrate

ref:

http://terokarvinen.com/2017/django-on-apache-with-python-3-on-ubuntu-16-04

https://zxtcode.com/main/37/

http://www.django-rest-framework.org/

https://docs.djangoproject.com/en/1.11/howto/static-files/

http://www.cnblogs.com/gide/p/6179975.html

http://www.runoob.com/django/django-first-app.html

Ubuntu配置Django+ Apache2+ mysql的更多相关文章

  1. ubuntu上安装apache2+mysql+php5-fpm(PHP5 - FastCGI Process Manager)

    1: 安装mysql apt-get install mysql-server mysql-client 安装过程中会被问到设置mysql root的密码     New password for t ...

  2. ubuntu配置django

    安装 安装Apache sudo apt-get install apache2 安装Django 下载Django 安装mod_wsgi sudo apt-get install libapache ...

  3. ubuntu 配置 django

    安装 安装Apache sudo apt-get install apache2 安装Django 下载Django 安装mod_wsgi sudo apt-get install libapache ...

  4. ubuntu 配置nginx+php+mysql 遇到的一些问题

    /* 公司内网打算配置一台ubuntu为主机的测试服务器.刚好手头有一个昂达的主机,装的windows 声音又大,还不如直接装ubuntu .声音又小,还占用资源少. */ 刚开始安装php5 结果提 ...

  5. win10环境下配置django+Apache2.4.38+python3.6项目

    1.)Apache-2.4.38-win64-vc15下载地址: https://www.apachelounge.com/download/VC14/ 解压httpd-2.4.38-win64-VC ...

  6. django 的mysql数据配置

    原地址:http://blog.csdn.net/gamesofsailing/article/details/21465327 在成功安装python-mysql后,开始配置django的mysql ...

  7. ubuntu环境下使用apt-get配置apache+php+mysql

    主要步骤:1,安装apachesudo apt-get install apache2sudo /etc/init.d/apache2 restart2,安装phpsudo apt-get insta ...

  8. ubuntu 安装Django MySQL

    1.安装步骤 我到公司的第一件事就是安装ubuntu系统,虽然我以前没有接触过ubuntu系统不过在网上找了一下资料感觉和安装其它系统也差不多(注:我是安装带图形界面的那个版本),还是比较轻松的搞定了 ...

  9. Ubuntu 15.04 安装配置Apache和mysql的方法

    前 言 上篇海面特效的博文结尾提到了SideFX开发的HQueue分布式集群,配置HQueue首先需要安装mysql,所以今天先分享一下如何在Ubuntu系统中安装mysql和Apache: Ubun ...

随机推荐

  1. gdb的多线程调试

    info threads 可以查看当前进程有哪些线程 thread ID 可以切换到线程ID bt 查看当前线程堆栈 set scheduler-locking on多线程调试过程中, 线程会来回切换 ...

  2. Python 串口通信操作

    下载  pyserial包 https://pypi.python.org/packages/source/p/pyserial/pyserial-2.7.tar.gz#md5=794506184df ...

  3. 简单使用Unity导航系统(小白之路)

    1.介绍 NavMesh:是一种根据场景中几何图像创建出来的3D网格.它会使导航和寻路变得很容易. 简单来说,NavMesh是一种我们在游戏世界中,可以让游戏角色在其表面行走并且导航的平面. 2.注意 ...

  4. 数据库服务器---Tps

    事务处理系统:Transactionprocessingsystems(TPS) 提高事务处理效率与保证其正确性 在数据(信息)发生处将它们记录下来 通过OLTP产生新的信息 将信息保存到数据库中供其 ...

  5. js 数组去重复的方法

    数组去重复是js中常用的方法,归纳了四种如下: 1. for + indexOf  去重复 var arr = [3,5,5,4,1,1,2,3,7,2,5]; var target = []; fo ...

  6. 网页设计——7.css的入门

    css的介绍 div+css的设计: 什么是div? 理解示意图: 实例操作: 这里就要用到div+css的布局操作 先写一个html文件,见下图: <html><head>& ...

  7. dict.get()和dict['key']的区别

    a ={'name':'xxxx'} 1.a.get('gender') :如果不存在则返回一个默认值,如果设置了则返回默认的值,没有设置就返回None 2.a['gender'] :只能获取存在的值 ...

  8. 是否是有效的dom节点--轮子代码

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...

  9. 移动 云MAS 发短信 .net HTTP 请求

    本人开发移动云MAS .net Http 请求  代码如下 using Newtonsoft.Json.Linq; using System; using System.Collections.Gen ...

  10. POJ 1861:Network(最小生成树&amp;&amp;kruskal)

    Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13266   Accepted: 5123   Specia ...