Laravel 8.x(LaraBBS) 部署至 阿里云 ECS,基于 MySQL、Redis、Supervisor、Crontab 实现

1、Laravel 8.x(LaraBBS) 在本地开发环境已经实现。如图1

Laravel 8.x(LaraBBS) 在本地开发环境已经实现

图1

2、基于 Xshell 7,登录至 阿里云 ECS。查看操作系统版本。列出所有版本信息,执行命令:lsb_release -a。版本:CentOS 7.7。如图2

基于 Xshell 7,登录至 阿里云 ECS。查看操作系统版本。列出所有版本信息,执行命令:lsb_release -a。版本:CentOS 7.7

图2

[root@iZ23wv7v5ggZ ~]# lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.7.1908 (Core)
Release:	7.7.1908
Codename:	Core

3、参考网址:https://oneinstack.com/ ,基于 OneinStack 来部署。由于此 ECS 中之前已经基于 OneinStack 部署过网站。因此,一些步骤会跳过。事先将云盘创建快照备份,以防万一造成数据损失。如图3

参考网址:https://oneinstack.com/ ,基于 OneinStack 来部署。由于此 ECS 中之前已经基于 OneinStack 部署过网站。因此,一些步骤会跳过。事先将云盘创建快照备份,以防万一造成数据损失

图3

4、建议在快照进度等于 100%,即状态成功后,才开始操作 ECS。如图4

建议在快照进度等于 100%,即状态成功后,才开始操作 ECS

图4

5、在 ECS 上已经部署成功的网址:https://www.shuijingwanwq.com/ 。参考网址:https://www.shuijingwanwq.com/2016/04/25/1050/

6、目录:/root/oneinstack 早已经存在。如图5

目录:/root/oneinstack 早已经存在

图5

7、查看当前的 PHP 版本:7.4。如图6

查看当前的 PHP 版本:7.4

图6

[root@iZ23wv7v5ggZ oneinstack]# php -v
PHP 7.4.0 (cli) (built: Dec  5 2019 11:56:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.0, Copyright (c), by Zend Technologies

8、升级脚本工具,不影响正在运行环境。执行命令:/upgrade.sh –oneinstack。如图7

升级脚本工具,不影响正在运行环境。执行命令:/upgrade.sh --oneinstack。

图7

[root@iZ23wv7v5ggZ oneinstack]# ./upgrade.sh --oneinstack

#######################################################################
#       OneinStack for CentOS/RedHat 6+ Debian 8+ and Ubuntu 14+      #
#              Upgrade Software versions for OneinStack               #
#       For more information please visit https://oneinstack.com      #
#######################################################################

Congratulations! OneinStack upgrade successful! 

[root@iZ23wv7v5ggZ oneinstack]# 

9、参考网址:https://oneinstack.com/install/ ,添加虚拟主机,执行命令:./vhost.sh。报错:Error: Create Let’s Encrypt SSL Certificate failed! 。原因在于不存在相应的 DNS 记录。如图8

参考网址:https://oneinstack.com/install/ ,添加虚拟主机,执行命令:./vhost.sh。报错:Error: Create Let's Encrypt SSL Certificate failed! 。原因在于不存在相应的 DNS 记录

图8

[root@iZ23wv7v5ggZ oneinstack]# ./vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 8+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
	1. Use HTTP Only
	2. Use your own SSL Certificate and Key
	3. Use Let's Encrypt to Create SSL Certificate and Key
	q. Exit
Please input the correct option: 3

Please input domain(example: www.example.com): fanxiapp-wangqiang-larabbs.shuijingwanwq.com
domain=fanxiapp-wangqiang-larabbs.shuijingwanwq.com

Please input the directory for the domain:fanxiapp-wangqiang-larabbs.shuijingwanwq.com :
(Default directory: /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com): 
Virtual Host Directory=/data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: n

Do you want to redirect all HTTP requests to HTTPS? [y/n]: y

Please enter your email: shuijingwanwq@163.com

[Fri Jan  7 10:36:05 CST 2022] Unknown parameter : -m

Let's Encrypt Verify error! DNS problem: NXDOMAIN looking up A for fanxiapp-wangqiang-larabbs.shuijingwanwq.com
[Fri Jan  7 10:36:10 CST 2022] Creating domain key
[Fri Jan  7 10:36:10 CST 2022] The domain key is here: /root/.acme.sh/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.key
[Fri Jan  7 10:36:10 CST 2022] Single domain='fanxiapp-wangqiang-larabbs.shuijingwanwq.com'
[Fri Jan  7 10:36:10 CST 2022] Getting domain auth token for each domain
[Fri Jan  7 10:36:14 CST 2022] Getting webroot for domain='fanxiapp-wangqiang-larabbs.shuijingwanwq.com'
[Fri Jan  7 10:36:15 CST 2022] Verifying: fanxiapp-wangqiang-larabbs.shuijingwanwq.com
[Fri Jan  7 10:36:19 CST 2022] fanxiapp-wangqiang-larabbs.shuijingwanwq.com:Verify error:DNS problem: NXDOMAIN looking up A for fanxiapp-wangqiang-larabbs.shuijingwanwq.com - check that a DNS record exists for this domain
[Fri Jan  7 10:36:19 CST 2022] Please add '--debug' or '--log' to check more details.
[Fri Jan  7 10:36:19 CST 2022] See: https://github.com/Neilpang/acme.sh/wiki/How-to-debug-acme.sh
Error: Create Let's Encrypt SSL Certificate failed! 
[root@iZ23wv7v5ggZ oneinstack]# 

10、检查此域是否存在 DNS 记录。先在 DNS 中添加相应的域名:fanxiapp-wangqiang-larabbs.shuijingwanwq.com 。如图9

检查此域是否存在 DNS 记录。先在 DNS 中添加相应的域名:fanxiapp-wangqiang-larabbs.shuijingwanwq.com

图9

11、再次执行命令:./vhost.sh。添加虚拟主机成功。如图10

再次执行命令:./vhost.sh。添加虚拟主机成功

图10

[root@iZ23wv7v5ggZ oneinstack]# ./vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 8+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
	1. Use HTTP Only
	2. Use your own SSL Certificate and Key
	3. Use Let's Encrypt to Create SSL Certificate and Key
	q. Exit
Please input the correct option: 3

Please input domain(example: www.example.com): fanxiapp-wangqiang-larabbs.shuijingwanwq.com
domain=fanxiapp-wangqiang-larabbs.shuijingwanwq.com

Please input the directory for the domain:fanxiapp-wangqiang-larabbs.shuijingwanwq.com :
(Default directory: /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com): 
Virtual Host Directory=/data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: n

Do you want to redirect all HTTP requests to HTTPS? [y/n]: y

Please enter your email: shuijingwanwq@163.com

[Fri Jan  7 10:48:20 CST 2022] Unknown parameter : -m
[Fri Jan  7 10:48:24 CST 2022] Single domain='fanxiapp-wangqiang-larabbs.shuijingwanwq.com'
[Fri Jan  7 10:48:24 CST 2022] Getting domain auth token for each domain
[Fri Jan  7 10:48:29 CST 2022] Getting webroot for domain='fanxiapp-wangqiang-larabbs.shuijingwanwq.com'
[Fri Jan  7 10:48:29 CST 2022] Verifying: fanxiapp-wangqiang-larabbs.shuijingwanwq.com
[Fri Jan  7 10:48:34 CST 2022] Success
[Fri Jan  7 10:48:34 CST 2022] Verify finished, start to sign.
[Fri Jan  7 10:48:34 CST 2022] Lets finalize the order, Le_OrderFinalize: https://acme-v02.api.letsencrypt.org/acme/finalize/73156074/53280741960
[Fri Jan  7 10:48:37 CST 2022] Download cert, Le_LinkCert: https://acme-v02.api.letsencrypt.org/acme/cert/04ed99c0b6706b74ad4a5a19389500b0add1
[Fri Jan  7 10:48:38 CST 2022] Cert success.
-----BEGIN CERTIFICATE-----
xxxxxxxxxx
-----END CERTIFICATE-----
[Fri Jan  7 10:48:38 CST 2022] Your cert is in  /root/.acme.sh/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.cer 
[Fri Jan  7 10:48:38 CST 2022] Your cert key is in  /root/.acme.sh/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.key 
[Fri Jan  7 10:48:39 CST 2022] The intermediate CA cert is in  /root/.acme.sh/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/ca.cer 
[Fri Jan  7 10:48:39 CST 2022] And the full chain certs is there:  /root/.acme.sh/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/fullchain.cer 

Do you want to add hotlink protection? [y/n]: y

Allow Rewrite rule? [y/n]: y

Please input the rewrite of programme :
wordpress,opencart,magento2,drupal,joomla,codeigniter,laravel
thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud,zblog,whmcs rewrite was exist.
(Default rewrite: other): laravel
You choose rewrite=laravel

Allow Nginx/Tengine/OpenResty access_log? [y/n]: y
You access log file=/data/wwwlogs/fanxiapp-wangqiang-larabbs.shuijingwanwq.com_nginx.log

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reload Nginx......

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 8+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  fanxiapp-wangqiang-larabbs.shuijingwanwq.com
Virtualhost conf:             /usr/local/nginx/conf/vhost/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.conf
Directory of:                 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com
Rewrite rule:                 /usr/local/nginx/conf/rewrite/laravel.conf
Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.crt
SSL Private Key:              /usr/local/nginx/conf/ssl/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.key
[root@iZ23wv7v5ggZ oneinstack]# ^C
[root@iZ23wv7v5ggZ oneinstack]# 

12、管理FTP账号,执行命令:./pureftpd_vhost.sh 。如图11

管理FTP账号,执行命令:./pureftpd_vhost.sh

图11

[root@iZ23wv7v5ggZ oneinstack]# ./pureftpd_vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 8+ and Ubuntu 16+      #
#                 FTP virtual user account management                 #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
	1. UserAdd
	2. UserMod
	3. UserPasswd
	4. UserDel
	5. ListAllUser
	6. ShowUser
	q. Exit
Please input the correct option: 1

Please input a username: fanxiapp-wangqiang-larabbs.shuijingwanwq.com

Please input the password: s0etwJ9DGm3e6CwP

Please input the directory(Default directory: /data/wwwroot): /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com
Password: 
Enter it again: 
#####################################

[fanxiapp-wangqiang-larabbs.shuijingwanwq.com] create successful! 

You user name is : fanxiapp-wangqiang-larabbs.shuijingwanwq.com
You Password is : xxxxxxxxxx
You directory is : /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com


What Are You Doing?
	1. UserAdd
	2. UserMod
	3. UserPasswd
	4. UserDel
	5. ListAllUser
	6. ShowUser
	q. Exit
Please input the correct option: q
[root@iZ23wv7v5ggZ oneinstack]# 

13、打开 FlashFXP,通过 FTP 上传源代码至 目录:/data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com 。如图12

打开 FlashFXP,通过 FTP 上传源代码至 目录:/data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com

图12

14、登录阿里云 RDS 控制台,创建数据库:fanxiapp_wangqiang_larabbs,且授权帐号:fanxiapp_wangqiang_larabbs。如图13

登录阿里云 RDS 控制台,创建数据库:fanxiapp_wangqiang_larabbs,且授权帐号:fanxiapp_wangqiang_larabbs

图13

15、登录 RDS 实例后,已经存在数据库:fanxiapp_wangqiang_larabbs。如图14

登录 RDS 实例后,已经存在数据库:fanxiapp_wangqiang_larabbs

图14

16、编辑虚拟主机配置文件:/usr/local/nginx/conf/vhost/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.conf 。网站根目录添加 /public。然后重启 Nginx 服务,执行命令:service nginx restart。如图15

编辑虚拟主机配置文件:/usr/local/nginx/conf/vhost/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.conf 。网站根目录添加 /public。然后重启 Nginx 服务,执行命令:service nginx restart

图15

[root@iZ23wv7v5ggZ oneinstack]# cat /usr/local/nginx/conf/vhost/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.conf
server {
  listen 80;
  listen 443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.crt;
  ssl_certificate_key /usr/local/nginx/conf/ssl/fanxiapp-wangqiang-larabbs.shuijingwanwq.com.key;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
  ssl_prefer_server_ciphers on;
  ssl_session_timeout 10m;
  ssl_session_cache builtin:1000 shared:SSL:10m;
  ssl_buffer_size 1400;
  add_header Strict-Transport-Security max-age=15768000;
  ssl_stapling on;
  ssl_stapling_verify on;
  server_name fanxiapp-wangqiang-larabbs.shuijingwanwq.com;
  access_log /data/wwwlogs/fanxiapp-wangqiang-larabbs.shuijingwanwq.com_nginx.log combined;
  index index.html index.htm index.php;
  root /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/public;
  if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
  
  include /usr/local/nginx/conf/rewrite/laravel.conf;
  #error_page 404 /404.html;
  #error_page 502 /502.html;
  location ~ .*/.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)$ {
    valid_referers none blocked *.shuijingwanwq.com fanxiapp-wangqiang-larabbs.shuijingwanwq.com;
    if ($invalid_referer) {
        return 403;
    }
  }
  location ~ [^/]/.php(/|$) {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
  }

  location ~ .*/.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
  }
  location ~ .*/.(js|css)?$ {
    expires 7d;
    access_log off;
  }
  location ~ /(/.user/.ini|/.ht|/.git|/.svn|/.project|LICENSE|README/.md) {
    deny all;
  }
  location /.well-known {
    allow all;
  }
}
[root@iZ23wv7v5ggZ oneinstack]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service

17、查看 Laravel 的伪静态配置文件,/usr/local/nginx/conf/rewrite/laravel.conf

[root@iZ23wv7v5ggZ oneinstack]# cat /usr/local/nginx/conf/rewrite/laravel.conf
location / {
  try_files $uri $uri/ /index.php?$query_string;
}
[root@iZ23wv7v5ggZ oneinstack]# 

18、第 13 步骤完成后,设置 Laravel 目录权限。参考网址:https://learnku.com/laravel/t/62112 。www 是我的 web 服务的 用户与用户组。目录设置为 755,所有的文件设置为 644。权限方面,已经被 OneinStack 自动设置好了的。因此,像目录:/bootstrap/cache、/storage、/public/uploads,皆无需要再设置额外的权限。如图16

第 13 步骤完成后,设置 Laravel 目录权限。参考网址:https://learnku.com/laravel/t/62112 。www 是我的 web 服务的 用户与用户组。目录设置为 755,所有的文件设置为 644。权限方面,已经被 OneinStack 自动设置好了的。因此,像目录:/bootstrap/cache、/storage、/public/uploads,皆无需要再设置额外的权限

图16

19、在 ECS 中编辑文件 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/.env。

20、执行数据库迁移与填充,执行成功。如图17

执行数据库迁移与填充,执行成功

图17

[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# php artisan migrate:refresh --seed
Migration table not found.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table (47.50ms)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table (29.91ms)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (36.63ms)
Migrating: 2019_12_14_000001_create_personal_access_tokens_table
Migrated:  2019_12_14_000001_create_personal_access_tokens_table (40.31ms)
Migrating: 2021_12_31_134920_add_avatar_and_introduction_to_users_table
Migrated:  2021_12_31_134920_add_avatar_and_introduction_to_users_table (240.63ms)
Migrating: 2021_12_31_155234_create_categories_table
Migrated:  2021_12_31_155234_create_categories_table (37.03ms)
Migrating: 2021_12_31_155935_seed_categories_data
Migrated:  2021_12_31_155935_seed_categories_data (12.72ms)
Migrating: 2021_12_31_161159_create_topics_table
Migrated:  2021_12_31_161159_create_topics_table (62.53ms)
Migrating: 2022_01_04_175444_create_replies_table
Migrated:  2022_01_04_175444_create_replies_table (49.36ms)
Migrating: 2022_01_05_101230_create_notifications_table
Migrated:  2022_01_05_101230_create_notifications_table (72.61ms)
Migrating: 2022_01_05_101456_add_notification_count_to_users_table
Migrated:  2022_01_05_101456_add_notification_count_to_users_table (41.74ms)
Migrating: 2022_01_05_114704_create_permission_tables
Migrated:  2022_01_05_114704_create_permission_tables (462.25ms)
Migrating: 2022_01_05_115758_seed_roles_and_permissions_data
Migrated:  2022_01_05_115758_seed_roles_and_permissions_data (252.50ms)
Migrating: 2022_01_05_164147_create_links_table
Migrated:  2022_01_05_164147_create_links_table (40.32ms)
Migrating: 2022_01_05_170327_add_references
Migrated:  2022_01_05_170327_add_references (133.90ms)
Migrating: 2022_01_06_094656_add_last_actived_at_to_users_table
Migrated:  2022_01_06_094656_add_last_actived_at_to_users_table (25.63ms)
Seeding: Database/Seeders/UsersTableSeeder
Seeded:  Database/Seeders/UsersTableSeeder (188.79ms)
Seeding: Database/Seeders/TopicsTableSeeder
Seeded:  Database/Seeders/TopicsTableSeeder (1,517.44ms)
Seeding: Database/Seeders/RepliesTableSeeder
Seeded:  Database/Seeders/RepliesTableSeeder (4,513.18ms)
Seeding: Database/Seeders/LinksTableSeeder
Seeded:  Database/Seeders/LinksTableSeeder (25.96ms)
Database seeding completed successfully.
[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# 

21、打开网址:https://fanxiapp-wangqiang-larabbs.shuijingwanwq.com/ ,提示:InvalidArgumentException
No hint path defined for [sudosu]. 。如图18

打开网址:https://fanxiapp-wangqiang-larabbs.shuijingwanwq.com/ ,提示:InvalidArgumentException No hint path defined for [sudosu].

图18

22、编辑文件 config/sudosu.php ,添加 com

    'allowed_tlds' => ['dev', 'local', 'com'],

23、在命令行启动队列系统,报错:Symfony/Component/Process/Exception/LogicException 。 The Process class relies on proc_open, which is not available on your PHP installation.。如图19

在命令行启动队列系统,报错:Symfony/Component/Process/Exception/LogicException 。  The Process class relies on proc_open, which is not available on your PHP installation.

图19

[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# php artisan queue:listen

   Symfony/Component/Process/Exception/LogicException 

  The Process class relies on proc_open, which is not available on your PHP installation.

  at vendor/symfony/process/Process.php:146
    142▕      */
    143▕     public function __construct(array $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
    144▕     {
    145▕         if (!/function_exists('proc_open')) {
  ➜ 146▕             throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.');
    147▕         }
    148▕ 
    149▕         $this->commandline = $command;
    150▕         $this->cwd = $cwd;

      +16 vendor frames 
  17  artisan:37
      Illuminate/Foundation/Console/Kernel::handle()

24、编辑 /usr/local/php/etc/php.ini 文件,搜索 disable_functions,将其值中的 proc_open 、proc_get_status 删除掉。然后重启 PHP 服务 。如图20

编辑 /usr/local/php/etc/php.ini 文件,搜索 disable_functions,将其值中的 proc_open 、proc_get_status 删除掉。然后重启 PHP 服务

图20

[root@iZ23wv7v5ggZ etc]# vi php.ini
[root@iZ23wv7v5ggZ etc]# 
[root@iZ23wv7v5ggZ etc]# service php-fpm restart
Redirecting to /bin/systemctl restart php-fpm.service
[root@iZ23wv7v5ggZ etc]# 

25、在命令行启动队列系统,队列在启动完成后会进入监听状态。但是,仍然报错: Symfony/Component/Process/Exception/ProcessTimedOutException 。 The process “‘/usr/local/php/bin/php’ ‘artisan’ ‘queue:work’ ‘–once’ ‘–name=default’ ‘–queue=default’ ‘–backoff=0’ ‘–memory=128’ ‘–sleep=3’ ‘–tries=1′” exceeded the timeout of 60 seconds.。添加选项 –timeout=0,不再报错。如图21

在命令行启动队列系统,队列在启动完成后会进入监听状态。但是,仍然报错: Symfony/Component/Process/Exception/ProcessTimedOutException 。  The process "'/usr/local/php/bin/php' 'artisan' 'queue:work' '--once' '--name=default' '--queue=default' '--backoff=0' '--memory=128' '--sleep=3' '--tries=1'" exceeded the timeout of 60 seconds.。添加选项 --timeout=0,不再报错

图21

[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# php artisan queue:listen
[2022-01-07 17:04:21][9iy9L39pxxNvZ7NL9YQ0xQMXxI4EwI0j] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:04:22][9iy9L39pxxNvZ7NL9YQ0xQMXxI4EwI0j] Failed:     App/Jobs/TranslateSlug
[2022-01-07 17:04:23][oho1xFRRasdVKHL8f4T19vz51vwzf241] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:04:24][oho1xFRRasdVKHL8f4T19vz51vwzf241] Failed:     App/Jobs/TranslateSlug
[2022-01-07 17:04:25][qCqFpPSu9ImA0JggR4IiMlIKLWL3EB8H] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:04:28][qCqFpPSu9ImA0JggR4IiMlIKLWL3EB8H] Failed:     App/Jobs/TranslateSlug
[2022-01-07 17:04:28][uxRYiXpFXEXBvpPxJTDKIDkCCXAgBTG9] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:04:29][uxRYiXpFXEXBvpPxJTDKIDkCCXAgBTG9] Failed:     App/Jobs/TranslateSlug
[2022-01-07 17:04:29][kgqbausYzFSzLYgjlAvvXfrgVaGBwZME] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:04:29][kgqbausYzFSzLYgjlAvvXfrgVaGBwZME] Failed:     App/Jobs/TranslateSlug
[2022-01-07 17:04:30][wdweaoBl2V2k0iCCwynnjE3imiHxmUZK] Processing: App/Jobs/TranslateSlug

   Symfony/Component/Process/Exception/ProcessTimedOutException 

  The process "'/usr/local/php/bin/php' 'artisan' 'queue:work' '--once' '--name=default' '--queue=default' '--backoff=0' '--memory=128' '--sleep=3' '--tries=1'" exceeded the timeout of 60 seconds.

  at vendor/symfony/process/Process.php:1204
    1200▕ 
    1201▕         if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
    1202▕             $this->stop(0);
    1203▕ 
  ➜ 1204▕             throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
    1205▕         }
    1206▕ 
    1207▕         if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
    1208▕             $this->stop(0);

      +18 vendor frames 
  19  artisan:37
      Illuminate/Foundation/Console/Kernel::handle()
[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# php artisan queue:listen --timeout=0
[2022-01-07 17:08:38][crCkj0LVPcowMiTlvjeGcGNHkPh1E4rY] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:39][crCkj0LVPcowMiTlvjeGcGNHkPh1E4rY] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:40][a6UvDyYukqW1sUSNcbjw7P6QzpFnt1dU] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:42][a6UvDyYukqW1sUSNcbjw7P6QzpFnt1dU] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:43][m8I0VIyZL9TguYR0XnxINv72wLgXqDCv] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:43][m8I0VIyZL9TguYR0XnxINv72wLgXqDCv] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:44][NM3oLDGUOhcsT5cIy9tAiM4WR1kOHTDw] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:46][NM3oLDGUOhcsT5cIy9tAiM4WR1kOHTDw] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:46][AGlsFITpj9Aqy2Iu0SOJZoxyNYcTl7ax] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:47][AGlsFITpj9Aqy2Iu0SOJZoxyNYcTl7ax] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:48][F8UO802DJzIt6nrIfAd5KZU0SmrFWg60] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:49][F8UO802DJzIt6nrIfAd5KZU0SmrFWg60] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:49][uN38Doj9q9xwDWtQcU7dGZLOub3W9Sqg] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:50][uN38Doj9q9xwDWtQcU7dGZLOub3W9Sqg] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:50][i2Fpvio1WVFbCbVFwmM8F6Gm9FWgveYq] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:51][i2Fpvio1WVFbCbVFwmM8F6Gm9FWgveYq] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:52][Ac7q3FzkUum0PN6jMVWYCqbbXRfInRM3] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:52][Ac7q3FzkUum0PN6jMVWYCqbbXRfInRM3] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:53][JstjmnEAp5ttbdPyqLXri7SwMs8Q7ple] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:54][JstjmnEAp5ttbdPyqLXri7SwMs8Q7ple] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:55][k7n2iJdSelQcgQWXsrjyci4KG1vNsAlq] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:55][k7n2iJdSelQcgQWXsrjyci4KG1vNsAlq] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:56][LcSujDiTXczEUgE1YZ5Cwf459he4yxSD] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:57][LcSujDiTXczEUgE1YZ5Cwf459he4yxSD] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:57][t2Umbs1fLco6N4ZfjYkEEbMdEHje0r9d] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:08:59][t2Umbs1fLco6N4ZfjYkEEbMdEHje0r9d] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:08:59][m4ttqh4axQ6JpFPQoL6Skpa1qBPAB6EC] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:09:01][m4ttqh4axQ6JpFPQoL6Skpa1qBPAB6EC] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:09:01][ARlo5v4zTyv3RUyKlBiR6HiYiwtuY6r5] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:09:03][ARlo5v4zTyv3RUyKlBiR6HiYiwtuY6r5] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:09:03][0DAnnrmFlwmZ6u1DGpZT0lL3fVc2GoTP] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:09:05][0DAnnrmFlwmZ6u1DGpZT0lL3fVc2GoTP] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:09:05][RXGEod7NPKnjrvzp0LB0xG7tumOTZQB3] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:09:07][RXGEod7NPKnjrvzp0LB0xG7tumOTZQB3] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:09:08][ebi2yS5WyyaZgfdHHdM0bPr6voETTHOY] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:09:10][ebi2yS5WyyaZgfdHHdM0bPr6voETTHOY] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:09:10][oCUs3UGYliYMEIldq3bOvbXEAuHJxH74] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:09:11][oCUs3UGYliYMEIldq3bOvbXEAuHJxH74] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:09:12][qS3aEkUuUx7s9eekD6txazQFCGXdZf95] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:09:12][qS3aEkUuUx7s9eekD6txazQFCGXdZf95] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:09:13][0M5eGoCrf44T0bHqi6CSnJWhIcRScx7V] Processing: App/Jobs/TranslateSlug
[2022-01-07 17:09:13][0M5eGoCrf44T0bHqi6CSnJWhIcRScx7V] Processed:  App/Jobs/TranslateSlug
[2022-01-07 17:09:14][ILzNa3JxWqzi4hMEbKsywvspJR0cSG7V] Processing: App/Jobs/TranslateSlug
^C
[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# 

26、发现队列作业未按预期起作用,查看表:failed_jobs,里面存在一些失败的队列记录。可以忽略掉,因为这是偶发事件,应该是一瞬间的调用频率过高所导致。如图22

发现队列作业未按预期起作用,查看表:failed_jobs,里面存在一些失败的队列记录。可以忽略掉,因为这是偶发事件,应该是一瞬间的调用频率过高所导致

图22

GuzzleHttp/Exception/ServerException: Server error: `GET http://api.fanyi.baidu.com/api/trans/vip/translate?q=Aut+et+assumenda+esse+necessitatibus+et+soluta+quia+temporibus.&from=zh&to=en&appid=20220104001046264&salt=1641546261&sign=6bf4c1c8f9779e1124e4e7b9a0dacd93` resulted in a `502 No data received from server or forwarder` response:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>502 - (truncated...)
in /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/guzzle/src/Middleware.php(69): GuzzleHttp/Exception/RequestException::create()
#1 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp/Middleware::GuzzleHttp/{closure}()
#2 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp/Promise/Promise::callHandler()
#3 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp/Promise/Promise::GuzzleHttp/Promise/{closure}()
#4 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp/Promise/TaskQueue->run()
#5 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp/Promise/Promise->invokeWaitFn()
#6 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp/Promise/Promise->waitIfPending()
#7 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp/Promise/Promise->invokeWaitList()
#8 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp/Promise/Promise->waitIfPending()
#9 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/guzzle/src/Client.php(187): GuzzleHttp/Promise/Promise->wait()
#10 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/guzzle/src/ClientTrait.php(44): GuzzleHttp/Client->request()
#11 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/app/Handlers/SlugTranslateHandler.php(42): GuzzleHttp/Client->get()
#12 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/app/Jobs/TranslateSlug.php(29): App/Handlers/SlugTranslateHandler->translate()
#13 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App/Jobs/TranslateSlug->handle()
#14 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate/Container/BoundMethod::Illuminate/Container/{closure}()
#15 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate/Container/Util::unwrapIfClosure()
#16 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate/Container/BoundMethod::callBoundMethod()
#17 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate/Container/BoundMethod::call()
#18 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate/Container/Container->call()
#19 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate/Bus/Dispatcher->Illuminate/Bus/{closure}()
#20 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate/Pipeline/Pipeline->Illuminate/Pipeline/{closure}()
#21 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate/Pipeline/Pipeline->then()
#22 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(120): Illuminate/Bus/Dispatcher->dispatchNow()
#23 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate/Queue/CallQueuedHandler->Illuminate/Queue/{closure}()
#24 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate/Pipeline/Pipeline->Illuminate/Pipeline/{closure}()
#25 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(122): Illuminate/Pipeline/Pipeline->then()
#26 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate/Queue/CallQueuedHandler->dispatchThroughMiddleware()
#27 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate/Queue/CallQueuedHandler->call()
#28 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(428): Illuminate/Queue/Jobs/Job->fire()
#29 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(378): Illuminate/Queue/Worker->process()
#30 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(329): Illuminate/Queue/Worker->runJob()
#31 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(117): Illuminate/Queue/Worker->runNextJob()
#32 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate/Queue/Console/WorkCommand->runWorker()
#33 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate/Queue/Console/WorkCommand->handle()
#34 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate/Container/BoundMethod::Illuminate/Container/{closure}()
#35 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate/Container/Util::unwrapIfClosure()
#36 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate/Container/BoundMethod::callBoundMethod()
#37 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate/Container/BoundMethod::call()
#38 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate/Container/Container->call()
#39 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/symfony/console/Command/Command.php(298): Illuminate/Console/Command->execute()
#40 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony/Component/Console/Command/Command->run()
#41 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/symfony/console/Application.php(1005): Illuminate/Console/Command->run()
#42 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/symfony/console/Application.php(299): Symfony/Component/Console/Application->doRunCommand()
#43 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/symfony/console/Application.php(171): Symfony/Component/Console/Application->doRun()
#44 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony/Component/Console/Application->run()
#45 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate/Console/Application->run()
#46 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/artisan(37): Illuminate/Foundation/Console/Kernel->handle()
#47 {main}

27、在开发环境中,我们为了测试方便,直接在命令行里调用 artisan queue:listen 进行队列监控。然而在生产环境中,我们需要配置一个进程管理工具来监控 queue:work 进程的状态并在需要时进行重启。安装 Supervisor,Supervisor 是一个用于 Linux 操作系统的进程监视器。如果它失败了,它将自动重启 queue 进程。安装 Supervisor,你可以使用以下命令。报错:[Errno 14] HTTP Error 502 – Bad Gateway

[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# yum install supervisor
Loaded plugins: fastestmirror
Determining fastest mirrors
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/epel/7/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/7/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/7/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
Resolving Dependencies
--> Running transaction check
---> Package supervisor.noarch 0:3.4.0-1.el7 will be installed
--> Processing Dependency: python-meld3 >= 0.6.5 for package: supervisor-3.4.0-1.el7.noarch
--> Processing Dependency: python-setuptools for package: supervisor-3.4.0-1.el7.noarch
--> Running transaction check
---> Package python-meld3.x86_64 0:0.6.10-1.el7 will be installed
---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch
--> Running transaction check
---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed
--> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Running transaction check
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================
Package                                           Arch                 Version                      Repository          Size
==============================================================================================================================
Installing:
supervisor                                        noarch               3.4.0-1.el7                  epel               498 k
Installing for dependencies:
python-backports                                  x86_64               1.0-8.el7                    base               5.8 k
python-backports-ssl_match_hostname               noarch               3.5.0.1-1.el7                base                13 k
python-ipaddress                                  noarch               1.0.16-2.el7                 base                34 k
python-meld3                                      x86_64               0.6.10-1.el7                 epel                73 k
python-setuptools                                 noarch               0.9.8-7.el7                  base               397 k
Transaction Summary
==============================================================================================================================
Install  1 Package (+5 Dependent packages)
Total download size: 1.0 M
Installed size: 5.1 M
Is this ok [y/d/N]: y
Downloading packages:
python-backports-1.0-8.el7.x86 FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
python-backports-ssl_match_hos FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
python-meld3-0.6.10-1.el7.x86_ FAILED                                          
http://mirrors.cloud.aliyuncs.com/epel/7/x86_64/Packages/p/python-meld3-0.6.10-1.el7.x86_64.rpm: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
python-ipaddress-1.0.16-2.el7. FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
python-setuptools-0.9.8-7.el7. FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
supervisor-3.4.0-1.el7.noarch. FAILED                                          
http://mirrors.cloud.aliyuncs.com/epel/7/x86_64/Packages/s/supervisor-3.4.0-1.el7.noarch.rpm: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
Error downloading packages:
python-backports-1.0-8.el7.x86_64: [Errno 256] No more mirrors to try.
python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch: [Errno 256] No more mirrors to try.
python-setuptools-0.9.8-7.el7.noarch: [Errno 256] No more mirrors to try.
supervisor-3.4.0-1.el7.noarch: [Errno 256] No more mirrors to try.
python-ipaddress-1.0.16-2.el7.noarch: [Errno 256] No more mirrors to try.
python-meld3-0.6.10-1.el7.x86_64: [Errno 256] No more mirrors to try.

28、缘由应该是 yum 源已经过期了,重新配置阿里云的 CentOS 7 yum 源,参考网址:https://oneinstack.com/faq/yum-apt/ 。如图23

缘由应该是 yum 源已经过期了,重新配置阿里云的 CentOS 7 yum 源,参考网址:https://oneinstack.com/faq/yum-apt/

图23

[root@iZ23wv7v5ggZ ~]# cd /etc/yum.repos.d
[root@iZ23wv7v5ggZ yum.repos.d]# ls
CentOS-Base.repo  epel.repo
[root@iZ23wv7v5ggZ yum.repos.d]# rm -rf /etc/yum.repos.d/*.repo
[root@iZ23wv7v5ggZ yum.repos.d]# ls
[root@iZ23wv7v5ggZ yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0   4059      0 --:--:-- --:--:-- --:--:--  4056
[root@iZ23wv7v5ggZ yum.repos.d]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100   664  100   664    0     0    639      0  0:00:01  0:00:01 --:--:--   640
[root@iZ23wv7v5ggZ yum.repos.d]# ls
CentOS-Base.repo  epel.repo
[root@iZ23wv7v5ggZ yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.cloud.aliyuncs.com
* extras: mirrors.cloud.aliyuncs.com
* updates: mirrors.cloud.aliyuncs.com
base                                                            | 3.6 kB  00:00:00     
epel                                                            | 4.7 kB  00:00:00     
extras                                                          | 2.9 kB  00:00:00     
updates                                                         | 2.9 kB  00:00:00     
(1/13): epel/x86_64/updateinfo                                  | 1.0 MB  00:00:00     
(2/13): epel/x86_64/prestodelta                                 |  450 B  00:00:00     
(3/13): base/7/x86_64/filelists_db                              | 7.2 MB  00:00:01     
(4/13): epel/x86_64/filelists_db                                |  12 MB  00:00:01     
(5/13): epel/x86_64/primary_db                                  | 7.0 MB  00:00:00     
(6/13): extras/7/x86_64/primary_db                              | 243 kB  00:00:00     
(7/13): extras/7/x86_64/filelists_db                            | 259 kB  00:00:00     
(8/13): epel/x86_64/other_db                                    | 3.4 MB  00:00:00     
(9/13): extras/7/x86_64/other_db                                | 145 kB  00:00:00     
(10/13): updates/7/x86_64/filelists_db                          | 7.4 MB  00:00:01     
(11/13): updates/7/x86_64/other_db                              | 955 kB  00:00:00     
(12/13): updates/7/x86_64/primary_db                            |  13 MB  00:00:02     
base/7/x86_64/other_db         FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/ecaab5cc3b9c10fefe6be2ecbf6f9fcb437231dac3e82cab8d9d2cf70e99644d-other.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/ecaab5cc3b9c10fefe6be2ecbf6f9fcb437231dac3e82cab8d9d2cf70e99644d-other.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(13/13): base/7/x86_64/other_db                                 | 2.6 MB  00:00:00     
Metadata Cache Created
[root@iZ23wv7v5ggZ yum.repos.d]# ^C
[root@iZ23wv7v5ggZ yum.repos.d]# 

29、参考 Supervisor 配置:https://learnku.com/docs/laravel/8.5/queues/10395#e45763 ,再次安装 Supervisor。安装成功。

[root@iZ23wv7v5ggZ yum.repos.d]# yum install supervisor
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cloud.aliyuncs.com
* extras: mirrors.cloud.aliyuncs.com
* updates: mirrors.cloud.aliyuncs.com
Resolving Dependencies
--> Running transaction check
---> Package supervisor.noarch 0:3.4.0-1.el7 will be installed
--> Processing Dependency: python-meld3 >= 0.6.5 for package: supervisor-3.4.0-1.el7.noarch
--> Processing Dependency: python-setuptools for package: supervisor-3.4.0-1.el7.noarch
--> Running transaction check
---> Package python-meld3.x86_64 0:0.6.10-1.el7 will be installed
---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch
--> Running transaction check
---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed
--> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Running transaction check
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================
Package                                 Arch       Version             Repository
Size
=======================================================================================
Installing:
supervisor                              noarch     3.4.0-1.el7         epel     498 k
Installing for dependencies:
python-backports                        x86_64     1.0-8.el7           base     5.8 k
python-backports-ssl_match_hostname     noarch     3.5.0.1-1.el7       base      13 k
python-ipaddress                        noarch     1.0.16-2.el7        base      34 k
python-meld3                            x86_64     0.6.10-1.el7        epel      73 k
python-setuptools                       noarch     0.9.8-7.el7         base     397 k
Transaction Summary
=======================================================================================
Install  1 Package (+5 Dependent packages)
Total download size: 1.0 M
Installed size: 5.1 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
(1/6): python-backports-1.0-8.el7.x86_64.rpm                    | 5.8 kB  00:00:00     
(2/6): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch |  13 kB  00:00:00     
(3/6): python-ipaddress-1.0.16-2.el7.noarch.rpm                 |  34 kB  00:00:00     
(4/6): python-meld3-0.6.10-1.el7.x86_64.rpm                     |  73 kB  00:00:00     
(5/6): python-setuptools-0.9.8-7.el7.noarch.rpm                 | 397 kB  00:00:00     
(6/6): supervisor-3.4.0-1.el7.noarch.rpm                        | 498 kB  00:00:00     
---------------------------------------------------------------------------------------
Total                                                     726 kB/s | 1.0 MB  00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-meld3-0.6.10-1.el7.x86_64                                    1/6 
Installing : python-ipaddress-1.0.16-2.el7.noarch                                2/6 
Installing : python-backports-1.0-8.el7.x86_64                                   3/6 
Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch            4/6 
Installing : python-setuptools-0.9.8-7.el7.noarch                                5/6 
Installing : supervisor-3.4.0-1.el7.noarch                                       6/6 
Verifying  : supervisor-3.4.0-1.el7.noarch                                       1/6 
Verifying  : python-backports-1.0-8.el7.x86_64                                   2/6 
Verifying  : python-ipaddress-1.0.16-2.el7.noarch                                3/6 
Verifying  : python-meld3-0.6.10-1.el7.x86_64                                    4/6 
Verifying  : python-setuptools-0.9.8-7.el7.noarch                                5/6 
Verifying  : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch            6/6 
Installed:
supervisor.noarch 0:3.4.0-1.el7                                                      
Dependency Installed:
python-backports.x86_64 0:1.0-8.el7                                                  
python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7                           
python-ipaddress.noarch 0:1.0.16-2.el7                                               
python-meld3.x86_64 0:0.6.10-1.el7                                                   
python-setuptools.noarch 0:0.9.8-7.el7                                               
Complete!
[root@iZ23wv7v5ggZ yum.repos.d]# 

30、创建一个 /etc/supervisord.d/fanxiapp-wangqiang-larabbs-worker.ini 文件,启动并监视 queue:work 进程。指示 Supervisor 运行 2 个 queue:work 进程并监视所有进程。如图24

创建一个 /etc/supervisord.d/fanxiapp-wangqiang-larabbs-worker.ini 文件,启动并监视 queue:work 进程。指示 Supervisor 运行 2 个 queue:work 进程并监视所有进程

图24

[root@iZ23wv7v5ggZ supervisord.d]# cat fanxiapp-wangqiang-larabbs-worker.ini 
[program:fanxiapp-wangqiang-larabbs-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/artisan queue:work sqs --sleep=3 --tries=3 --max-time=600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www
numprocs=2
redirect_stderr=true
stdout_logfile=/data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/worker.log
stopwaitsecs=600
[root@iZ23wv7v5ggZ supervisord.d]# 

31、创建配置文件后,你可以更新 Supervisor 配置并使用以下命令启动进程。报错:unix:///var/run/supervisor/supervisor.sock no such file

[root@iZ23wv7v5ggZ supervisord.d]# cd ~
[root@iZ23wv7v5ggZ ~]# supervisorctl reread
error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224
[root@iZ23wv7v5ggZ ~]# supervisorctl status
unix:///var/run/supervisor/supervisor.sock no such file

32、重启 ECS 实例后,执行命令:easy_install supervisor。查看 supervisord 运行状态:supervisorctl status,报错:can’t find command ‘php’。如图25

重启 ECS 实例后,执行命令:easy_install supervisor。查看 supervisord 运行状态:supervisorctl status,报错:can't find command 'php'

图25

[root@iZ23wv7v5ggZ ~]# easy_install supervisor
Searching for supervisor
Best match: supervisor 3.4.0
Adding supervisor 3.4.0 to easy-install.pth file
Installing echo_supervisord_conf script to /usr/bin
Installing pidproxy script to /usr/bin
Installing supervisorctl script to /usr/bin
Installing supervisord script to /usr/bin
Using /usr/lib/python2.7/site-packages
Processing dependencies for supervisor
Finished processing dependencies for supervisor
[root@iZ23wv7v5ggZ ~]# systemctl enable supervisord
Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.
[root@iZ23wv7v5ggZ ~]# systemctl restart supervisord
[root@iZ23wv7v5ggZ ~]# supervisorctl status
fanxiapp-wangqiang-larabbs-worker:fanxiapp-wangqiang-larabbs-worker_00   FATAL     can't find command 'php'
fanxiapp-wangqiang-larabbs-worker:fanxiapp-wangqiang-larabbs-worker_01   FATAL     can't find command 'php'
[root@iZ23wv7v5ggZ ~]# 

33、查看 php 的运行目录 which php,ini 配置文件的 command 的 php 加上绝对路径。如图26

查看 php 的运行目录 which php,ini 配置文件的 command 的 php 加上绝对路径

图26

[root@iZ23wv7v5ggZ ~]# which php
/usr/local/php/bin/php
[root@iZ23wv7v5ggZ ~]# vim /etc/supervisord.d/fanxiapp-wangqiang-larabbs-worker.ini
[root@iZ23wv7v5ggZ ~]# cat /etc/supervisord.d/fanxiapp-wangqiang-larabbs-worker.ini
[program:fanxiapp-wangqiang-larabbs-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/artisan queue:work sqs --sleep=3 --tries=3 --max-time=600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www
numprocs=2
redirect_stderr=true
stdout_logfile=/data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/worker.log
stopwaitsecs=600
[root@iZ23wv7v5ggZ ~]# 

34、重启 supervisord 后,查看状态,运行成功,但是提示:退出太快(进程日志可能有详细信息)。如图27

重启 supervisord 后,查看状态,运行成功,但是提示:退出太快(进程日志可能有详细信息)

图27

[root@iZ23wv7v5ggZ ~]# service supervisord restart
Redirecting to /bin/systemctl restart supervisord.service
[root@iZ23wv7v5ggZ ~]# supervisorctl status
fanxiapp-wangqiang-larabbs-worker:fanxiapp-wangqiang-larabbs-worker_00   BACKOFF   Exited too quickly (process log may have details)
fanxiapp-wangqiang-larabbs-worker:fanxiapp-wangqiang-larabbs-worker_01   STARTING  
[root@iZ23wv7v5ggZ ~]# 

35、查看 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/worker.log,提示:Class ‘Aws/Sqs/SqsClient’ not found。如图29

查看 /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/worker.log,提示:Class 'Aws/Sqs/SqsClient' not found

图29

[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# cat worker.log 
Error 
Class 'Aws/Sqs/SqsClient' not found
at /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Connectors/SqsConnector.php:26
22▕             $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
23▕         }
24▕ 
25▕         return new SqsQueue(
➜  26▕             new SqsClient($config),
27▕             $config['queue'],
28▕             $config['prefix'] ?? '',
29▕             $config['suffix'] ?? '',
30▕             $config['after_commit'] ?? null
+18 vendor frames 
19  /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/artisan:37
Illuminate/Foundation/Console/Kernel::handle()
+18 vendor frames 
19  /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/artisan:37
Illuminate/Foundation/Console/Kernel::handle()

36、ini 配置文件的 command 的 php ,删除掉 sqs,然后重启后,查看状态,一直处于运行中。如图30

ini 配置文件的 command 的 php ,删除掉 sqs,然后重启后,查看状态,一直处于运行中

图30

[root@iZ23wv7v5ggZ ~]# vim /etc/supervisord.d/fanxiapp-wangqiang-larabbs-worker.ini
[root@iZ23wv7v5ggZ ~]# cat /etc/supervisord.d/fanxiapp-wangqiang-larabbs-worker.ini
[program:fanxiapp-wangqiang-larabbs-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/artisan queue:work --sleep=3 --tries=3 --max-time=600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www
numprocs=2
redirect_stderr=true
stdout_logfile=/data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/worker.log
stopwaitsecs=600
[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# service supervisord restart
Redirecting to /bin/systemctl restart supervisord.service
[root@iZ23wv7v5ggZ fanxiapp-wangqiang-larabbs.shuijingwanwq.com]# supervisorctl status
fanxiapp-wangqiang-larabbs-worker:fanxiapp-wangqiang-larabbs-worker_00   RUNNING   pid 2277, uptime 0:00:07
fanxiapp-wangqiang-larabbs-worker:fanxiapp-wangqiang-larabbs-worker_01   RUNNING   pid 2276, uptime 0:00:07

37、测试队列是否生效,重启 ECS 后,新建一个话题,其详情页面的网址为:https://fanxiapp-wangqiang-larabbs.shuijingwanwq.com/topics/105 。刷新一下,其会 301 跳转至:https://fanxiapp-wangqiang-larabbs.shuijingwanwq.com/topics/105/a-german 。表明队列生效中。如图31

测试队列是否生效,重启 ECS 后,新建一个话题,其详情页面的网址为:https://fanxiapp-wangqiang-larabbs.shuijingwanwq.com/topics/105 。刷新一下,其会 301 跳转至:https://fanxiapp-wangqiang-larabbs.shuijingwanwq.com/topics/105/a-german 。表明队列生效中

图31

38、计划任务的实现,使用调度器时,我们需要修改系统的 Cron 计划任务配置信息,运行以下命令,添加新的调度任务。部署完毕。如图32

计划任务的实现,使用调度器时,我们需要修改系统的 Cron 计划任务配置信息,运行以下命令,添加新的调度任务。部署完毕

图32

[root@iZ23wv7v5ggZ ~]# export EDITOR=vi && crontab -e
crontab: installing new crontab
* * * * * /usr/local/php/bin/php /data/wwwroot/fanxiapp-wangqiang-larabbs.shuijingwanwq.com/artisan schedule:run >> /dev/null 2>&1

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/250316.html

(0)
上一篇 2022年4月29日
下一篇 2022年4月29日

相关推荐

发表回复

登录后才能评论