Ubuntu服务器部署

1. 开发环境配置

1.1 Python/Python3安装

  • python3 install

ubuntu14.04 升级python3.4到3.6
Ubuntu 16.04 安装 python3.6 环境并设置为默认

  • pip
1
2
3
4
5
6
7
8
9
10
11
# 1. 更新系统包
sudo apt-get update
sudo apt-get upgrade
# 2. 安装Pip
//sudo apt-get install python-pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
# 3. 检查 pip 是否安装成功
pip -V
# python3 pip 升级命令
pip3 install --upgrade pip
  • pip version >= 10
    ImportError: cannot import name ‘main‘
1
2
3
4
5
6
7
8
9
10
11
12
13
cd /usr/bin
sudo vi pip
```
![-w960](media/15366330895306.png)
edit the file content like the picture then press and input:
```esc```
```:wq```

### 1.2 Git Repository for Ubuntu
##### git install
```shell
sudo apt-get install git
git --version
create the repository directory for git
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
mkdir projectGitlab/
```
##### git configure and ssh key generate

```shell
git config -- global user.name "winkyqin"
git config -- global user.email "winkyqin@163.com"
git config -- list
# ssh key generate
ssh-keygen -t rsa -C "winkyqin@163.com"
# into the directory .ssh/ to get ssh key detail
# get the ssh key string detail
ls ~ .ssh
cat id_rsa.pub
# copy the ssh key to paste
```

##### git repository clone
```shell
git clone “xxx.git”

1.3 ubuntu安装常用数据库(mongoDB, mysql)

1.3.1 mysql for ubuntu

sudo apt-get install mysql-server

sudo apt-get install mysql-client

sudo apt-get install libmysqlclient-dev

sudo netstat -tap | grep mysql

msyql -u root -p

show database 

show tables 
mysql数据库使用root账号创建新用户
    # -- 创建用户设置
    create user 'chaininfo_dev'@'%' identified by 'chaininfo_dev';
    # -- 创建数据库
    create database database_chain_news DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    # -- 为用户赋权限
    grant all privileges on database_chain_news.* to 'chaininfo_dev'@'%' identified by 'chaininfo_dev';
    grant all privileges on database_chain_news.* to 'chaininfo_dev'@'localhost' identified by 'chaininfo_dev';
    flush privileges;
    
    

1.3.2 mongodb for ubuntu install

sudo apt-get install mongodb

(install no response input before the line above :
  
    sudo apt-get update
)

    # check the mongodb is start or not  
    gprep mongo -l
    
    # where the directory is the mongo location 
    locate mongo
    
    # mongodb uninstall 
    sudo apt-get --purge remove mongodb mongodb-clients mongodb-server
    

1.4 Scrapy install

1
2
3
4
5
6
7
8
9
10
#dependency lib
sudo apt-get install libssl-dev
pip install pyopenssl --upgrade
#or
pip3 install pyopenssl --upgrade

#install scrapy
pip install scrapy
#or
pip3 install scrapy
  • UserWarning: You do not have a working installation of the service_identity module: ‘cannot import name ‘opentype’’.
1
pip3 install --user service_identity --force --upgrade
  • error: Failed building wheel for twisted
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    sudo apt update
    sudo apt install python3.6-dev
    ```
    * [add-apt-repositoryModuleNotFoundError: No module named 'apt_pkg'](https://qiita.com/miyagaw61/items/665616d769f74158f1a1)
    **Traceback (most recent call last):
    File "/usr/bin/apt-add-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
    File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in <module>
    import apt_pkg
    ModuleNotFoundError: No module named 'apt_pkg'**

    ```shell
    cd /usr/lib/python3/dist-packages
    sudo ln -s apt_pkg.cpython-{35m,36m}-x86_64-linux-gnu.so
    ```

    ### 1.4 scrapyd 部署
    ### 1.5 java项目部署
    #### 1.5.1 安装JDK8
    [INSTALL ORACLE JAVA8/jdk8 IN UBUNTU OR LINUX MINT VIA PPA REPOSITORY](http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html)
    ```shell
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java8-installer

1.5.2 安装Tomcat8

Install Tomcat 8 on ubuntu 16.04 Server

1.5 mongodb 添加远程访问配置

Ubuntu的add-apt-repository: command not found

1
sudo apt-get install software-properties-common python-software-properties

Ubuntu环境下python配置

完全卸载python for Ubuntu 14.04
Python3以上版本安装sqlite3的解决方案
Python3安装sqlite3
Ubuntu中Python3找不到_sqlite3模块