There is no problem not worth solving, and no technology not worth learning!

Uninstall PHP 7.4 in CentOS 7.7 in Alibaba Cloud and install PHP 8

PHP 版本 7.4 已经不再符合 Shopify 应用的运行条件。需要升级至 8.1 版本,尽量与本地环境保持一致

1. Reference:Based on Alibaba Cloud’s ECS and RDS, the personal blog migration has been upgraded to: Docker (based on budget considerations, ultimately not realized), LNMP (CentOS 7.7, Nginx 1.16, MySQL 5.7, PHP 7.4), the process of HTTPS , the previous environment was based on the automatic installation of OneInstack. PHP version 7.4 is no longer eligible for Shopify applications. It needs to be upgraded to version 8.1, trying to be consistent with the local environment. as shown in Figure 1

PHP 版本 7.4 已经不再符合 Shopify 应用的运行条件。需要升级至 8.1 版本,尽量与本地环境保持一致
Figure 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


2. In Alibaba Cloud, create a snapshot of the disk to avoid data loss during the operation. as shown in Figure 2

在阿里云中,将磁盘创建快照,避免操作过程中导致数据丢失
Figure 2

3. Configure the CentOS 7 yum source, refer to:“CentOS, Ubuntu, Debian dependency source configuration” . Error when updating cache: file contains no section headers. loaded plugins: fastestmirror


[root@iZ23wv7v5ggZ ~]# cd /etc/yum.repos.d/
[root@iZ23wv7v5ggZ yum.repos.d]# ls -l
total 8
-rw-r--r-- 1 root root 2523 Jan 28  2022 CentOS-Base.repo
-rw-r--r-- 1 root root  664 Jan 28  2022 epel.repo
[root@iZ23wv7v5ggZ yum.repos.d]# rm -rf /etc/yum.repos.d/*.repo
[root@iZ23wv7v5ggZ yum.repos.d]# ls -l
total 0
[root@iZ23wv7v5ggZ yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7221  100  7221    0     0   3763      0  0:00:01  0:00:01 --:--:--  3762
[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  7215  100  7215    0     0  11531      0 --:--:-- --:--:-- --:--:-- 11525
[root@iZ23wv7v5ggZ yum.repos.d]# yum makecache
Loaded plugins: fastestmirror


File contains no section headers.
file: file:///etc/yum.repos.d/CentOS-Base.repo, line: 1
'\n'
[root@iZ23wv7v5ggZ yum.repos.d]# ls -l
total 16
-rw-r--r-- 1 root root 7221 Jun  6 14:32 CentOS-Base.repo
-rw-r--r-- 1 root root 7215 Jun  6 14:32 epel.repo
[root@iZ23wv7v5ggZ yum.repos.d]#



4. Check the content of the file /etc/yum.repos.d/centos-base.repo, it is no longer the correct format, and the download failed. The source of Alibaba Cloud no longer exists. as shown in Figure 3

查看文件 /etc/yum.repos.d/CentOS-Base.repo 的内容,其已经不再是正确的格式,下载失败了。阿里云的源已经不存在
Figure 3

5. Openhttps://mirrors.aliyun.com/repo/, confirm that the source centos-7.repo and epel-7.repo can be downloaded. Decided to manually edit the save content, and then update the cache. Error:[Errno 14]HTTP Error 502 – Bad Gateway. as shown in Figure 4

打开 https://mirrors.aliyun.com/repo/ ,确认源 Centos-7.repo 与 epel-7.repo 是可以下载的。决定手动编辑保存内容,然后更新缓存。报错:[Errno 14] HTTP Error 502 - Bad Gateway
Figure 4

[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
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
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.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.aliyun.com/epel/7/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.aliyun.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/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.aliyun.com/centos/7/updates/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.
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
Metadata Cache Created



6. After stopping the instance, roll back the cloud disk. as shown in Figure 5

停止实例后,回滚云盘
Figure 5

7, update the cache, still report an error.


[root@iZ23wv7v5ggZ yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
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.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.aliyun.com/epel/7/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.aliyun.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/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
http://mirrors.aliyun.com/centos/7/updates/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.
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 502 - Bad Gateway
Trying other mirror.
Metadata Cache Created



8. Reference:In Alibaba Cloud ECS, CentOS 7 migration (replace) to Alibaba Cloud Linux 3 . Open URL:https://oneinstack.com/auto/, based on the automatic installation of OneInStack, LNMP, PHP version 8.1, and copy the installation command are selected, as shown in Figure 6

参考:在阿里云的 ECS 中,CentOS 7 迁移(更换)至 Alibaba Cloud Linux 3 https://www.shuijingwanwq.com/2023/07/06/7805/。打开网址:https://oneinstack.com/auto/ ,基于 OneinStack 的自动安装,选择了 LNMP,PHP 版本 8.1,复制安装命令
Figure 6

9. After starting the ECS instance, enter the Alibaba Cloud Linux server based on Putty, paste the installation command, and then keep it stuck at –php_extensions fileinfo. Press Ctrl + C to stop the installation process. as shown in Figure 7

启动 ECS 实例后,基于 PuTTY 进入 Alibaba Cloud Linux 服务器中,粘贴执行安装命令,然后一直卡在 --php_extensions fileinfo 处。按 Ctrl + C 中止掉安装过程
Figure 7

[root@iZ23wv7v5ggZ ~]# wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --nginx_option 1 --php_option 11 --phpcache_option 1 --php_extensions imagick,fileinfo,imap,ldap,redis,mongodb --pureftpd  --redis


10. In the installation command, the PHP extension only keeps Imagick, Redis, and other extensions will be installed on demand. If the components are not installed before, the subsequent installation will be supplemented, and the unified entrance is ./install.sh . Still stuck at –php_extensions FileInfo, confirm that OneInStack does not support the installation of extended FileInfo under PHP 8.1. Next, try to install this extension yourself.


[root@iZ23wv7v5ggZ ~]# wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --nginx_option 1 --php_option 11 --phpcache_option 1 --php_extensions imagick,redis --pureftpd  --redis
[root@iZ23wv7v5ggZ oneinstack]# ./install.sh

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

Please input SSH port(Default: 22):

Do you want to install Web server? [y/n]: n

Do you want to install Database? [y/n]: n

Do you want to install PHP? [y/n]: n

Do you want to install opcode cache of the PHP? [y/n]: n

Please select PHP extensions:
         0. Do not install
         1. Install zendguardloader(PHP<=5.6)
         2. Install ioncube
         3. Install sourceguardian(PHP<=7.2)
         4. Install imagick
         5. Install gmagick
         6. Install fileinfo
         7. Install imap
         8. Install ldap
         9. Install phalcon(PHP>=5.5)
        10. Install yaf(PHP>=7.0)
        11. Install redis
        12. Install memcached
        13. Install memcache
        14. Install mongodb
        15. Install swoole
        16. Install xdebug(PHP>=5.5)
Please input numbers:(Default '4 11 12' press Enter) 6



12. Check the PHP version


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



13. My ECS memory is 1 GB configuration. Compiling FileInfo takes up a lot of memory, which is the direct cause of incompilation. It was finally decided to improve the configuration of the ECS, and the memory was increased to 2 GB. Reference:When compiling and installing PHP extension FileInfo in Alibaba Cloud ECS, the solution is stuck (improve memory configuration)

Linux Server Operations, Deployment & Production Troubleshooting

If your website or backend service runs on a Linux server and you are facing unstable access, Nginx configuration issues, MySQL / Redis errors, Docker service failures, full disk usage, or high CPU / memory usage, feel free to contact me for remote troubleshooting.

Ideal For:
✅ Website downtime or unstable access
✅ Nginx / PHP-FPM configuration issues
✅ MySQL / Redis performance or connection problems
✅ Docker service deployment and maintenance
✅ Server migration and environment setup
✅ CPU / memory / disk usage investigation

What I Offer:
✅ Linux environment inspection
✅ Website migration and deployment
✅ Nginx / PHP-FPM / MySQL / Redis troubleshooting
✅ Docker configuration and maintenance
✅ Server performance analysis
✅ Long-term remote operations support

Please contact me and mention: Linux Operations Consultation.

Contact Me:
Telegram: @shuijingwan
WeChat: 13980074657
Email: shuijingwanwq@gmail.com

评论

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.