Board logo

標題: [分享] 如何在CentOS7上安裝 Nginx1.20 + PHP8.1 + Composer2 + Redis7.0 + MySQL 8.0 [打印本頁]

作者: altis    時間: 2022-8-29 23:41     標題: 如何在CentOS7上安裝 Nginx1.20 + PHP8.1 + Composer2 + Redis7.0 + MySQL 8.0

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


(1)安裝 EPEL 及 REMI Repository
# yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.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

(6)安裝 MySQL 8.0
# yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
# yum install mysql-community-server
# systemctl enable mysqld
# systemctl start mysqld

首次啟動 MySQL服物器時,將為 MySQL root用户生成一个臨時密碼。您可以通過運行命令底下指令來找到密碼。
# grep 'temporary password' /var/log/mysqld.log

# mysql -u root -p

下面將使用第一個選項運行ALTER USER SQL語句使root用戶使用密碼進行身份驗證。

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';
FLUSH PRIVILEGES;


這樣就可以囉~




歡迎光臨 ADJ網路實驗室 (http://dz.adj.idv.tw/) Powered by Discuz! 6.0.0