本帖最后由 jingqinglee 于 2020-8-23 10:21 编辑
整理了一个VMware、esxi虚拟机安装CentOS、Redhat通过Python部署homeassistant的基本步骤。适用于有软路由的同志比较合适
系统安装不做介绍,本次采用的为CentOS8-minimal最小化安装
纯字 无图 慎入
Centos8-minimail 1、yum update -y 2、安装必须组件 yum install libffi-devel gcc openssl-devel make wgetnet-tools lrzsz sysstat gcc zlib* gcc-c++ systemd-devel avahi -y 3、建立Python目录 mkdir/usr/local/bin/python3 4、下载Python包并解压安装 tar -zxvfPython-3.8.0.tgz cdPython-3.8.0 ./configure --with-ssl --prefix=/usr/local/bin/python3 make make install
建立软连接: rm -rf /usr/bin/python3 ln -s/usr/local/bin/python3/bin/python3 /usr/bin/python3 检查版本是否生效 python3 -V
5、必要的安全设置 防火墙打开端口: firewall-cmd--add-port=8123/tcp --permanent 关闭selinux:(不关闭会导致homeassistant进程通过systemctl启动失败) vi /etc/selinux/config 修改 SELINUX=disabled
安装homeassistant useradd -rmhomeassistant cd /srv mkdir homeassistant chownhomeassistant:homeassistant homeassistant su -s /bin/bashhomeassistant cd /srv/homeassistant python3 -m venvhomeassistant_venv source /srv/homeassistant/homeassistant_venv/bin/activate pip install --upgrade pip pip install homeassistant Hass(测试启动成功后Ctrl+c结束掉进程通过systemctl进行启动关闭测试)
homeassistant更新 su -s /bin/bashhomeassistant cd/srv/homeassistant python3 -m venvhomeassistant_venv source/srv/homeassistant/homeassistant_venv/bin/activate pip install--upgrade homeassistant
安装特定版本的 pip installhomeassistant==0.XX.X
设置systemctl启动相关 [Unit] Description=HomeAssistant #After=network.target #After=network-online.target [Service] Type=simple User=homeassistant Environment=PATH="$VIRTUAL_ENV/binPATH" ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass-c "/home/homeassistant/.homeassistant" [Install] WantedBy=multi-user.target
刷新systemctl systemctl --system daemon-reload 设置开机启动 启动homeassistant 停止homeassistant 查看homeassistant运行状态
|