centos8 使用阿里镜像快速安装php7.4套件
程序员文章站
2022-05-31 09:11:26
...
centos8 使用阿里镜像快速安装php7.4套件
本文只考虑centos8
今日日期:2020-11-16
所谓套件:指php相关的各类软件集合。
remi是一个php安装仓库。是rpm包。
经实测,全部安装时间大约2分钟,包括下面全部的软件(不含操作系统本身)
本文各软件版本
centos 8
php 7.4.12
nginx 1.18
mysql 8.0.21
redis 5.0.3 其实稳定版 6 已经出来了,这里不讲究了。
git 2.18.4
首先,安装阿里的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
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
注意观察,确认安装成功,且大版本是2.0
composer -V
安装 nginx 1.18 并整合 php-fpm 服务
下面这个echo是一句命令,得一起复制
echo $'[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 ' > /etc/yum.repos.d/nginx.repo
上面是一条echo命令。
dnf makecache
dnf install -y nginx
systemctl enable nginx
systemctl enable php74-php-fpm
sed -i 's/user\ =\ apache/user\ =\ nginx/g' /etc/opt/remi/php74/php-fpm.d/www.conf
sed -i 's/group\ =\ apache/group\ =\ nginx/g' /etc/opt/remi/php74/php-fpm.d/www.conf
sed -i 's/listen\ =\ \/var\/opt\/remi\/php74\/run\/php-fpm\/www.sock/listen=9000/g' /etc/opt/remi/php74/php-fpm.d/www.conf
rm -f /etc/nginx/conf.d/default.conf
vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
charset utf-8 ;
access_log /var/log/nginx/host.access.log main;
root /usr/share/nginx/html;
index index.php index.html index.htm;
error_page 404 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
vi /usr/share/nginx/html/1.php
<?php
phpinfo();
systemctl start nginx
systemctl start php74-php-fpm
curl localhost/1.php
如果能看到很多的大量输出,说明php和nginx正确安装了。
安装mysql 8
实际也用了阿里的镜像,因为是从AppStream库下载的。
dnf install -y @mysql
systemctl enable mysqld
systemctl start mysqld
mysql -uroot
上面的命令就可以登陆。
说明,用此方法安装好的mysql服务默认账号root,默认密码空
安装redis,git 以及其他常用库
dnf install -y git wget vim redis zip unzip p7zip rsync crontabs supervisor net-tools python3
git config --global core.autocrlf false
git config --global core.safecrlf false
systemctl enable redis
systemctl start redis
总结
用了国内镜像会速度极快,下载包的速度:3MB/秒,惊人的快!
无论docker还是linux环境都非常的快!!
整个安装过程就是吃着阿里,喝着阿里,真想唱支山歌给阿里听~
本文只考虑centos8
今日日期:2020-11-16
所谓套件:指php相关的各类软件集合。
remi是一个php安装仓库。是rpm包。
经实测,全部安装时间大约2分钟,包括下面全部的软件(不含操作系统本身)
本文各软件版本
centos 8
php 7.4.12
nginx 1.18
mysql 8.0.21
redis 5.0.3 其实稳定版 6 已经出来了,这里不讲究了。
git 2.18.4
首先,安装阿里的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
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
注意观察,确认安装成功,且大版本是2.0
composer -V
安装 nginx 1.18 并整合 php-fpm 服务
下面这个echo是一句命令,得一起复制
echo $'[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 ' > /etc/yum.repos.d/nginx.repo
上面是一条echo命令。
dnf makecache
dnf install -y nginx
systemctl enable nginx
systemctl enable php74-php-fpm
sed -i 's/user\ =\ apache/user\ =\ nginx/g' /etc/opt/remi/php74/php-fpm.d/www.conf
sed -i 's/group\ =\ apache/group\ =\ nginx/g' /etc/opt/remi/php74/php-fpm.d/www.conf
sed -i 's/listen\ =\ \/var\/opt\/remi\/php74\/run\/php-fpm\/www.sock/listen=9000/g' /etc/opt/remi/php74/php-fpm.d/www.conf
rm -f /etc/nginx/conf.d/default.conf
vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
charset utf-8 ;
access_log /var/log/nginx/host.access.log main;
root /usr/share/nginx/html;
index index.php index.html index.htm;
error_page 404 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
vi /usr/share/nginx/html/1.php
<?php
phpinfo();
systemctl start nginx
systemctl start php74-php-fpm
curl localhost/1.php
如果能看到很多的大量输出,说明php和nginx正确安装了。
安装mysql 8
实际也用了阿里的镜像,因为是从AppStream库下载的。
dnf install -y @mysql
systemctl enable mysqld
systemctl start mysqld
mysql -uroot
上面的命令就可以登陆。
说明,用此方法安装好的mysql服务默认账号root,默认密码空
安装redis,git 以及其他常用库
dnf install -y git wget vim redis zip unzip p7zip rsync crontabs supervisor net-tools python3
git config --global core.autocrlf false
git config --global core.safecrlf false
systemctl enable redis
systemctl start redis
总结
用了国内镜像会速度极快,下载包的速度:3MB/秒,惊人的快!
无论docker还是linux环境都非常的快!!
整个安装过程就是吃着阿里,喝着阿里,真想唱支山歌给阿里听~