disable_functions – 永夜 https://www.shuijingwanwq.com 没有不值得去解决的问题,也没有不值得去学习的技术! Thu, 21 May 2026 11:15:07 +0000 zh-Hans hourly 1 https://wordpress.org/?v=7.0 部署 Shopify PHP 应用至生产环境(阿里云、ECS 中的 CentOS 7.7 64位、MySQL 5.7) https://www.shuijingwanwq.com/2023/07/13/7855/ https://www.shuijingwanwq.com/2023/07/13/7855/#comments Thu, 13 Jul 2023 03:06:29 +0000 https://www.shuijingwanwq.com/?p=7855 浏览量: 327

1、现有一个 Shopify PHP 应用,已经可在开发环境中预览。如图1

现有一个 Shopify PHP 应用,已经可在开发环境中预览

图1

2、现准备将其部署至生产环境。如果需要部署应用至生产环境,Shopify 建议创建一个单独的应用。此应用与开发、测试环境共用代码库,但是在 Shopify 合作伙伴中心有自己的记录和配置。以避免在开发和测试过程中影响到生产环境的应用。使用 Shopify 合作伙伴
从头开始创建应用:learn-php-app-0605-prod。如图2

使用 Shopify 合作伙伴从头开始创建应用:learn-php-app-0605-prod

图2

3、检索环境变量,以便可以在稍后的步骤中设置它们。记下 SCOPES、SHOPIFY_API_KEY 和 SHOPIFY_API_SECRET 值。 您需要将这些值设置为托管应用程序的环境变量。


wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605$ npm run shopify app env show

> learn-php-app-ubuntu-2004-0605@1.0.0 shopify
> shopify app env show

?  Which existing app is this for?
✔  learn-php-app-0605-prod


    SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef
    SHOPIFY_API_SECRET=4de64aa8281e97055cf7698bbe56039e
    SCOPES=write_products



4、参考:基于阿里云的 ECS、RDS,将个人博客迁移升级至:Docker(基于预算考虑,最终未实现)、LNMP(CentOS 7.7、Nginx 1.16、MySQL 5.7、PHP 7.4)、HTTPS 的过程  ,之前的环境是基于 OneinStack 的自动安装。PHP 版本 7.4 已经不再符合 Shopify 应用的运行条件。需要升级至 8.1 版本,尽量与本地环境保持一致。


[root@iZ23wv7v5ggZ ~]# 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




wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605$ php -v
PHP 8.1.18 (cli) (built: Apr 14 2023 04:39:24) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.18, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.18, Copyright (c), by Zend Technologies


5、参考:在 阿里云中的 CentOS 7.7 中卸载 PHP 7.4,然后安装 PHP 8

6、查看阿里云中的 ECS 的 Alibaba Cloud Linux 3 的 PHP 版本


[root@iZ23wv7v5ggZ ~]# php -v
PHP 8.1.19 (cli) (built: Jun  7 2023 11:34:24) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.19, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.19, Copyright (c), by Zend Technologies
[root@iZ23wv7v5ggZ ~]#



7、添加虚拟主机时,设置 SSL 证书失败:Let’s Encrypt Verify error! DNS problem,需要先设置域名的解析。


[root@iZ23wv7v5ggZ www.shuijingwanwq.com]# ~/oneinstack/vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ 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): learn-php-app-0605-prod.shuijingwanwq.com
domain=learn-php-app-0605-prod.shuijingwanwq.com

Please input the directory for the domain:learn-php-app-0605-prod.shuijingwanwq.com :
(Default directory: /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com):
Virtual Host Directory=/data/wwwroot/learn-php-app-0605-prod.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 select domain cert key length.
Enter one of 2048, 3072, 4096, 8192 will issue a RSA cert.
Enter one of ec-256, ec-384, ec-521 will issue a ECC cert.

Please enter your cert key length (default 2048):

Let's Encrypt Verify error! DNS problem: NXDOMAIN looking up A for learn-php-app-0605-prod.shuijingwanwq.com
[Wed Jun  7 04:44:59 PM CST 2023] Using CA: https://acme.zerossl.com/v2/DV90
[Wed Jun  7 04:44:59 PM CST 2023] Creating domain key
[Wed Jun  7 04:44:59 PM CST 2023] The domain key is here: /root/.acme.sh/learn-php-app-0605-prod.shuijingwanwq.com/learn-php-app-0605-prod.shuijingwanwq.com.key
[Wed Jun  7 04:44:59 PM CST 2023] Single domain='learn-php-app-0605-prod.shuijingwanwq.com'
[Wed Jun  7 04:44:59 PM CST 2023] Getting domain auth token for each domain
[Wed Jun  7 04:45:05 PM CST 2023] Getting webroot for domain='learn-php-app-0605-prod.shuijingwanwq.com'
[Wed Jun  7 04:45:05 PM CST 2023] Verifying: learn-php-app-0605-prod.shuijingwanwq.com
[Wed Jun  7 04:45:07 PM CST 2023] Processing, The CA is processing your order, please just wait. (1/30)
[Wed Jun  7 04:45:11 PM CST 2023] learn-php-app-0605-prod.shuijingwanwq.com:Verify error:"error":{
[Wed Jun  7 04:45:11 PM CST 2023] Please add '--debug' or '--log' to check more details.
[Wed Jun  7 04:45:11 PM CST 2023] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh
Error: Create Let's Encrypt SSL Certificate failed!
[root@iZ23wv7v5ggZ www.shuijingwanwq.com]#



8、在阿里云 云解析DNS 中添加记录。如图3

在阿里云 云解析DNS 中添加记录

图3

9、再次添加虚拟主机


[root@iZ23wv7v5ggZ www.shuijingwanwq.com]# ~/oneinstack/vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ 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): learn-php-app-0605-prod.shuijingwanwq.com
domain=learn-php-app-0605-prod.shuijingwanwq.com

Please input the directory for the domain:learn-php-app-0605-prod.shuijingwanwq.com :
(Default directory: /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com):
Virtual Host Directory=/data/wwwroot/learn-php-app-0605-prod.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 select domain cert key length.
Enter one of 2048, 3072, 4096, 8192 will issue a RSA cert.
Enter one of ec-256, ec-384, ec-521 will issue a ECC cert.

Please enter your cert key length (default 2048):
[Wed Jun  7 04:51:49 PM CST 2023] Using CA: https://acme.zerossl.com/v2/DV90
[Wed Jun  7 04:51:49 PM CST 2023] Single domain='learn-php-app-0605-prod.shuijingwanwq.com'
[Wed Jun  7 04:51:49 PM CST 2023] Getting domain auth token for each domain
[Wed Jun  7 04:51:54 PM CST 2023] Getting webroot for domain='learn-php-app-0605-prod.shuijingwanwq.com'
[Wed Jun  7 04:51:54 PM CST 2023] Verifying: learn-php-app-0605-prod.shuijingwanwq.com
[Wed Jun  7 04:51:55 PM CST 2023] Processing, The CA is processing your order, please just wait. (1/30)
[Wed Jun  7 04:52:01 PM CST 2023] Success
[Wed Jun  7 04:52:01 PM CST 2023] Verify finished, start to sign.
[Wed Jun  7 04:52:01 PM CST 2023] Lets finalize the order.
[Wed Jun  7 04:52:01 PM CST 2023] Le_OrderFinalize='https://acme.zerossl.com/v2/DV90/order/CLf6pxWJkdxtQylgNxS_Jg/finalize'
[Wed Jun  7 04:52:02 PM CST 2023] Order status is processing, lets sleep and retry.
[Wed Jun  7 04:52:02 PM CST 2023] Retry after: 15
[Wed Jun  7 04:52:18 PM CST 2023] Polling order status: https://acme.zerossl.com/v2/DV90/order/CLf6pxWJkdxtQylgNxS_Jg
[Wed Jun  7 04:52:20 PM CST 2023] Downloading cert.
[Wed Jun  7 04:52:20 PM CST 2023] Le_LinkCert='https://acme.zerossl.com/v2/DV90/cert/B2uRnJRfyVAP2B9aqQ2_Lw'
[Wed Jun  7 04:52:22 PM CST 2023] Cert success.
-----BEGIN CERTIFICATE-----
*******************
-----END CERTIFICATE-----
[Wed Jun  7 04:52:22 PM CST 2023] Your cert is in: /root/.acme.sh/learn-php-app-0605-prod.shuijingwanwq.com/learn-php-app-0605-prod.shuijingwanwq.com.cer
[Wed Jun  7 04:52:22 PM CST 2023] Your cert key is in: /root/.acme.sh/learn-php-app-0605-prod.shuijingwanwq.com/learn-php-app-0605-prod.shuijingwanwq.com.key
[Wed Jun  7 04:52:22 PM CST 2023] The intermediate CA cert is in: /root/.acme.sh/learn-php-app-0605-prod.shuijingwanwq.com/ca.cer
[Wed Jun  7 04:52:22 PM CST 2023] And the full chain certs is there: /root/.acme.sh/learn-php-app-0605-prod.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/learn-php-app-0605-prod.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 9+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  learn-php-app-0605-prod.shuijingwanwq.com
Virtualhost conf:             /usr/local/nginx/conf/vhost/learn-php-app-0605-prod.shuijingwanwq.com.conf
Directory of:                 /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com
Rewrite rule:                 /usr/local/nginx/conf/rewrite/laravel.conf
Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/learn-php-app-0605-prod.shuijingwanwq.com.crt
SSL Private Key:              /usr/local/nginx/conf/ssl/learn-php-app-0605-prod.shuijingwanwq.com.key
[root@iZ23wv7v5ggZ www.shuijingwanwq.com]#



10、添加FTP账号


[root@iZ23wv7v5ggZ www.shuijingwanwq.com]# ~/oneinstack/pureftpd_vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ 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: learn-php-app-0605-prod.shuijingwanwq.com

Please input the password: XZzqpC4k3Clf6Oup26e

Please input the directory(Default directory: /data/wwwroot): /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com
Password:
Enter it again:
#####################################

[learn-php-app-0605-prod.shuijingwanwq.com] create successful!

You user name is : learn-php-app-0605-prod.shuijingwanwq.com
You Password is : ************
You directory is : /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com



11、此时,需要在本地环境中构建生产环境中的应用,避免在生产环境中构建,因为生产环境中暂不支持构建所需要的前提条件,比如说 npm、composer 等。SHOPIFY_API_KEY 需要使用 步骤 3 中检索出的变量值。复制应用目录 learn-php-app-ubuntu-2004-0605/web 为 learn-php-app-0605-prod。目录 learn-php-app-0605-prod 仅需要构建后,上传至生产环境,因此,开发环境的依赖文件皆不需要。


wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app$ cd learn-php-app-0605-prod/
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod$ ls -l
total 300
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:38 app
-rwxrwxrwx 1 wangqiang wangqiang   1690 Jun  5 15:02 artisan
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:38 bootstrap
-rwxrwxrwx 1 wangqiang wangqiang   2238 Jun  5 15:02 composer.json
-rwxrwxrwx 1 wangqiang wangqiang 304694 Jun  6 09:35 composer.lock
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:38 config
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:38 database
-rwxrwxrwx 1 wangqiang wangqiang    450 Jun  5 15:02 entrypoint.sh
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 frontend
-rwxrwxrwx 1 wangqiang wangqiang    860 Jun  5 15:00 nginx.conf
-rwxrwxrwx 1 wangqiang wangqiang   1202 Jun  5 15:00 phpunit.xml
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 public
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 resources
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 routes
-rwxrwxrwx 1 wangqiang wangqiang    563 Jun  5 15:00 server.php
-rwxrwxrwx 1 wangqiang wangqiang     75 Jun  5 15:00 shopify.web.toml
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 storage
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:42 vendor



12、编辑 .env ,设置为生产环境中的配置值


APP_NAME="Shopify PHP App 0605 Prod"
APP_ENV=production
APP_KEY=***********
APP_DEBUG=false

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=************
DB_PORT=3306
DB_DATABASE=learn_php_app_0605_prod
DB_USERNAME=learn_php_app_0605_prod
DB_PASSWORD=**********



13、构建前端与后端,报错:/bin/sh: 1: vite: not found,需要先执行:npm install 。如图4

构建前端与后端,报错:/bin/sh: 1: vite: not found,需要先执行:npm install

图4


wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod/frontend$ SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef yarn build
yarn run v1.22.15
$ vite build
/bin/sh: 1: vite: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod/frontend$ npm install
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.

added 354 packages, and audited 360 packages in 3m

41 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod/frontend$ SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef npm run build

> shopify-frontend-template-react@1.0.0 build
> vite build

vite v4.3.9 building for production...
✓ 1966 modules transformed.
dist/assets/empty-state-8039a1e1.svg      0.26 kB │ gzip:   0.20 kB
dist/index.html                           0.48 kB │ gzip:   0.33 kB
dist/assets/home-trophy-d70b3542.png     20.65 kB
dist/assets/index-37530742.css          371.48 kB │ gzip:  45.42 kB
dist/assets/ko-ef9a93f5.js                0.21 kB │ gzip:   0.15 kB
dist/assets/ja-abb1af27.js                0.21 kB │ gzip:   0.15 kB
dist/assets/zh-4775ba45.js                0.21 kB │ gzip:   0.15 kB
dist/assets/th-32f01d1c.js                0.21 kB │ gzip:   0.15 kB
dist/assets/vi-72f55a87.js                0.23 kB │ gzip:   0.17 kB
dist/assets/nb-79727cd5.js                0.24 kB │ gzip:   0.17 kB
dist/assets/tr-d5c962f0.js                0.24 kB │ gzip:   0.17 kB
dist/assets/nl-ed6c02b1.js                0.28 kB │ gzip:   0.20 kB
dist/assets/de-5d4a5256.js                0.28 kB │ gzip:   0.20 kB
dist/assets/fi-e67a7779.js                0.28 kB │ gzip:   0.20 kB
dist/assets/da-9b835bb8.js                0.31 kB │ gzip:   0.22 kB
dist/assets/cs-d855408e.js                0.32 kB │ gzip:   0.23 kB
dist/assets/sv-8ac62b51.js                0.37 kB │ gzip:   0.25 kB
dist/assets/en-d265ad8d.js                0.41 kB │ gzip:   0.26 kB
dist/assets/es-fd2f35f4.js                0.41 kB │ gzip:   0.29 kB
dist/assets/pt-227fd344.js                0.41 kB │ gzip:   0.29 kB
dist/assets/pt-PT-a0c51464.js             0.41 kB │ gzip:   0.29 kB
dist/assets/pl-ab15c7ea.js                0.42 kB │ gzip:   0.29 kB
dist/assets/fr-23e50d95.js                0.43 kB │ gzip:   0.29 kB
dist/assets/it-08f76780.js                0.45 kB │ gzip:   0.30 kB
dist/assets/en-df34a502.js                1.53 kB │ gzip:   0.77 kB
dist/assets/de-2ae5c9fa.js                1.72 kB │ gzip:   0.90 kB
dist/assets/fr-5253333d.js                1.83 kB │ gzip:   0.94 kB
dist/assets/polyfill-force-11887b4b.js    5.21 kB │ gzip:   2.03 kB
dist/assets/zh-CN-cf74d136.js             7.72 kB │ gzip:   3.26 kB
dist/assets/zh-TW-6a74a185.js             7.86 kB │ gzip:   3.36 kB
dist/assets/ko-2cf626e6.js                8.18 kB │ gzip:   3.39 kB
dist/assets/ja-6f78282b.js                8.35 kB │ gzip:   3.58 kB
dist/assets/en-c240dff3.js                9.95 kB │ gzip:   2.95 kB
dist/assets/vi-e4ef4fd6.js                9.97 kB │ gzip:   3.34 kB
dist/assets/th-2a34d5e0.js               10.14 kB │ gzip:   3.77 kB
dist/assets/sv-a901b08f.js               10.22 kB │ gzip:   3.27 kB
dist/assets/da-1564850b.js               10.30 kB │ gzip:   3.26 kB
dist/assets/nb-0a6d8490.js               10.35 kB │ gzip:   3.25 kB
dist/assets/pl-a603e9c2.js               10.39 kB │ gzip:   3.39 kB
dist/assets/cs-3c753a97.js               10.40 kB │ gzip:   3.50 kB
dist/assets/fi-c0a9d95f.js               10.63 kB │ gzip:   3.41 kB
dist/assets/tr-bd45be97.js               10.68 kB │ gzip:   3.39 kB
dist/assets/it-8bb02787.js               10.72 kB │ gzip:   3.32 kB
dist/assets/pt-PT-af188c06.js            10.85 kB │ gzip:   3.34 kB
dist/assets/nl-0772ea77.js               10.89 kB │ gzip:   3.25 kB
dist/assets/pt-BR-8a1d5660.js            10.94 kB │ gzip:   3.36 kB
dist/assets/es-5e0e20e7.js               10.95 kB │ gzip:   3.39 kB
dist/assets/de-a04fe3bd.js               11.11 kB │ gzip:   3.35 kB
dist/assets/fr-1848494a.js               11.31 kB │ gzip:   3.48 kB
dist/assets/index-41437cc7.js            53.59 kB │ gzip:  18.93 kB
dist/assets/polyfill-904c231f.js        133.64 kB │ gzip:  40.74 kB
dist/assets/index-991532e3.js           618.82 kB │ gzip: 164.28 kB

(!) Some chunks are larger than 500 kBs after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✓ built in 47.73s
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod$ composer build
> composer build-frontend-links
> ln -sf ../frontend/dist/assets public/assets && ln -sf ../frontend/dist/index.html public/index.html
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod$ cd public/
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod/public$ ls -l
total 0
lrwxrwxrwx 1 wangqiang wangqiang   23 Jun  6 10:06 assets -> ../frontend/dist/assets
-rwxrwxrwx 1 wangqiang wangqiang    0 Jun  5 15:00 favicon.ico
lrwxrwxrwx 1 wangqiang wangqiang   27 Jun  8 09:45 index.html -> ../frontend/dist/index.html
-rwxrwxrwx 1 wangqiang wangqiang 1743 Jun  5 15:00 index.php
-rwxrwxrwx 1 wangqiang wangqiang   24 Jun  5 15:00 robots.txt


14、基于 FTP 上传 目录 learn-php-app-0605-prod 下的所有文件。总计大小为 150 MB 左右。上传时间过长,最张决定在生产环境中构建。目录:vendor、frontend/node_modules 不上传。如图5

基于 FTP 上传 目录 learn-php-app-0605-prod 下的所有文件。总计大小为 150 MB 左右。上传时间过长,最张决定在生产环境中构建。目录:vendor、frontend/node_modules 不上传

图5

15、安装 Node.js 与 Composer,Node.js 安装后需要重启实例


[root@iZ23wv7v5ggZ ~]# ~/oneinstack/install.sh --node

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

Download Nodejs...
--2023-06-08 10:45:47--  https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/v18.14.2/node-v18.14.2-linux-x64.tar.gz
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.15.130, 2402:f000:1:400::2
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.15.130|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 44201520 (42M) [application/octet-stream]
Saving to: ‘node-v18.14.2-linux-x64.tar.gz’

     0K .......... .......... .......... .......... ..........  0%  878K 49s
    50K .......... .......... .......... .......... ..........  0% 1.79M 36s
 43150K .......... .....                                      100% 14.2M=2.7s

2023-06-08 10:45:50 (15.7 MB/s) - ‘node-v18.14.2-linux-x64.tar.gz’ saved [44201520/44201520]

Nodejs installed successfully!
[xprober.php] found
####################Congratulations########################
Total OneinStack Install Time: 0 minutes

[root@iZ23wv7v5ggZ ~]# node -v
-bash: node: command not found

[root@iZ23wv7v5ggZ ~]# ~/oneinstack/addons.sh

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

What Are You Doing?
        1. Install/Uninstall PHP Composer
        2. Install/Uninstall fail2ban
        3. Install/Uninstall ngx_lua_waf
        4. Install/Uninstall Python3.6
        q. Exit
Please input the correct option: 1

Please select an action:
        1. install
        2. uninstall
Please input a number:(Default 1 press Enter) 1

PHP Composer installed successfully!

What Are You Doing?
        1. Install/Uninstall PHP Composer
        2. Install/Uninstall fail2ban
        3. Install/Uninstall ngx_lua_waf
        4. Install/Uninstall Python3.6
        q. Exit
Please input the correct option: q
[root@iZ23wv7v5ggZ ~]# composer -V
Composer version 2.5.7 2023-05-24 15:00:39
[root@iZ23wv7v5ggZ ~]# node -v
v18.14.2



16、当FTP上传完毕后,创建数据库(连接信息与 .env 中的保持一致),生成APP_KEY ,执行数据库迁移,构建前端与后端



[root@iZ23wv7v5ggZ frontend]# npm install
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.

added 359 packages, and audited 360 packages in 17s

41 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice
npm notice New minor version of npm available! 9.5.0 -> 9.7.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.7.1
npm notice Run npm install -g npm@9.7.1 to update!
npm notice
[root@iZ23wv7v5ggZ frontend]# SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef npm run build

> shopify-frontend-template-react@1.0.0 build
> vite build

vite v4.3.9 building for production...
✓ 1966 modules transformed.
dist/assets/empty-state-8039a1e1.svg      0.26 kB │ gzip:   0.20 kB
dist/index.html                           0.48 kB │ gzip:   0.33 kB
dist/assets/home-trophy-d70b3542.png     20.65 kB
dist/assets/index-37530742.css          371.48 kB │ gzip:  45.42 kB
dist/assets/ja-abb1af27.js                0.21 kB │ gzip:   0.15 kB
dist/assets/ko-ef9a93f5.js                0.21 kB │ gzip:   0.15 kB
dist/assets/th-32f01d1c.js                0.21 kB │ gzip:   0.15 kB
dist/assets/zh-4775ba45.js                0.21 kB │ gzip:   0.15 kB
dist/assets/vi-72f55a87.js                0.23 kB │ gzip:   0.17 kB
dist/assets/nb-79727cd5.js                0.24 kB │ gzip:   0.17 kB
dist/assets/tr-d5c962f0.js                0.24 kB │ gzip:   0.17 kB
dist/assets/de-5d4a5256.js                0.28 kB │ gzip:   0.20 kB
dist/assets/fi-e67a7779.js                0.28 kB │ gzip:   0.20 kB
dist/assets/nl-ed6c02b1.js                0.28 kB │ gzip:   0.20 kB
dist/assets/da-9b835bb8.js                0.31 kB │ gzip:   0.22 kB
dist/assets/cs-d855408e.js                0.32 kB │ gzip:   0.23 kB
dist/assets/sv-8ac62b51.js                0.37 kB │ gzip:   0.25 kB
dist/assets/en-d265ad8d.js                0.41 kB │ gzip:   0.26 kB
dist/assets/es-fd2f35f4.js                0.41 kB │ gzip:   0.29 kB
dist/assets/pt-227fd344.js                0.41 kB │ gzip:   0.29 kB
dist/assets/pt-PT-a0c51464.js             0.41 kB │ gzip:   0.29 kB
dist/assets/pl-ab15c7ea.js                0.42 kB │ gzip:   0.29 kB
dist/assets/fr-23e50d95.js                0.43 kB │ gzip:   0.29 kB
dist/assets/it-08f76780.js                0.45 kB │ gzip:   0.30 kB
dist/assets/en-df34a502.js                1.53 kB │ gzip:   0.77 kB
dist/assets/de-2ae5c9fa.js                1.72 kB │ gzip:   0.90 kB
dist/assets/fr-5253333d.js                1.83 kB │ gzip:   0.94 kB
dist/assets/polyfill-force-11887b4b.js    5.21 kB │ gzip:   2.03 kB
dist/assets/zh-CN-cf74d136.js             7.72 kB │ gzip:   3.26 kB
dist/assets/zh-TW-6a74a185.js             7.86 kB │ gzip:   3.36 kB
dist/assets/ko-2cf626e6.js                8.18 kB │ gzip:   3.39 kB
dist/assets/ja-6f78282b.js                8.35 kB │ gzip:   3.58 kB
dist/assets/en-c240dff3.js                9.95 kB │ gzip:   2.95 kB
dist/assets/vi-e4ef4fd6.js                9.97 kB │ gzip:   3.34 kB
dist/assets/th-2a34d5e0.js               10.14 kB │ gzip:   3.77 kB
dist/assets/sv-a901b08f.js               10.22 kB │ gzip:   3.27 kB
dist/assets/da-1564850b.js               10.30 kB │ gzip:   3.26 kB
dist/assets/nb-0a6d8490.js               10.35 kB │ gzip:   3.25 kB
dist/assets/pl-a603e9c2.js               10.39 kB │ gzip:   3.39 kB
dist/assets/cs-3c753a97.js               10.40 kB │ gzip:   3.50 kB
dist/assets/fi-c0a9d95f.js               10.63 kB │ gzip:   3.41 kB
dist/assets/tr-bd45be97.js               10.68 kB │ gzip:   3.39 kB
dist/assets/it-8bb02787.js               10.72 kB │ gzip:   3.32 kB
dist/assets/pt-PT-af188c06.js            10.85 kB │ gzip:   3.34 kB
dist/assets/nl-0772ea77.js               10.89 kB │ gzip:   3.25 kB
dist/assets/pt-BR-8a1d5660.js            10.94 kB │ gzip:   3.36 kB
dist/assets/es-5e0e20e7.js               10.95 kB │ gzip:   3.39 kB
dist/assets/de-a04fe3bd.js               11.11 kB │ gzip:   3.35 kB
dist/assets/fr-1848494a.js               11.31 kB │ gzip:   3.48 kB
dist/assets/index-41437cc7.js            53.59 kB │ gzip:  18.93 kB
dist/assets/polyfill-904c231f.js        133.64 kB │ gzip:  40.74 kB
dist/assets/index-991532e3.js           618.82 kB │ gzip: 164.28 kB

(!) Some chunks are larger than 500 kBs after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✓ built in 21.56s
[root@iZ23wv7v5ggZ frontend]# cd ..
[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - league/flysystem is locked to version 1.1.10 and an update of this package was not requested.
    - league/flysystem 1.1.10 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
  Problem 2
    - league/mime-type-detection is locked to version 1.11.0 and an update of this package was not requested.
    - league/mime-type-detection 1.11.0 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
  Problem 3
    - league/flysystem 1.1.10 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
    - laravel/framework v8.83.27 requires league/flysystem ^1.1 -> satisfiable by league/flysystem[1.1.10].
    - laravel/framework is locked to version v8.83.27 and an update of this package was not requested.

To enable extensions, verify that they are enabled in your .ini files:
    - /usr/local/php/etc/php.ini
    - /usr/local/php/etc/php.d/02-opcache.ini
    - /usr/local/php/etc/php.d/03-imagick.ini
    - /usr/local/php/etc/php.d/04-ldap.ini
    - /usr/local/php/etc/php.d/05-redis.ini
    - /usr/local/php/etc/php.d/07-mongodb.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-fileinfo` to temporarily ignore these required extensions.



17、安装 PHP 扩展 fileinfo 后,再次执行。报错:The Process class relies on proc_open, which is not available on your PHP installation.

[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 114 installs, 0 updates, 0 removals
proc_open is disabled so 'unzip' and '7z' commands cannot be used, zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Enabling proc_open and installing 'unzip' or '7z' (21.01+) may remediate them.
  - Downloading brick/math (0.11.0)
  - Downloading psr/log (2.0.0)
  - Downloading psr/cache (3.0.0)
  - Downloading doctrine/event-manager (2.0.0)
  - Downloading doctrine/deprecations (v1.1.1)
  - Downloading doctrine/cache (2.2.0)
  - Downloading doctrine/dbal (3.6.3)
  - Downloading doctrine/lexer (1.2.3)
  - Downloading symfony/polyfill-ctype (v1.27.0)
  - Downloading webmozart/assert (1.11.0)
  - Downloading dragonmantank/cron-expression (v3.3.2)
  - Downloading symfony/polyfill-php80 (v1.27.0)
  - Downloading symfony/polyfill-mbstring (v1.27.0)
  - Downloading symfony/var-dumper (v5.4.24)
  - Downloading symfony/polyfill-intl-normalizer (v1.27.0)
  - Downloading symfony/polyfill-intl-grapheme (v1.27.0)
  - Downloading symfony/string (v6.3.0)
  - Downloading symfony/deprecation-contracts (v3.3.0)
  - Downloading psr/container (1.1.2)
  - Downloading symfony/service-contracts (v2.5.2)
  - Downloading symfony/polyfill-php73 (v1.27.0)
  - Downloading symfony/console (v5.4.24)
  - Downloading monolog/monolog (2.9.1)
  - Downloading voku/portable-ascii (1.6.1)
  - Downloading phpoption/phpoption (1.9.1)
  - Downloading graham-campbell/result-type (v1.1.1)
  - Downloading vlucas/phpdotenv (v5.5.0)
  - Downloading symfony/css-selector (v6.3.0)
  - Downloading tijsverkoyen/css-to-inline-styles (2.2.6)
  - Downloading symfony/routing (v5.4.22)
  - Downloading symfony/process (v5.4.24)
  - Downloading symfony/polyfill-php72 (v1.27.0)
  - Downloading symfony/polyfill-intl-idn (v1.27.0)
  - Downloading symfony/mime (v5.4.23)
  - Downloading symfony/http-foundation (v5.4.24)
  - Downloading psr/event-dispatcher (1.0.0)
  - Downloading symfony/event-dispatcher-contracts (v3.3.0)
  - Downloading symfony/event-dispatcher (v6.3.0)
  - Downloading symfony/error-handler (v5.4.24)
  - Downloading symfony/http-kernel (v5.4.24)
  - Downloading symfony/finder (v5.4.21)
  - Downloading symfony/polyfill-iconv (v1.27.0)
  - Downloading egulias/email-validator (2.1.25)
  - Downloading swiftmailer/swiftmailer (v6.3.0)
  - Downloading ramsey/collection (2.0.0)
  - Downloading ramsey/uuid (4.7.4)
  - Downloading psr/simple-cache (1.0.1)
  - Downloading opis/closure (3.6.3)
  - Downloading symfony/translation-contracts (v3.3.0)
  - Downloading symfony/translation (v6.3.0)
  - Downloading nesbot/carbon (2.67.0)
  - Downloading league/mime-type-detection (1.11.0)
  - Downloading league/flysystem (1.1.10)
  - Downloading nette/utils (v4.0.0)
  - Downloading nette/schema (v1.2.3)
  - Downloading dflydev/dot-access-data (v3.0.2)
  - Downloading league/config (v1.2.0)
  - Downloading league/commonmark (2.4.0)
  - Downloading laravel/serializable-closure (v1.3.0)
  - Downloading doctrine/inflector (2.0.6)
  - Downloading laravel/framework (v8.83.27)
  - Downloading facade/ignition-contracts (1.0.2)
  - Downloading facade/flare-client-php (1.10.0)
  - Downloading facade/ignition (2.17.7)
  - Downloading fakerphp/faker (v1.22.0)
  - Downloading fideloper/proxy (4.4.2)
  - Downloading fruitcake/php-cors (v1.2.0)
  - Downloading fruitcake/laravel-cors (v3.0.0)
  - Downloading guzzlehttp/promises (2.0.0)
  - Downloading symfony/yaml (v6.3.0)
  - Downloading laravel/sail (v1.22.0)
  - Downloading nikic/php-parser (v4.15.5)
  - Downloading psy/psysh (v0.11.18)
  - Downloading laravel/tinker (v2.8.1)
  - Downloading hamcrest/hamcrest-php (v2.0.1)
  - Downloading mockery/mockery (1.6.1)
  - Downloading filp/whoops (2.15.2)
  - Downloading nunomaduro/collision (v5.11.0)
  - Downloading sebastian/version (3.0.2)
  - Downloading sebastian/type (3.2.1)
  - Downloading sebastian/resource-operations (3.0.3)
  - Downloading sebastian/recursion-context (4.0.5)
  - Downloading sebastian/object-reflector (2.0.4)
  - Downloading sebastian/object-enumerator (4.0.4)
  - Downloading sebastian/global-state (5.0.5)
  - Downloading sebastian/exporter (4.0.5)
  - Downloading sebastian/environment (5.1.5)
  - Downloading sebastian/diff (4.0.5)
  - Downloading sebastian/comparator (4.0.8)
  - Downloading sebastian/code-unit (1.0.8)
  - Downloading sebastian/cli-parser (1.0.1)
  - Downloading phpunit/php-timer (5.0.3)
  - Downloading phpunit/php-text-template (2.0.4)
  - Downloading phpunit/php-invoker (3.1.1)
  - Downloading phpunit/php-file-iterator (3.0.6)
  - Downloading theseer/tokenizer (1.2.1)
  - Downloading sebastian/lines-of-code (1.0.3)
  - Downloading sebastian/complexity (2.0.2)
  - Downloading sebastian/code-unit-reverse-lookup (2.0.3)
  - Downloading phpunit/php-code-coverage (9.2.26)
  - Downloading phar-io/version (3.2.1)
  - Downloading phar-io/manifest (2.0.3)
  - Downloading myclabs/deep-copy (1.11.1)
  - Downloading doctrine/instantiator (2.0.0)
  - Downloading phpunit/phpunit (9.6.8)
  - Downloading psr/http-message (1.1)
  - Downloading psr/http-factory (1.0.2)
  - Downloading ralouphie/getallheaders (3.0.3)
  - Downloading psr/http-client (1.0.2)
  - Downloading guzzlehttp/psr7 (2.5.0)
  - Downloading guzzlehttp/guzzle (7.7.0)
  - Downloading firebase/php-jwt (v6.5.0)
  - Downloading shopify/shopify-api (v5.0.0)
  - Downloading squizlabs/php_codesniffer (3.7.2)
  - Installing brick/math (0.11.0): Extracting archive
  - Installing psr/log (2.0.0): Extracting archive
  - Installing psr/cache (3.0.0): Extracting archive
  - Installing doctrine/event-manager (2.0.0): Extracting archive
  - Installing doctrine/deprecations (v1.1.1): Extracting archive
  - Installing doctrine/cache (2.2.0): Extracting archive
  - Installing doctrine/dbal (3.6.3): Extracting archive
  - Installing doctrine/lexer (1.2.3): Extracting archive
  - Installing symfony/polyfill-ctype (v1.27.0): Extracting archive
  - Installing webmozart/assert (1.11.0): Extracting archive
  - Installing dragonmantank/cron-expression (v3.3.2): Extracting archive
  - Installing symfony/polyfill-php80 (v1.27.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.27.0): Extracting archive
  - Installing symfony/var-dumper (v5.4.24): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.27.0): Extracting archive
  - Installing symfony/string (v6.3.0): Extracting archive
  - Installing symfony/deprecation-contracts (v3.3.0): Extracting archive
  - Installing psr/container (1.1.2): Extracting archive
  - Installing symfony/service-contracts (v2.5.2): Extracting archive
  - Installing symfony/polyfill-php73 (v1.27.0): Extracting archive
  - Installing symfony/console (v5.4.24): Extracting archive
  - Installing monolog/monolog (2.9.1): Extracting archive
  - Installing voku/portable-ascii (1.6.1): Extracting archive
  - Installing phpoption/phpoption (1.9.1): Extracting archive
  - Installing graham-campbell/result-type (v1.1.1): Extracting archive
  - Installing vlucas/phpdotenv (v5.5.0): Extracting archive
  - Installing symfony/css-selector (v6.3.0): Extracting archive
  - Installing tijsverkoyen/css-to-inline-styles (2.2.6): Extracting archive
  - Installing symfony/routing (v5.4.22): Extracting archive
  - Installing symfony/process (v5.4.24): Extracting archive
  - Installing symfony/polyfill-php72 (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-idn (v1.27.0): Extracting archive
  - Installing symfony/mime (v5.4.23): Extracting archive
  - Installing symfony/http-foundation (v5.4.24): Extracting archive
  - Installing psr/event-dispatcher (1.0.0): Extracting archive
  - Installing symfony/event-dispatcher-contracts (v3.3.0): Extracting archive
  - Installing symfony/event-dispatcher (v6.3.0): Extracting archive
  - Installing symfony/error-handler (v5.4.24): Extracting archive
  - Installing symfony/http-kernel (v5.4.24): Extracting archive
  - Installing symfony/finder (v5.4.21): Extracting archive
  - Installing symfony/polyfill-iconv (v1.27.0): Extracting archive
  - Installing egulias/email-validator (2.1.25): Extracting archive
  - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive
  - Installing ramsey/collection (2.0.0): Extracting archive
  - Installing ramsey/uuid (4.7.4): Extracting archive
  - Installing psr/simple-cache (1.0.1): Extracting archive
  - Installing opis/closure (3.6.3): Extracting archive
  - Installing symfony/translation-contracts (v3.3.0): Extracting archive
  - Installing symfony/translation (v6.3.0): Extracting archive
  - Installing nesbot/carbon (2.67.0): Extracting archive
  - Installing league/mime-type-detection (1.11.0): Extracting archive
  - Installing league/flysystem (1.1.10): Extracting archive
  - Installing nette/utils (v4.0.0): Extracting archive
  - Installing nette/schema (v1.2.3): Extracting archive
  - Installing dflydev/dot-access-data (v3.0.2): Extracting archive
  - Installing league/config (v1.2.0): Extracting archive
  - Installing league/commonmark (2.4.0): Extracting archive
  - Installing laravel/serializable-closure (v1.3.0): Extracting archive
  - Installing doctrine/inflector (2.0.6): Extracting archive
  - Installing laravel/framework (v8.83.27): Extracting archive
  - Installing facade/ignition-contracts (1.0.2): Extracting archive
  - Installing facade/flare-client-php (1.10.0): Extracting archive
  - Installing facade/ignition (2.17.7): Extracting archive
  - Installing fakerphp/faker (v1.22.0): Extracting archive
  - Installing fideloper/proxy (4.4.2): Extracting archive
  - Installing fruitcake/php-cors (v1.2.0): Extracting archive
  - Installing fruitcake/laravel-cors (v3.0.0): Extracting archive
  - Installing guzzlehttp/promises (2.0.0): Extracting archive
  - Installing symfony/yaml (v6.3.0): Extracting archive
  - Installing laravel/sail (v1.22.0): Extracting archive
  - Installing nikic/php-parser (v4.15.5): Extracting archive
  - Installing psy/psysh (v0.11.18): Extracting archive
  - Installing laravel/tinker (v2.8.1): Extracting archive
  - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
  - Installing mockery/mockery (1.6.1): Extracting archive
  - Installing filp/whoops (2.15.2): Extracting archive
  - Installing nunomaduro/collision (v5.11.0): Extracting archive
  - Installing sebastian/version (3.0.2): Extracting archive
  - Installing sebastian/type (3.2.1): Extracting archive
  - Installing sebastian/resource-operations (3.0.3): Extracting archive
  - Installing sebastian/recursion-context (4.0.5): Extracting archive
  - Installing sebastian/object-reflector (2.0.4): Extracting archive
  - Installing sebastian/object-enumerator (4.0.4): Extracting archive
  - Installing sebastian/global-state (5.0.5): Extracting archive
  - Installing sebastian/exporter (4.0.5): Extracting archive
  - Installing sebastian/environment (5.1.5): Extracting archive
  - Installing sebastian/diff (4.0.5): Extracting archive
  - Installing sebastian/comparator (4.0.8): Extracting archive
  - Installing sebastian/code-unit (1.0.8): Extracting archive
  - Installing sebastian/cli-parser (1.0.1): Extracting archive
  - Installing phpunit/php-timer (5.0.3): Extracting archive
  - Installing phpunit/php-text-template (2.0.4): Extracting archive
  - Installing phpunit/php-invoker (3.1.1): Extracting archive
  - Installing phpunit/php-file-iterator (3.0.6): Extracting archive
  - Installing theseer/tokenizer (1.2.1): Extracting archive
  - Installing sebastian/lines-of-code (1.0.3): Extracting archive
  - Installing sebastian/complexity (2.0.2): Extracting archive
  - Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive
  - Installing phpunit/php-code-coverage (9.2.26): Extracting archive
  - Installing phar-io/version (3.2.1): Extracting archive
  - Installing phar-io/manifest (2.0.3): Extracting archive
  - Installing myclabs/deep-copy (1.11.1): Extracting archive
  - Installing doctrine/instantiator (2.0.0): Extracting archive
  - Installing phpunit/phpunit (9.6.8): Extracting archive
  - Installing psr/http-message (1.1): Extracting archive
  - Installing psr/http-factory (1.0.2): Extracting archive
  - Installing ralouphie/getallheaders (3.0.3): Extracting archive
  - Installing psr/http-client (1.0.2): Extracting archive
  - Installing guzzlehttp/psr7 (2.5.0): Extracting archive
  - Installing guzzlehttp/guzzle (7.7.0): Extracting archive
  - Installing firebase/php-jwt (v6.5.0): Extracting archive
  - Installing shopify/shopify-api (v5.0.0): Extracting archive
  - Installing squizlabs/php_codesniffer (3.7.2): Extracting archive
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
 
In Process.php line 146:
 
  The Process class relies on proc_open, which is not available on your PHP installation.
 
 
install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]
 
 

18、参考:Jenkins 构建镜像时,报错:The Process class relies on proc_open, which is not available on your PHP installation.的解决 。 编辑 /usr/local/php/etc/php.ini,在 disable_functions 中删除 proc_open、proc_get_status


disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen

[root@iZ23wv7v5ggZ php]# service php-fpm restart
Redirecting to /bin/systemctl restart php-fpm.service
[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
81 packages you are using are looking for funding.
Use the `composer fund` command to find out more!



19、执行数据库迁移时失败,报错:SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes


[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# php artisan migrate
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migration table created successfully.
Migrating: 2019_08_19_000000_create_failed_jobs_table

   Illuminate\Database\QueryException

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `failed_jobs` add unique `failed_jobs_uuid_unique`(`uuid`))

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

      +9 vendor frames
  10  database/migrations/2019_08_19_000000_create_failed_jobs_table.php:24
      Illuminate\Support\Facades\Facade::__callStatic()

      +22 vendor frames
  33  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()


20、参考:阿里云RDS的参数配置,启用Innodb_large_prefix 。编辑 config/database.php,修改 ‘engine’ => null, 为 ‘engine’ => ‘InnoDB’,。再次执行数据库迁移,报错。SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘failed_jobs’ already exists。在数据库中删除掉所有表后,重新执行迁移。不再报错。


[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# php artisan migrate
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migration table created successfully.
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (13.03ms)
Migrating: 2021_05_03_050717_create_sessions_table
Migrated:  2021_05_03_050717_create_sessions_table (11.62ms)
Migrating: 2021_05_05_071311_add_scope_expires_access_token_to_sessions
Migrated:  2021_05_05_071311_add_scope_expires_access_token_to_sessions (9.72ms)
Migrating: 2021_05_11_151158_add_online_access_info_to_sessions
Migrated:  2021_05_11_151158_add_online_access_info_to_sessions (9.32ms)
Migrating: 2021_05_17_152611_change_sessions_user_id_type
Migrated:  2021_05_17_152611_change_sessions_user_id_type (48.28ms)



21、构建后端。


[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# composer build
> composer build-frontend-links
> ln -sf ../frontend/dist/assets public/assets && ln -sf ../frontend/dist/index.html public/index.html



22、访问应用首页:https://learn-php-app-0605-prod.shuijingwanwq.com/ 。响应 403。如图6

访问应用首页:https://learn-php-app-0605-prod.shuijingwanwq.com/ 。响应 403

图6

23、查看虚拟主机配置文件


[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# cat /usr/local/nginx/conf/vhost/learn-php-app-0605-prod.shuijingwanwq.com.conf
server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/learn-php-app-0605-prod.shuijingwanwq.com.crt;
  ssl_certificate_key /usr/local/nginx/conf/ssl/learn-php-app-0605-prod.shuijingwanwq.com.key;
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
  ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256;
  ssl_conf_command Ciphersuites TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256;
  ssl_conf_command Options PrioritizeChaCha;
  ssl_prefer_server_ciphers on;
  ssl_session_timeout 10m;
  ssl_session_cache shared:SSL:10m;
  ssl_buffer_size 2k;
  add_header Strict-Transport-Security max-age=15768000;
  ssl_stapling on;
  ssl_stapling_verify on;
  server_name learn-php-app-0605-prod.shuijingwanwq.com;
  access_log /data/wwwlogs/learn-php-app-0605-prod.shuijingwanwq.com_nginx.log combined;
  index index.html index.htm index.php;
  root /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com;
  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 learn-php-app-0605-prod.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 learn-php-app-0605-prod.shuijingwanwq.com]# ^C
[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# cat /usr/local/nginx/conf/rewrite/laravel.conf
location / {
  try_files $uri $uri/ /index.php?$query_string;
}
[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]#



24、参考模板中的 nginx.conf,其内容如下


user www-data www-data;

events {
    worker_connections 1024;
}

http {
    index index.php index.html;

    upstream php {
        server 127.0.0.1:9000;
    }

    server {
        include /etc/nginx/mime.types;
        include /etc/nginx/default.d/*.conf;

        listen PORT;
        server_name 0.0.0.0;
        root /app/public;

        location / {
            try_files $uri $uri/ /index.php?$args;
        }

        location ~ [^/]\.php(/|$) {
            include /etc/nginx/fastcgi_params;

            try_files $uri $uri/ /index.php?$uri;

            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;

            fastcgi_pass   php;
            fastcgi_index  index.php;
        }
    }
}


25、编辑 /usr/local/nginx/conf/vhost/learn-php-app-0605-prod.shuijingwanwq.com.conf


  index index.php index.html;
  root /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com/public;


26、响应 500,开启 debug,编辑 .env。报错:TypeError
Shopify\Utils::sanitizeShopDomain(): Argument #1 ($shop) must be of type string, null given, called in /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com/app/Lib/AuthRedirection.php on line 17 。不用理会,符合预期。如图7

报错:TypeErrorShopify\Utils::sanitizeShopDomain(): Argument #1 ($shop) must be of type string, null given, called in /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com/app/Lib/AuthRedirection.php on line 17

图7


APP_ENV=local
APP_DEBUG=true


27、更新合作伙伴仪表板中的 URL。如图8

更新合作伙伴仪表板中的 URL

图8

28、在合作伙伴仪表板中,转到应用程序的概览页面。在“测试您的应用”部分中,单击“选择商店”,然后选择一个商店来测试应用。如图9

在合作伙伴仪表板中,转到应用程序的概览页面。在“测试您的应用”部分中,单击“选择商店”,然后选择一个商店来测试应用

图9

29、安装应用时,报错:ops, something went wrong. 。原因应该在于请求参数有误。如图10

安装应用时,报错:ops, something went wrong. 。原因应该在于请求参数有误

图10


client_id: not_defined
scope: not_defined
redirect_uri: https://not_defined/api/auth/callback
state: b27be356-0010-43ae-b3b8-90a337314c0c
grant_options[]: 


30、编辑 .env,参考 .env.testing


APP_NAME="Shopify PHP App 0605 Prod"
APP_ENV=production
APP_KEY=base64:tPbLjWcISYL3Z/HS+OQS2GXvMPb0A7GlvNv6iFwFG6A=
APP_DEBUG=false
APP_URL=https://learn-php-app-0605-prod.shuijingwanwq.com

SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef
SHOPIFY_API_SECRET=4de64aa8281e97055cf7698bbe56039e
SCOPES=write_products
HOST=learn-php-app-0605-prod.shuijingwanwq.com

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=**************
DB_PORT=3306
DB_DATABASE=learn_php_app_0605_prod
DB_USERNAME=learn_php_app_0605_prod
DB_PASSWORD=*********



31、不再报错。如图11

不再报错

图11

32、点击安装应用后,进入店铺后台,但是页面预览为空白。如图12

点击安装应用后,进入店铺后台,但是页面预览为空白

图12

33、重新构建前端与后端后,卸载应用。如图13

重新构建前端与后端后,卸载应用

图13

34、再次安装,刷新页面,页面不再空白,符合预期。如图14

再次安装,刷新页面,页面不再空白,符合预期

图14

]]>
https://www.shuijingwanwq.com/2023/07/13/7855/feed/ 1
Laravel 8.x(LaraBBS) 部署至 阿里云 ECS,基于 MySQL、Redis、Supervisor、Crontab 实现 https://www.shuijingwanwq.com/2022/01/28/5867/ https://www.shuijingwanwq.com/2022/01/28/5867/#respond Fri, 28 Jan 2022 09:14:42 +0000 https://www.shuijingwanwq.com/?p=5867 浏览量: 201 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): app-wangqiang-larabbs.shuijingwanwq.com
domain=app-wangqiang-larabbs.shuijingwanwq.com

Please input the directory for the domain:app-wangqiang-larabbs.shuijingwanwq.com :
(Default directory: /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com): 
Virtual Host Directory=/data/wwwroot/app-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 app-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/app-wangqiang-larabbs.shuijingwanwq.com/app-wangqiang-larabbs.shuijingwanwq.com.key
[Fri Jan  7 10:36:10 CST 2022] Single domain='app-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='app-wangqiang-larabbs.shuijingwanwq.com'
[Fri Jan  7 10:36:15 CST 2022] Verifying: app-wangqiang-larabbs.shuijingwanwq.com
[Fri Jan  7 10:36:19 CST 2022] app-wangqiang-larabbs.shuijingwanwq.com:Verify error:DNS problem: NXDOMAIN looking up A for app-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 中添加相应的域名:app-wangqiang-larabbs.shuijingwanwq.com 。如图9
检查此域是否存在 DNS 记录。先在 DNS 中添加相应的域名:app-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): app-wangqiang-larabbs.shuijingwanwq.com
domain=app-wangqiang-larabbs.shuijingwanwq.com

Please input the directory for the domain:app-wangqiang-larabbs.shuijingwanwq.com :
(Default directory: /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com): 
Virtual Host Directory=/data/wwwroot/app-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='app-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='app-wangqiang-larabbs.shuijingwanwq.com'
[Fri Jan  7 10:48:29 CST 2022] Verifying: app-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/app-wangqiang-larabbs.shuijingwanwq.com/app-wangqiang-larabbs.shuijingwanwq.com.cer 
[Fri Jan  7 10:48:38 CST 2022] Your cert key is in  /root/.acme.sh/app-wangqiang-larabbs.shuijingwanwq.com/app-wangqiang-larabbs.shuijingwanwq.com.key 
[Fri Jan  7 10:48:39 CST 2022] The intermediate CA cert is in  /root/.acme.sh/app-wangqiang-larabbs.shuijingwanwq.com/ca.cer 
[Fri Jan  7 10:48:39 CST 2022] And the full chain certs is there:  /root/.acme.sh/app-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/app-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:                  app-wangqiang-larabbs.shuijingwanwq.com
Virtualhost conf:             /usr/local/nginx/conf/vhost/app-wangqiang-larabbs.shuijingwanwq.com.conf
Directory of:                 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com
Rewrite rule:                 /usr/local/nginx/conf/rewrite/laravel.conf
Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/app-wangqiang-larabbs.shuijingwanwq.com.crt
SSL Private Key:              /usr/local/nginx/conf/ssl/app-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: app-wangqiang-larabbs.shuijingwanwq.com

Please input the password: s0etwJ9DGm3e6CwP

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

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

You user name is : app-wangqiang-larabbs.shuijingwanwq.com
You Password is : xxxxxxxxxx
You directory is : /data/wwwroot/app-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/app-wangqiang-larabbs.shuijingwanwq.com 。如图12
打开 FlashFXP,通过 FTP 上传源代码至 目录:/data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com

图12

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

图13

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

图14

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

图15



[root@iZ23wv7v5ggZ oneinstack]# cat /usr/local/nginx/conf/vhost/app-wangqiang-larabbs.shuijingwanwq.com.conf
server {
  listen 80;
  listen 443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/app-wangqiang-larabbs.shuijingwanwq.com.crt;
  ssl_certificate_key /usr/local/nginx/conf/ssl/app-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 app-wangqiang-larabbs.shuijingwanwq.com;
  access_log /data/wwwlogs/app-wangqiang-larabbs.shuijingwanwq.com_nginx.log combined;
  index index.html index.htm index.php;
  root /data/wwwroot/app-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 app-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/app-wangqiang-larabbs.shuijingwanwq.com/.env。 20、执行数据库迁移与填充,执行成功。如图17
执行数据库迁移与填充,执行成功

图17



[root@iZ23wv7v5ggZ app-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 app-wangqiang-larabbs.shuijingwanwq.com]# 



21、打开网址:https://app-wangqiang-larabbs.shuijingwanwq.com/ ,提示:InvalidArgumentException No hint path defined for [sudosu]. 。如图18
打开网址:https://app-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 app-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

<pre class="wp-block-syntaxhighlighter-code">

[root@iZ23wv7v5ggZ app-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 app-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 app-wangqiang-larabbs.shuijingwanwq.com]# 


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

图22

<pre class="wp-block-syntaxhighlighter-code">

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/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/guzzle/src/Middleware.php(69): GuzzleHttp\Exception\RequestException::create()
#1 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp\{closure}()
#2 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler()
#3 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Promise\TaskQueue->run()
#5 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#6 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#7 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#8 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/guzzle/src/Client.php(187): GuzzleHttp\Promise\Promise->wait()
#10 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/guzzlehttp/guzzle/src/ClientTrait.php(44): GuzzleHttp\Client->request()
#11 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/app/Handlers/SlugTranslateHandler.php(42): GuzzleHttp\Client->get()
#12 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/app/Jobs/TranslateSlug.php(29): App\Handlers\SlugTranslateHandler->translate()
#13 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Jobs\TranslateSlug->handle()
#14 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#15 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#16 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#17 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call()
#18 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate\Container\Container->call()
#19 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}()
#20 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#21 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\Pipeline\Pipeline->then()
#22 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(120): Illuminate\Bus\Dispatcher->dispatchNow()
#23 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}()
#24 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#25 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(122): Illuminate\Pipeline\Pipeline->then()
#26 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware()
#27 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\Queue\CallQueuedHandler->call()
#28 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(428): Illuminate\Queue\Jobs\Job->fire()
#29 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(378): Illuminate\Queue\Worker->process()
#30 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(329): Illuminate\Queue\Worker->runJob()
#31 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(117): Illuminate\Queue\Worker->runNextJob()
#32 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Console\WorkCommand->runWorker()
#33 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#34 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#35 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#36 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#37 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call()
#38 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call()
#39 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/symfony/console/Command/Command.php(298): Illuminate\Console\Command->execute()
#40 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run()
#41 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/symfony/console/Application.php(1005): Illuminate\Console\Command->run()
#42 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand()
#43 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#44 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\Component\Console\Application->run()
#45 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run()
#46 /data/wwwroot/app-wangqiang-larabbs.shuijingwanwq.com/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
#47 {main}

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


[root@iZ23wv7v5ggZ app-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/app-wangqiang-larabbs-worker.ini 文件,启动并监视 queue:work 进程。指示 Supervisor 运行 2 个 queue:work 进程并监视所有进程。如图24
创建一个 /etc/supervisord.d/app-wangqiang-larabbs-worker.ini 文件,启动并监视 queue:work 进程。指示 Supervisor 运行 2 个 queue:work 进程并监视所有进程

图24



[root@iZ23wv7v5ggZ supervisord.d]# cat app-wangqiang-larabbs-worker.ini 
[program:app-wangqiang-larabbs-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /data/wwwroot/app-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/app-wangqiang-larabbs.shuijingwanwq.com/worker.log
stopwaitsecs=600
[root@iZ23wv7v5ggZ supervisord.d]# 



31、创建配置文件后,你可以更新 Supervisor 配置并使用以下命令启动进程。报错:unix:///var/run/supervisor/supervisor.sock no such file
<pre class="wp-block-syntaxhighlighter-code">

[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


</pre>
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
app-wangqiang-larabbs-worker:app-wangqiang-larabbs-worker_00   FATAL     can't find command 'php'
app-wangqiang-larabbs-worker:app-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/app-wangqiang-larabbs-worker.ini
[root@iZ23wv7v5ggZ ~]# cat /etc/supervisord.d/app-wangqiang-larabbs-worker.ini
[program:app-wangqiang-larabbs-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /data/wwwroot/app-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/app-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
app-wangqiang-larabbs-worker:app-wangqiang-larabbs-worker_00   BACKOFF   Exited too quickly (process log may have details)
app-wangqiang-larabbs-worker:app-wangqiang-larabbs-worker_01   STARTING  
[root@iZ23wv7v5ggZ ~]# 


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

图29



[root@iZ23wv7v5ggZ app-wangqiang-larabbs.shuijingwanwq.com]# cat worker.log 

   Error 

  Class 'Aws\Sqs\SqsClient' not found

  at /data/wwwroot/app-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/app-wangqiang-larabbs.shuijingwanwq.com/artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

      +18 vendor frames 
  19  /data/wwwroot/app-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/app-wangqiang-larabbs-worker.ini
[root@iZ23wv7v5ggZ ~]# cat /etc/supervisord.d/app-wangqiang-larabbs-worker.ini
[program:app-wangqiang-larabbs-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /data/wwwroot/app-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/app-wangqiang-larabbs.shuijingwanwq.com/worker.log
stopwaitsecs=600
[root@iZ23wv7v5ggZ app-wangqiang-larabbs.shuijingwanwq.com]# service supervisord restart
Redirecting to /bin/systemctl restart supervisord.service
[root@iZ23wv7v5ggZ app-wangqiang-larabbs.shuijingwanwq.com]# supervisorctl status
app-wangqiang-larabbs-worker:app-wangqiang-larabbs-worker_00   RUNNING   pid 2277, uptime 0:00:07
app-wangqiang-larabbs-worker:app-wangqiang-larabbs-worker_01   RUNNING   pid 2276, uptime 0:00:07




37、测试队列是否生效,重启 ECS 后,新建一个话题,其详情页面的网址为:https://app-wangqiang-larabbs.shuijingwanwq.com/topics/105 。刷新一下,其会 301 跳转至:https://app-wangqiang-larabbs.shuijingwanwq.com/topics/105/a-german 。表明队列生效中。如图31
测试队列是否生效,重启 ECS 后,新建一个话题,其详情页面的网址为:https://app-wangqiang-larabbs.shuijingwanwq.com/topics/105 。刷新一下,其会 301 跳转至:https://app-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/app-wangqiang-larabbs.shuijingwanwq.com/artisan schedule:run >> /dev/null 2>&1


]]>
https://www.shuijingwanwq.com/2022/01/28/5867/feed/ 0
在 Yii 2 中,基于 Hprose 实现 RPC 服务,报错:passthru() has been disabled for security reasons 的解决 https://www.shuijingwanwq.com/2018/08/13/2821/ https://www.shuijingwanwq.com/2018/08/13/2821/#respond Mon, 13 Aug 2018 06:26:45 +0000 http://www.shuijingwanwq.com/?p=2821 浏览量: 273 1、在本地环境中,在 Postman 中 POST ,http://api.aims-api.localhost/v1/tasks?group_id=015ce30b116ce86058fa6ab4fea4ac63 ,响应成功


{
	"group_id":"015ce30b116ce86058fa6ab4fea4ac63",
	"title":"标题 - 20180809 - 1",
	"source":"xcontent",
	"media_path":"http://www.media_path.com",
	"type":"mc_vca",
	"callback_url":"http://www.callback_url.com",
	"dlurl":"http://www.dlurl.com"
}




{
    "code": 10000,
    "message": "提交任务成功",
    "data": {
        "id": 14,
        "group_id": "015ce30b116ce86058fa6ab4fea4ac63",
        "task_uuid": "B914E6E49B9F11E8872454EE75D2EBC1",
        "title": "标题 - 20180809 - 1",
        "source": "xcontent",
        "media_path": "http://www.media_path.com",
        "dlurl": "http://www.dlurl.com",
        "callback_url": "http://www.callback_url.com",
        "ai_task_type": "mc_vca",
        "ai_task_status": 0,
        "pri": 2,
        "pri_updated_at": 0,
        "status": 1,
        "created_at": 1533797093,
        "updated_at": 1533797093
    }
}


2、在开发环境中,在 Postman 中 POST ,http://wjdev2.chinamcloud.com:8659/v1/tasks?group_id=015ce30b116ce86058fa6ab4fea4ac63 ,响应失败,如图2
passthru() has been disabled for security reasons

图2



{
	"group_id":"015ce30b116ce86058fa6ab4fea4ac63",
	"title":"标题 - 20180809 - 1",
	"source":"xcontent",
	"media_path":"http://www.media_path.com",
	"type":"mc_vca",
	"callback_url":"http://www.callback_url.com",
	"dlurl":"http://www.dlurl.com"
}




{
{
    "name": "Exception",
    "message": "passthru() has been disabled for security reasons",
    "code": 0,
    "type": "Exception",
    "file": "/sobey/www/aims-api/vendor/hprose/hprose/src/Hprose/Client.php",
    "line": 383,
    "stack-trace": [
        "#0 /sobey/www/aims-api/vendor/hprose/hprose/src/Hprose/Client.php(477): Hprose\\Client->decode('Es49\"passthru()...', Array, Object(stdClass))",
        "#1 /sobey/www/aims-api/vendor/hprose/hprose/src/Hprose/Client.php(489): Hprose\\Client->syncInvokeHandler('task_create', Array, Object(stdClass))",
        "#2 /sobey/www/aims-api/vendor/hprose/hprose/src/Hprose/Client.php(103): Hprose\\Client->invokeHandler('task_create', Array, Object(stdClass))",
        "#3 /sobey/www/aims-api/vendor/hprose/hprose/src/Hprose/Client.php(608): Hprose\\Client->Hprose\\{closure}('task_create', Array, Object(stdClass))",
        "#4 /sobey/www/aims-api/vendor/hprose/hprose/src/Hprose/Proxy.php(91): Hprose\\Client->invoke('task_create', Array)",
        "#5 /sobey/www/aims-api/common/logics/rpc/Task.php(106): Hprose\\Proxy->__call('task_create', Array)",
        "#6 /sobey/www/aims-api/common/services/TaskService.php(30): common\\logics\\rpc\\Task->create(Array, '0.0', 'zh-CN')",
        "#7 /sobey/www/aims-api/api/rests/task/CreateAction.php(65): common\\services\\TaskService->create(Object(api\\modules\\v1\\models\\rpc\\Task))",
        "#8 [internal function]: api\\rests\\task\\CreateAction->run()",
        "#9 /sobey/www/aims-api/vendor/yiisoft/yii2/base/Action.php(94): call_user_func_array(Array, Array)",
        "#10 /sobey/www/aims-api/vendor/yiisoft/yii2/base/Controller.php(157): yii\\base\\Action->runWithParams(Array)",
        "#11 /sobey/www/aims-api/vendor/yiisoft/yii2/base/Module.php(528): yii\\base\\Controller->runAction('create', Array)",
        "#12 /sobey/www/aims-api/vendor/yiisoft/yii2/web/Application.php(103): yii\\base\\Module->runAction('v1/task/create', Array)",
        "#13 /sobey/www/aims-api/vendor/yiisoft/yii2/base/Application.php(386): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))",
        "#14 /sobey/www/aims-api/api/web/index.php(17): yii\\base\\Application->run()",
        "#15 {main}"
    ]
}


3、编辑接口(RPC客户端)的 Dockerfile,在 disable_functions 中删除 passthru


FROM registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php71:0.2.4

MAINTAINER wangqiang@chinamcloud.com

RUN sed -i 's/open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv/;open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv:\/usr\/local\/php/g' /usr/local/php/etc/php.ini && \
    sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /usr/local/php/etc/php.ini && \
    sed -i 's/disable_functions = exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show/disable_functions = system,shell_exec,escapeshellarg,escapeshellcmd,dl,popen,show/g' /usr/local/php/etc/php.ini

COPY code /sobey/www/aims-api
COPY code/build/c_files/ /

RUN chown -R nginx:nginx /sobey/www/ && \
    rm -rf /etc/nginx/conf.d/status.conf && \
    chmod +x /usr/local/bin/composer && \
    cd /sobey/www/aims-api && \
    composer install


4、编辑RPC服务端的 Dockerfile,在 disable_functions 中删除 passthru


FROM registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php71:0.2.4

MAINTAINER wangqiang@chinamcloud.com

RUN sed -i 's/open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv/;open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv:\/usr\/local\/php/g' /usr/local/php/etc/php.ini && \
    sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /usr/local/php/etc/php.ini && \
    sed -i 's/disable_functions = exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show/disable_functions = system,shell_exec,escapeshellarg,escapeshellcmd,dl,popen,show/g' /usr/local/php/etc/php.ini

COPY code /sobey/www/aims-rpc
COPY code/build/c_files/ /

RUN chown -R nginx:nginx /sobey/www/ && \
    rm -rf /etc/nginx/conf.d/status.conf && \
    chmod +x /usr/local/bin/composer && \
    cd /sobey/www/aims-rpc && \
    composer install


5、在开发环境中,在 Postman 中 POST ,http://wjdev2.chinamcloud.com:8659/v1/tasks?group_id=015ce30b116ce86058fa6ab4fea4ac63 ,响应成功


{
	"group_id":"015ce30b116ce86058fa6ab4fea4ac63",
	"title":"标题 - 20180811 - 6",
	"source":"xContent",
	"media_path":"http://www.media_path.com",
	"type":"mc_vca",
	"callback_url":"http://www.callback_url.com",
	"dlurl":"http://www.dlurl.com"
}




{
    "code": 10000,
    "message": "提交任务成功",
    "data": {
        "id": 5,
        "group_id": "015ce30b116ce86058fa6ab4fea4ac63",
        "task_uuid": "D9C9092A9D4711E8AD5E54EE75D2EdC1",
        "title": "标题 - 20180811 - 5",
        "source": "xContent",
        "media_path": "http://www.media_path.com",
        "dlurl": "http://www.dlurl.com",
        "callback_url": "http://www.callback_url.com",
        "ai_task_type": "mc_vca",
        "ai_task_status": 0,
        "pri": 2,
        "pri_updated_at": 0,
        "status": 1,
        "created_at": 1533980458,
        "updated_at": 1533980458
    }
}


]]>
https://www.shuijingwanwq.com/2018/08/13/2821/feed/ 0
Jenkins 构建镜像时,报错:The Process class relies on proc_open, which is not available on your PHP installation.的解决 https://www.shuijingwanwq.com/2018/07/17/2796/ https://www.shuijingwanwq.com/2018/07/17/2796/#comments Tue, 17 Jul 2018 07:27:30 +0000 http://www.shuijingwanwq.com/?p=2796 浏览量: 294 1、由于无法从 dist 下载 yiisoft/yii2-composer (2.0.7),现在尝试从源代码下载,Process 类依赖于 proc_open ,这在PHP安装中不可用,如图1
由于无法从 dist 下载 yiisoft/yii2-composer (2.0.7),现在尝试从源代码下载,Process 类依赖于 proc_open ,这在PHP安装中不可用

图1

2、编辑 Dockerfile,在 disable_functions 中删除 proc_open、proc_close


FROM registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php71:0.2.4

MAINTAINER wjtester@sobey.com

RUN sed -i 's/open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv/;open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv:\/usr\/local\/php/g' /usr/local/php/etc/php.ini && \
    sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /usr/local/php/etc/php.ini && \
    sed -i 's/disable_functions = exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show/disable_functions = system,passthru,shell_exec,escapeshellarg,escapeshellcmd,dl,popen,show/g' /usr/local/php/etc/php.ini

COPY code /sobey/www/pcs-api
COPY code/build/c_files/ /

RUN chown -R nginx:nginx /sobey/www/ && \
    rm -rf /etc/nginx/conf.d/status.conf && \
    chmod +x /usr/local/bin/composer && \
    cd /sobey/www/pcs-api && \
    composer install


3、之前 proc_open、proc_close 也是禁用的,可以正常构建,原因在于可以从 dist 正常下载 yiisoft/yii2-composer (2.0.6),因此,不会从源代码下载,也就不会使用到 proc_open、proc_close,如图2
之前 proc_open、proc_close 也是禁用的,可以正常构建,原因在于可以从 dist 正常下载 yiisoft/yii2-composer (2.0.6),因此,不会从源代码下载,也就不会使用到 proc_open、proc_close

图2

4、重新构建镜像,从源代码下载成功,构建成功,如图3
重新构建镜像,从源代码下载成功,构建成功

图3

]]>
https://www.shuijingwanwq.com/2018/07/17/2796/feed/ 2