快如閃電的安裝php(centos8)

yyy123456發表於2020-11-15

本文只考慮centos8

本文編寫時間:2020-11-14
remi是一個php安裝倉庫。是rpm包。

用了國內映象會速度極快,下載包的速度:3MB/秒,驚人的快!
無論docker還是centos環境都非常的快!!

首先,安裝阿里的 centos 倉庫。

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
rm -f  /etc/yum.repos.d/CentOS-centosplus.repo
rm -f  /etc/yum.repos.d/CentOS-PowerTools.repo
rm -f  /etc/yum.repos.d/CentOS-Extras.repo
rm -f  /etc/yum.repos.d/CentOS-AppStream.repo
dnf makecache
dnf repolist


安裝阿里的 epel 倉庫。

dnf install -y epel-release

sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*

sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
dnf makecache
dnf repolist


安裝阿里的 remi 的倉庫

dnf install -y https://mirrors.aliyun.com/remi/enterprise/remi-release-8.rpm

sed -i  's/https*:\/\/rpms.remirepo.net/https:\/\/mirrors.aliyun.com\/remi/g'  /etc/yum.repos.d/remi*

sed -i 's/#baseurl/baseurl/g' /etc/yum.repos.d/remi*

快如閃電的最關鍵是下一句,清除映象列表!!否則又去讀取國外的映象了。

sed -i 's|^mirrorlist|#mirrorlist|' /etc/yum.repos.d/remi*

dnf makecache
dnf repolist


安裝 php

dnf install -y yum-utils

dnf install -y php74 php74-php-devel  php74-php-fpm  php74-php-mbstring php74-php-memcache php74-php-memcached php74-php-redis  php74-php-mysqlnd  php74-php-pdo  php74-php-bcmath php74-php-xml php74-php-gd php74-php-gmp php74-php-igbinary php74-php-imagick   php74-php-mcrypt  php74-php-pdo_mysql php74-php-posix php74-php-simplexml  php74-php-opcache php74-php-xsl php74-php-xmlwriter php74-php-xmlreader php74-php-swoole php74-php-zip php74-php-phalcon  php74-php-yaml php74-php-yar php74-php-yaf php74-php-uuid

體驗到快如閃電的速度了吧!

最後安裝阿里的 composer 映象源

ln -s /usr/bin/php74 /usr/bin/php

curl -o /usr/local/bin/composer https://mirrors.aliyun.com/composer/composer.phar

chmod +x /usr/local/bin/composer

注意觀察,確認安裝成功,且大版本是2.0

composer -V

立刻設定composer 的映象源為阿里

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/


安裝 nginx

cat>/etc/yum.repos.d/nginx.repo<<EOF
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF

dnf install -y nginx
nginx -v
systemctl enable nginx
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章