由他 - 天猫精灵
type: channel
link: https://xiaoxin.wang/index.php/tag/%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5/
items: 天猫精灵打开电脑 语音控制电脑

天猫精灵打开电脑 语音控制电脑
type: item
date: 2020-11-04T19:45:00+08:00
description: “天猫精灵”“哎，我在！”“打开电脑”上了一天班，回到家就想静静的玩会游戏，吼一句天猫精灵，立马帮你开机，多么舒服~装x~的体验。然而现实是骨感的，精灵无此功能，网上有人让弄个智能插排+通电自启，这明显无法满足我们的高逼格。[TOC]前言准备工作：外部网络可以访问的一个接口，用于逻辑处理，如果你的服务器外网不能访问，就不要整php+nginx，别想着在虚拟机里面搭个，没用！电脑有外网ip，可以外部魔术包唤醒，网卡方面需要支持，一般网卡都支持博主搭建的php+nginx可以提供给有兴趣的小伙伴PHP + Nginx 整合~CentOS8.0~安装Nginxdnf install -y nginx #安装nginx cd /etc/nginx ## 备份nginx.conf cp nginx.conf nginx.conf_`date +%Y%m%d` ## grep -Ev '#|^%|^$' nginx.conf_`date +%Y%m%d` > nginx.conf ## 新增index.php用于测试 echo -e "<?php \nphpinfo();\n?>" > /usr/share/nginx/html/index.php ## 赋权 chown nginx:nginx -R /usr/share/nginx/html vi /etc/nginx/nginx.conf ## 参照下面conf进行修改 user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; root /usr/share/nginx/html; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; server { listen 8765 default_server; listen [::]:8765 default_server; server_name _; include /etc/nginx/default.d/*.conf; location / { } location ~ \.php$ { fastcgi_pass unix:/run/php-fpm/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }安装PHPdnf install -y php #安装php dnf install -y php-json #安装php-json启动服务## 服务启动php和nginx systemctl start nginx systemctl start php-fpm ## 服务器检查 # ps -ef|grep nginx # ps -ef|grep php-fpm ## 停止命令 # systemctl stop nginx # systemctl stop php-fpm ## 重启命令 # systemctl restart nginx # systemctl restart php-fpm整合结果检查看到这个页面说明整合完成编写wol.php用于处理逻辑cd /usr/share…