ECS

1、第一步

下载Xshell

2、第二步:安装图形化界面

更新软件库:apt-get update

升级软件:apt-get upgrade

安装ubuntu桌面系统:apt-get install ubuntu-desktop

修改root权限:cd~ cd /usr/share/lightdm/lightdm.conf.d   chmod 777 50-ubuntu.conf   vi 50-ubuntu.conf

# 文件 /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
 
# 修改前
[Seat:*]
user-session=ubuntu
 
# 修改后
[Seat:*]
user-session=ubuntu
greeter-show-manual-login=true
allow-guest=false

去掉警告:cd ~   vi .profile

# 文件 /root/.profile
 
# 文件修改前
  # ~/.profile: executed by Bourne-compatible login shells.
 
  if [ "$BASH" ]; then
   if [ -f ~/.bashrc ]; then
    . ~/.bashrc
   fi
  fi
  mesg n || true
 
# 文件修改后
  # ~/.profile: executed by Bourne-compatible login shells.
 
  if [ "$BASH" ]; then
   if [ -f ~/.bashrc ]; then
    . ~/.bashrc
   fi
  fi
  tty -s && mesg n || true

重启服务器:reboot

3、软件安装路径

下载的软件存放位置/var/cache/apt/archives

安装后软件默认位置/usr/share

可执行文件位置/usr/bin

配置文件位置/etc

lib文件位置/usr/lib

4、第三步:虚拟环境(virtualenv)的安装

安装virtualenv:sudo pip install virtualenv

        sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pbr

        sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --no-deps stevedore

          sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --no-deps virtualenvwrapper

在home下创建虚拟环境安装目录:cd ../home  mkdir   .virtualenvs

在root下为virtualenv配置环境变量:vi  .bashrc

                  在末尾添加两行代码:export WORKON_HOME=$HOME/.virtualenvs # 所有虚拟环境存储的目录

                            source /usr/local/bin/virtualenvwrapper.sh

在root下生效配置文件:source .bashrc

创建虚拟环境:mkvirtualenv -p /usr/bin/python3.5 Name(Name为虚拟环境名字)(workon xx #进入虚拟环境XX   deactivate #退出虚拟环境)

4、第三步:Nginx

安装:sudo apt-get install nginx

启动Nginx:/etc/init.d/nginx start #启动

                   /etc/init.d/nginx stop #关闭

        /etc/init.d/nginx restart#重启

查看端口:netstat -ntlp

tcp   0 0 0.0.0.0:80   0.0.0.0:*   LISTEN   4187/nginx -g daemo
tcp6   0 0 :::80        :::*      LISTEN   4187/nginx -g daemo

配置nginx:(详解http://www.zsythink.net/archives/3186)

cd /etc/nginx/sites-available  vi default

修改前:
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }
}
修改后:
server {
    listen 8080 default_server;
    listen [::]:8080 default_server;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

    location /static {   #http:xxx.xxx.xxx.xxx:8080/static/img.jpg ==> /home/static/img.jpg
        root /home;
    }
}
        

重启nginx:/etc/init.d/nginx restart

查看端口:netstat -ntlp

tcp   0 0 0.0.0.0:8080   0.0.0.0:*   LISTEN   4187/nginx -g daemo
tcp6   0 0 :::8080        :::*      LISTEN   4187/nginx -g daemo

浏览器访问http:xxx.xxx.xxx.xxx:8080/static/img.jpg,出现图片ig.jpg

5、第四步:uWSGI

在虚拟环境中安装:workon

         apt-get install build-essential python

           apt-get install build-essential libssl-dev libffi-dev python-dev

           sudo pip install uwsgi

配置uWSGI:

6、第六步:Django

安装:pip3 install Django==2.2

7、第七步:Mysql

安装:sudo apt-get update

     sudo apt-get install mysql-server 

     sudo apt-get install mysql-client

导入数据库:mysql -u root -p

        mysql->creat database Name

      mysql->use Name

      mysql->source /home/path···/Name.sql

mysql配置:文件 /etc/mysql/mysql.conf.d/mysqld.cnf

        注释 bind-address = 127.0.0.1  ==>  #bind-address = 127.0.0.1

8、第八步:搭建项目

创建项目:django-admin startproject Work

     django-admin startapp myapp

修改settings.py:ALLOWED_HOSTS = [] 改为 ALLOWED_HOSTS = ['xxx.xxx.xxx'] #公网ip

        DEBUG=False

posted @ 2020-04-14 14:28  上官幺樱花  阅读(274)  评论(0)    收藏  举报