CentOS7 安装Nginx+MySQL

时间:2024-01-16 11:22:20

首先我们需要安装nginx的yum源
[root@AD ~]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
获取http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
警告:/var/tmp/rpm-tmp.aRXWtf: 头V4 RSA/SHA1 Signature, 密钥 ID 7bd9bf62: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:nginx-release-centos-7-0.el7.ngx ################################# [100%]
[root@AD ~]# cd /etc/yum.repos.d/
CentOS-Base.repo       CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo     
CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo    nginx.repo            
[root@AD yum.repos.d]# yum info nginx       //yum查看nginx的可用版本信息
[root@AD yum.repos.d]# yum install nginx    //yum安装nginx
安装MySql
CentOS7的yum源中默认好像是没有mysql的。为了解决这个问题,我们要先下载mysql的repo源。

1. 下载mysql的repo源

$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

2. 安装mysql-community-release-el7-5.noarch.rpm包

$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。

3. 安装mysql

$ sudo yum install mysql-server