zoukankan      html  css  js  c++  java
  • linux安装Python和Django以及防火墙的原因没连上,明天开始看看linux上的django开发以及看看阿里云的连接问题

    linux安装Python和Django

     

    首先目录结构看一下

    。在opt里安软件。

    image-20200306204331452

    如果pip安装,请用豆瓣云清华大学的快
    pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple django==1.11.9

     

    1.安装python3

    先编译环境:

    yum install gcc patch libffi-devel python-devel  zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y

    下载,解压安装源码包 下载地址:https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz

    wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tar.xz

    xz -d Python-3.6.7.tar.xz
    tar -xf Python-3.6.7.tar

    tar xvcf Python-3.6.7.tgz

    2.配置环境并安装

    ./configure --prefix=/opt/python
    make && make install

    3在环境中写入并执行

    在/etc/profile最后一行添加
    export PATH=$PATH:/opt/python/bin
    然后
    source /etc/profile

    #python快捷path就被改了

    这个是手动编译。复杂些。

    还有简单的从《djanog 李阳的书上》 也得配置编译环境,然后一步wget ...python36 pip3 ,可能吧

    2.安装django1.11

    pip3 install django==1.11
    #创建django项目mysite
    django-admin startproject mysite
    #创建app01   django-admin startproject django_test
    python3 manage.py startapp app01

    mysite/settings.py

    #settings.py设置
    ALLOWED_HOSTS = ['*']
    install app01

    mysite/urls.py

    from app01 import views
    urlpatterns = [
       url(r'^admin/', admin.site.urls),
       url(r'^hello_django/', views.hello),
    ]

    app01/views.py

    from django.shortcuts import render,HttpResponse

    # Create your views here.
    def hello(request):
       print('request is :',request)
       return HttpResponse('django is ok ')

     

     

    Django开启了,我的windows系统不能访问的问题:
    百思不得。原来是linux防火墙开着。
    1.关闭防火墙
    systemctl status firewalld #查看防火墙状态
    systemctl stop firewalld   #关闭防火墙
    systemctl disable firewalld#关闭防火墙开机启动systemctl is-enabled firewalld.service#检查防火墙是否启动

    都关了就好了。

     

  • 相关阅读:
    oracle 数据库服务名怎么查
    vmware vsphere 6.5
    vSphere虚拟化之ESXi的安装及部署
    ArcMap中无法添加ArcGIS Online底图的诊断方法
    ArcGIS中字段计算器(高级计算VBScript、Python)
    Bad habits : Putting NOLOCK everywhere
    Understanding the Impact of NOLOCK and WITH NOLOCK Table Hints in SQL Server
    with(nolock) or (nolock)
    What is “with (nolock)” in SQL Server?
    Changing SQL Server Collation After Installation
  • 原文地址:https://www.cnblogs.com/Doner/p/12431360.html
Copyright © 2011-2022 走看看