字體:  

如何在CentOS7上安裝 Nginx1.20 + PHP8.1 + Composer2 + Redis7.0

altis 發表於: 2022-8-29 23:41 來源: ADJ網路控股集團


最近剛好在嘗試安裝最新版的版本...步驟如下:


(1)Enable REMI Repository
# yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm

Install PHP 8.1 on CentOS
# yum install php81 php81-php-fpm php81-php-intl php81-php-mbstring php81-php-gd php81-php-xml php81-php-imap php81-php-zip php81-php-curl php81-php-json php81-php-ldap php81-php-mysqlnd php81-php-opcache

啟用 php8.1 為預設版本
# scl enable php81 bash

寫入 .bash_profile 讓開機就生效
# echo "scl enable php81 bash" >> /root/.bash_profile

# php -v
PHP 8.1.9 (cli) (built: Aug  2 2022 13:02:24) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.9, Copyright (c), by Zend Technologies

(2)安裝nginx 1.20

# yum install nginx

# nginx -v
nginx version: nginx/1.20.1


(3)安裝 git
# yum install git

(4)安裝 Composer 2
# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

將 Composer 安裝到 /usr/local/bin,成為系統可直接使用的指令
# php composer-setup.php --install-dir=/usr/local/bin --filename=composer

用 composer 指令確認是否安裝成功,出現版本號就是成功了」
# composer -V
Composer version 2.4.1 2022-08-20 11:44:50

(5)安裝 redis 7.0
# yum --enablerepo=remi install redis

這樣就可以囉~