跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
Wiki首页
Domoticz 中文站
Domoticz 论坛
Domoticz Github
随机页面
特殊页面
特殊页面
所有页面
分类
最近更改
Domoticz
搜索
搜索
登录
个人工具
登录
查看“Linux”的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
←
Linux
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
此页面描述了如何在Debian-based操作系统中编译/构建最新beta版Domoticz。<br> ''此过程已经成功测试于Ubuntu Server 14.04 LTS 以及 16.04 LTS'' ==安装依赖库== ''注意: 如果你使用Ubuntu 16.04或更新版本,推荐使用<code>apt</code>代替<code>apt-get</code>。''<br><br> 首先,升级你的系统:<br> sudo apt-get update sudo apt-get upgrade 如果你最近没有升级过,那么上面的命令可能会需要很长时间。<br> 然后为编译Domoticz安装开发工具和依赖库: <br> sudo apt-get install build-essential nano cmake git libboost-dev libboost-thread-dev libboost-system-dev sudo apt-get install libsqlite3-dev curl libcurl4-openssl-dev libssl-dev libusb-dev zlib1g-dev python3-dev <br> ===修复在Ubuntu 12.04 LTS及更早版本中可能出现的依赖性问题=== 以上安装在Ubuntu (12.04 LTS)及更早版本中可能会出现以下编译失败错误: <code>error: ‘class boost::asio::io_service’ has no member named ‘stopped’</code> 这种情况,你需要手动用更新版本的boost库替换apt-get命令安装的版本。请参考树莓派说明页 [https://www.domoticz.com/wiki/Installing_and_running_Domoticz_on_a_Raspberry_PI#Build_.26_Install_Boost_Libraries 点这里] ===CMake版本 === 要使用Python插件,cmake版本需要3.0.1或更新才能找到Python 3。查看系统中cmake的版本使用以下命令:<code>cmake --version</code>。如果版本过旧,cmake可能无法找到python 3. <br><br> 下载及构建3.2.2版cmake使用以下命令: <br> sudo apt-get install build-essential wget http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gz tar xf cmake-3.2.2.tar.gz cd cmake-3.2.2 ./configure make sudo make install ==编译/构建Domoticz库== '''注意: 如果你需要支持Z-Wave或Tellstick,你需要在编译Domoticz之前先增加对Z-Wave或Tellstick的支持。如何增加[[Linux#Add_support_for_Z-Wave|Z-Wave]]及[[Linux#Add_support_for_Tellstick|Tellstick]]支持请阅读以下部分。'''<br> 在低配电脑上进行编译可能需要10-15分钟。如果你的电脑拥有多核CPU,可以通过给'make'命令增加'-j'标识来使用更多核心,这样会快很多。四核CPU可以使用<code>make -j4</code>代替<code>make</code>。''<br><br> 通过以下命令获取最新Domoticz源代码并进行编译/构建: cd ~ git clone <nowiki>https://github.com/domoticz/domoticz.git</nowiki> domoticz cd domoticz cmake -DCMAKE_BUILD_TYPE=Release . make ''注意: 如果你有任何设备连接到USB口或串口,你需要在启动Domoticz之前先授权ttyUSB端口。根据[[Linux#Allow_non-root_user_to_access_ttyUSB*_ports|这些]]说明来操作。'' Some older Boost libraries on certain hardware can give you If linkage error. In that case you could try adding the flag '''-DCMAKE_EXE_LINKER_FLAGS=-lboost_atomic''' to the cmake command.<br><br> To start Domoticz type: ./domoticz When you open your browser at <nowiki>http://ip_of_your_machine:8080</nowiki>, you should be presented with the Domoticz web interface. For additional parameters of the Domoticz daemon, run: ./domoticz -h To start Domoticz automatically when the system boots follow [[Linux#Starting_Domoticz_automatically_when_the_system boots|these]] instructions. ==Allow non-root user to access ttyUSB* ports== If you don't plan on interfacing Domoticz with USB and/or serial devices, you can skip this step. By default (at least on Ubuntu) a non-root user has no permission to access the ttyUSB* ports. So if you have Domoticz running under a separate user ''(which is always a good idea to make the system more secure)'', Domoticz isn't allowed access to your RFXCOM for example. Here are two methods of doing it. For most people the first one by adding the user to the dialout goup is enough and by far the easiest. ===Adding the user to the dialout group=== This can be done by running the command below: sudo usermod -a -G dialout YOURUSERNAME ''(Where you replace YOURUSERNAME with the user that runs Domoticz.)''<br> ===Setting up an udev rule=== Alternatively you can setup (as root) a udev rule that matches the RFXCOM device. To find which attributes match your device use the command: udevadm info -a -p $(udevadm info -q path /dev/ttyUSB1) | less Where /dev/ttyUSB1 is the device. If you wish to run Domoticz under the YOURUSERNAME credentials, who is member of the YOURGROUPNAME group and your device has serial YOURSERIAL a suitable udev rule would be: SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{serial}=="YOURSERIAL", ATTRS{idProduct}=="6001", SYMLINK+="ttyUSB21", OWNER="YOURUSERNAME", GROUP="YOURGROUPNAME" Save it to a file under /etc/udev/rules.d/ with the .rules extention and run: service udev reload Unplug and replug the device and execute: ls -l /dev/ttyUSB* You should see something like crw-rw---- 1 domoticz domoticz 188, 1 Nov 10 15:27 /dev/ttyUSB1 lrwxrwxrwx 1 root root 7 Nov 10 15:27 /dev/ttyUSB21 -> ttyUSB1 The added SYMLINK+= creates an additional link to the device node. This is a static name that is useful when you have multiple usb-serial devices that go into your box. Use the static link in Domoticz. For more information on udev rules have a look here: http://www.reactivated.net/writing_udev_rules.html ==Starting Domoticz automatically when the system boots== ===Init.d Method=== To let Domoticz start automatically when the system boots ''(which is probably the case, as most people run it on a headless server)'', run the commands below, (You want to end up in ''/home/YOURUSERNAME/domoticz/'')<br> cd domoticz sudo cp domoticz.sh /etc/init.d sudo chmod +x /etc/init.d/domoticz.sh sudo update-rc.d domoticz.sh defaults Edit the startup script. sudo nano /etc/init.d/domoticz.sh The lines you usually need to change are USERNAME, DAEMON and DAEMON_ARGS USERNAME=yourusername DAEMON=/home/$USERNAME/domoticz/$NAME DAEMON_ARGS="-daemon -www 8080" *Change the USERNAME variable to the user you want domoticz to be run as. It's recommended to run domoticz as its own user and not as root, due to security reasons. *If you installed Domoticz in the USERNAME home directory <code>/home/yourusername/domoticz</code> you don't need to change the DAEMON variable. If you installed it in an alternate location for example <code>/usr/local/domoticz/</code> you should change DAEMON to <code>/usr/local/domoticz/$NAME</code> *If you want to use another web interface port change the '8080' in: <code>DAEMON_ARGS="-daemon www 8080"</code> to your own port. ''Note: To be able to use ports below 1024, for example the standard port for webbrowsing, 80, you need to run domoticz as the root user.''<br> If you want to see more arguments for DAEMON_ARGS run this in the domoticz directory. This is usually not needed. ./domoticz -h Domoticz will now start automatically when you reboot your machine. ====Manually controlling the Domoticz service==== This only works if you followed the above steps.<br> You can now start/stop/restart and check the status of domoticz with:<br> sudo /etc/init.d/domoticz.sh start sudo /etc/init.d/domoticz.sh stop sudo /etc/init.d/domoticz.sh restart sudo /etc/init.d/domoticz.sh status If your system supports it you can instead use:<br> sudo service domoticz.sh start sudo service domoticz.sh stop sudo service domoticz.sh restart sudo service domoticz.sh status ===Systemd Alternative === Open the systemd configuration file : vi /etc/systemd/system/domoticz.service [Unit] Description=domoticz_service [Service] User=domoticz Group=domoticz ExecStart=/home/domoticz/domoticz/domoticz -www 80 -sslwww 443 WorkingDirectory=/home/domoticz #give the right to open priviliged ports ExecStartPre=setcap 'cap_net_bind_service=+ep' /home/domoticz/domoticz/domoticz Restart=on-failure RestartSec=1m #StandardOutput=null [Install] WantedBy=multi-user.target ====Enable the service==== systemctl daemon-reload systemctl enable domoticz.service ====Start the service ==== systemctl start domoticz.service == Updating Domoticz == Once in a while, a new Domoticz version is released, and of course you want to update. You can do this with the commands below:<br> #First stop Domoticz with <code>sudo /etc/init.d/domoticz.sh stop</code> or <code>sudo service domoticz.sh stop</code><br> #Navigate to the directory where Domoticz is installed: <code>cd domoticz</code> (You want to end up in ''/home/YOURUSERNAME/domoticz/'')<br> #Pull the latest Domoticz code from Github: <code>git pull</code> #Compile/build the files that have been downloaded: <code>make && sudo /etc/init.d/domoticz.sh start</code> (Compiling will take a while, but the command will automatically start Domoticz again when compiling is done, so you can go to sleep or do something else in the meantime.)<br> If all went correctly, Domoticz should be updated to the latest version and should be running again automatically.<br><br> '''Attention:''' when you use [https://mmonit.com/monit/ Monit], be sure to disable it before doing the update process, otherwise after you have stopped Domoticz by hand yourself, it will get restarted automatically by Monit within a few minutes (because that is what is Monit should do normally).<br> Stopping Monit can be done by <code>sudo /etc/init.d/monit stop</code> and after updating it can be started again with <code>sudo /etc/init.d/monit start</code>.<br> You could also use this command: <code>make && sudo /etc/init.d/domoticz.sh start && sudo /etc/init.d/monit start</code> to update, start Domoticz & start Monit when updating is done. ===Script to update almost automatically=== For updating almost automatically, i made this script <syntaxhighlight lang="bash"> #! /bin/sh cd /home/YOURUSERNAME/domoticz/ \ && sudo /etc/init.d/monit stop \ && sudo /etc/init.d/domoticz.sh stop \ && git pull \ && make \ && sudo /etc/init.d/domoticz.sh start\ && sudo /etc/init.d/monit start </syntaxhighlight> Save it as ''domoupdater.sh'', give it executable rights (<code>chmod +x domoupdater.sh</code>) and call it by <code>sh /home/YOURUSERNAME/domoupdater.sh</code><br> It will change the current path to the Domoticz folder, stop Monit, stop Domoticz, pull binaries, compile, start Domoticz, start Monit again.<br> Very handy to run & go do something else.<br><br> In theory it can work automatically (weekly cronjob for example), however when running as a non-root user (which is the case in my situation), it will ask for the password of the user. But after you have provided the password (almost immediately after the script has started), it will continue without needing any further user input.<br> In theory it is possible to let it run fully automated, but i myself prefer a bit of feedback (watching afterwards if all went well). If you want to work around this sudo password asking, look [http://superuser.com/a/67766 here]. ==Add support for Z-Wave== Follow the steps below if you want to add support for Z-Wave devices in Domoticz. This needs to be done before compiling domoticz.<br> ===Install libudev-dev=== To install the specific dependencies issue the command: sudo apt-get install libudev-dev ===Compile OpenZWave=== The OpenZWave source directory needs to be in the same directory as the domoticz directory cd ~ <nowiki>git clone https://github.com/OpenZWave/open-zwave.git</nowiki> ln -s open-zwave open-zwave-read-only cd open-zwave make cd .. The directory should look something like this drwxrwxr-x 27 pi pi 4096 aug 12 19:59 domoticz drwxrwxr-x 11 pi pi 4096 aug 14 16:30 open-zwave lrwxrwxrwx 1 pi pi 10 aug 14 16:32 open-zwave-read-only -> open-zwave ===Updating OpenZWave=== To update the OpenZWave-part, run these commands:<br> cd open-zwave git pull make clean make cd .. ===Problems when compiling Domoticz with OpenZWave=== For people having trouble compiling with OpenZWave try with a fresh source.<br> cmake -USE_STATIC_OPENZWAVE -DCMAKE_BUILD_TYPE=Release CMakeLists.txt instead of cmake -DCMAKE_BUILD_TYPE=Release . when compiling the main Domoticz binary. For more information read this thread on the forum: [https://www.domoticz.com/forum/viewtopic.php?f=28&t=12625#p90568 Link]<br><br> ==Problems locating Python== Some users, particularly those on old operating systems see the following message when starting Domoticz: 2016-12-20 09:44:32.251 Failed dynamic library load, install the latest libpython3.x library that is available for your platform. this shows that, even though python3 may be on the system, the python library can not be located. This error will not stop Domoticz from starting but will mean that hardware supported by the Python Plugin Framework will not be available. To fix this, install the newest version of libpython3 for the platform. For example, RaspberryPi Jessie has python 3.4 on it but the library is not included. Executing: sudo apt-get install libpython3.4 should solve the issue. Note that python 3.4 is the earliest support version of python, where available later versions should always be used.<br> If the python 3 is installed but Make is not able to progress, try to add <br> set(Python_ADDITIONAL_VERSIONS 3.4) just before ''find_package(PythonLibs 3.4)'' in the CMakeLists.txt <br> If your platform does not have a compatible version, for example RaspberryPi Wheezy, then one can be built from source using: wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz tar -xvf Python-3.5.2.tar.xz cd Python-3.5.2 ./configure --enable-shared make sudo make install Don't miss the enabled-shared flag otherwise libpython will not be built. After building Python 3.5.x change CMakeLists.txt option(USE_PYTHON_PLUGINS "Use Python Plugins" YES) IF(USE_PYTHON_PLUGINS) set(Python_ADDITIONAL_VERSIONS 3.5) <---- add this line find_package(PythonLibs 3.5) <---- change version into 3.5 IF(PYTHONLIBS_FOUND) ==Add support for Tellstick== If you need support for Tellstick or Tellstic Duo you need to install telldus-core before compiling Domoticz. On Debian-based systems (For example Ubuntu and Raspbian) telldus-core can be installed by doing the following: echo "deb <nowiki>http://download.telldus.com/debian/</nowiki> stable main" | sudo tee /etc/apt/sources.list.d/telldus.list wget -q <nowiki>http://download.telldus.se/debian/telldus-public.key</nowiki> -O- | sudo apt-key add - sudo apt-get update sudo apt-get install libtelldus-core-dev [[Category:Domoticz]] [[Category:手册]] [[Category:安装]] [[Category:Linux]]
返回
Linux
。
开关有限宽度模式