CentOS7 Yum安装Nginx+PHP7.2+MySQL5.7环境

本人腾讯云服务器安装

yum 源配置 /etc/yum.repos.d/CentOS-Base.repo 如下

[extras]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
baseurl=http://mirrors.tencentyun.com/centos/$releasever/extras/$basearch/
name=Qcloud centos extras - $basearch
[os]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
baseurl=http://mirrors.tencentyun.com/centos/$releasever/os/$basearch/
name=Qcloud centos os - $basearch
[updates]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
baseurl=http://mirrors.tencentyun.com/centos/$releasever/updates/$basearch/
name=Qcloud centos updates - $basearch

安装NGINX

yum -y install nginx
systemctl start nginx
systemctl enable nginx

安装PHP7.2

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-bcmath

systemctl start php-fpm.service
systemctl enable php-fpm.service

安装Mysql5.7

下载MySql的yum包
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

yum命令安装
yum -y install mysql57-community-release-el7-10.noarch.rpm

安装MySql服务器
yum -y install mysql-community-server

启动mysql服务
systemctl start mysqld.service

检查是否启动成功
netstat -antp

在日志文件中找到安装时的临时密码
grep 'temporary password' /var/log/mysqld.log

登陆mysql后修改密码
alter user 'root'@'localhost' identified by '123456';

如果提示 Your password does not satisfy the current policy requirements
set global validate_password_length=1;
set global validate_password_policy=0;

systemctl enable mysqld.service

更改nginx配置

修改文件/etc/nginx/nginx.conf

#根据需要修改server下 root 地址
#如果没有index 添加, 有在index 增加 index.php
index        index.php index.html index.htm;

location / {
        try_files $uri $uri/ /index.php?$query_string;
 }

#php配置
location ~ .*\.(php|php5)?$
{
         #fastcgi_pass  unix:/tmp/php-cgi.sock;
         fastcgi_pass  127.0.0.1:9000;
         fastcgi_index index.php;
         include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
        expires 30d;
}
location ~ .*\.(js|css)?$
{
       expires 1h;
}

重启Nginx服务

你可能感兴趣的:(CentOS7 Yum安装Nginx+PHP7.2+MySQL5.7环境)