代码拉取完成,页面将自动刷新
支持的环境:
1.php7以上
2.mysql5.6以上
git clone https://gitee.com/huchaoran/muchTemplate.git
composer update
cp .env.example .env
php artisan key:generate
php artisan migrate
php artisan db:seed
php artisan serve
http://localhost:8000/admin
,账号和密码都是admin
这里使用的是laravel框架,基于laravel的组件larvels(laravel+swoole)
框架内运行 php bin/laravels start
并配置nginx.conf
include引入一个新的conf文件,为aa.conf
gzip on;
gzip_min_length 1024;
gzip_comp_level 2;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml;
gzip_vary on;
gzip_disable "msie6";
#nginx upstream用于负载均衡
upstream swoole {
# 通过 IP:Port 连接
#多服务器负载均衡(没有服务器,拿端口来顶替),模拟多个服务器
server 127.0.0.1:5200 weight=5 max_fails=3 fail_timeout=5s;#可设置参数请求
server 127.0.0.1:5201 weight=5 max_fails=3 fail_timeout=5s;#可设置参数请求
# 通过 UnixSocket Stream 连接,小诀窍:将socket文件放在/dev/shm目录下,可获得更好的性能
#server unix:/yourpath/laravel-s-test/storage/laravels.sock weight=5 max_fails=3 fail_timeout=30s;
#server 192.168.1.1:5200 weight=3 max_fails=3 fail_timeout=30s;
#server 192.168.1.2:5200 backup;
keepalive 16;
}
server {
listen 80;
client_max_body_size 512m;
server_name aa.com;
# root /Users/huchaoran/Desktop/所有项目/muchTemplate/public;
autoindex off;
index index.html index.php;
location / {
# try_files $uri $uri/ /index.php?$query_string;
try_files $uri @laravels;
}
# location ~ \.php(.*)$ {
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param PATH_INFO $fastcgi_path_info;
# fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
# include fastcgi_params;
# }
# location ~ /\.ht {
# deny all;
# }
# if (!-e $request_filename) {
# rewrite ^/(.*)$ /index.php/$1;
# }
location @laravels {
# proxy_connect_timeout 60s;
# proxy_send_timeout 60s;
# proxy_read_timeout 120s;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header Server-Protocol $server_protocol;
proxy_set_header Server-Name $server_name;
proxy_set_header Server-Addr $server_addr;
proxy_set_header Server-Port $server_port;
access_log /Users/huchaoran/Desktop/所有项目/muchTemplate/access.log;
# “swoole”是指上面的upstream定义的swoole
proxy_pass http://swoole;
}
}
配置hosts文件指向到aa.com
域名,并重载nginx服务器配置,通过http://aa.com
域名访问
php artisan timer
即可运行,文件在App\Console\Commands\Timer.php
App\Services\WebSocket.php
,案例在App\Http\PushController.php
App\Http\Controllers\TaskWorkController.php
,接口在routes\api.php
中的taskWork
,通过http://XXXX.com/api/taskWork
进行触发此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。