环境要求

  操作系统

  Pyhotn要求

Pyhton依赖包安装

  创建Python虚拟环境(建议)

python -m venv /home/work/venv-osroom
或
python3 -m venv /home/work/venv-osroom



sudo apt-get install python3.6-venv



  安装依赖包

    source /home/work/venv-osroom/bin/activate
    # 或
    . /home/work/venv-osroom/bin/activate



pip install -r requirements.txt



  安装需求包异常情况

 Command "/xxx/venv-osroom/bin/python3 -u -c "import setuptools, tokenize;

 __file__='/tmp/pip-install-erphi6km/xxx/setup.py';

 f=getattr(tokenize, 'open', open)(__file__);
 code=f.read().replace('\r\n', '\n');f.close();
 exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-nhbhzs1a/install-record.txt
  --single-version-externally-managed --compile
  --install-headers /home/work/project/venv_osroom/include
 site/python3.5/xxxx" failed with error code 1 in /tmp/pip-install-erphi6km/xxxx/

  那么请尝试安装python-dev

   Ubuntu系统:

 # 不一定需要版本号

 sudo apt-get install python3.5-dev

   其他使用yum安装工具的Linux发行部系统:

  # 不一定需要版本号
 sudo yum install python3.5-devel



 Command "python setup.py egg_info" failed with error code 1 in ...

  那么请尝试安装 setuptools

 pip install --upgrade setuptools




配置数据库

  安装



  初始化配置



因为osroom源代码只把数据库配置文件db_config.py的sample文件上传到git,所以请先复制修改名称


 # 进入到apps/configs
 cp db_config_sample.py db_config.py




 DB_CONFIG = {
    "redis": {
        "password": "<Your password>",
        "host": [
            "127.0.0.1"
        ],
        "port": [
            "6379"
        ]
    },
    "mongodb": {
        "mongo_web": {
            "password": "<Your password>",
            "username": "work",
            "config": {
                "fsync": False,
                "replica_set": None
            },
            "host": [
                "127.0.0.1:27017"
            ],
            "dbname": "osr_web"
        },
        "mongo_user": {
            "password": "<Your password>",
            "username": "work",
            "config": {
                "fsync": False,
                "replica_set": None
            },
            "host": [
                "127.0.0.1:27017"
            ],
            "dbname": "osr_user"
        },
        "mongo_sys": {
            "password": "<Your password>",
            "username": "work",
            "config": {
                "fsync": False,
                "replica_set": None
            },
            "host": [
                "127.0.0.1:27017"
            ],
            "dbname": "osr_sys"
        }
    }
}




初始化第一个用户

(venv_osroom) work@osroom:~/project/osroom$ python start.py add_user
 * [User] add
Input username:root
Input email:hehecdirr@163.com
Input password(Password at least 8 characters):
[Warning]: 密码至少8个字符! 至少包含数字,字母,特殊字符中的任意两种

Input password(Password at least 8 characters):
 * Create root role...
Create root user role successfully
 * Create root user...
 * Create a root user role successfully
 * Create the average user role...
 * Create a generic user role successfully
The basic information is as follows
Username: root
Email: h*****irr@***.com
User role: Root
Password: #D****qw123
End




访问测试

使用自带的服务测试是否能够成功运行osroom(测试用, 实际部署产品不会使用该方式启动运行)

  启动OSROOM

# 如果需要外部访问,--host 为0.0.0.0 , --port 指定已开放的端口,默认5000
python start.py runserver --host 127.0.0.1 --port 5000



- 打开浏览器访问 127.0.0.1:5000