本教程基于 Aliyun Linux release 2.1903 (Hunting Beagle) 环境下,可供Centos 7系统参考。
在 /etc/yum.repos.d 创建文件 nginx.repo ,内容如下:
[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
执行 yum install nginx
确认将要安装的nginx版本正确后按 y 回车。
PS: $releasever 是centos系统的大版本号,如使用 Aliyun Linux (阿里云linux) 系统无法识别请改为数字 7,下面MySQL和PHP安装repo文件同理。
在 /etc/yum.repos.d 下创建文件 mysql57.repo ,内容如下:
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
执行 yum install mysql-server
确认将要安装的MySQL版本正确后按 y 回车。
执行grep 'password' /var/log/mysqld.log
搜索数据库root用户密码
2021-03-01T14:07:18.222811Z 1 [Note] A temporary password is generated for root@localhost: 4AnhG8*/CaS(
root@localhost: 后面的是密码。
#MySQL登录,输入刚才搜索到的密码
mysql -uroot -p
#更改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'New Password';
#根据需要执行,是否允许root用户远程登录
grant all privileges on *.* to root@'%' identified by 'Password';
#创建远程admin用户并给予全部权限
grant all privileges on *.* to admin@'%' identified by 'Password';
#刷新MySQL权限
flush privileges;
在 /etc/yum.repos.d 下创建文件 php80.repo ,内容如下:
[remi-php80]
name=Remi's PHP 8.0 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php80/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/php80/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php80/mirror
enabled=1
gpgcheck=0
此安装的PHP 8.0的最新稳定版,可将文件中的 php80 变更为 php74 即可安装 php 7.4 的最新稳定版
安装php本体以及相关扩展,可根据需要增减。
yum install php php-fpm php-mysqlnd php-pdo php-bcmath php-gd php-mbstring php-xml
确认将要安装的PHP版本正确后按 y 回车。
1.在 /etc/yum.repos.d 下创建文件 remi-safe.repo ,内容如下:
[remi-safe]
name=Safe Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/safe/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/safe/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/safe/mirror
enabled=1
gpgcheck=0
2.在 /etc/yum.repos.d 下创建文件 epel.repo ,内容如下:
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=1
gpgcheck=0
再次执行PHP安装命令,看是否安装成功。
systemctl enable nginx
systemctl enable mysqld
systemctl enable php-fpm
yum install bash-completion -y
本文为LinWord原创文章,转载无需和我联系,但请注明来自LinWord博客https://www.linword.com
最新评论