点击这里给我发消息QQ客服

LNMP-nginx1.8+mysql5.7+php7.4

云之渝 2020-09-17

#Centos8.2 20.04 mini  

# LNMP

# Nginx 1.18.0

#Mysql 5.7

#PHP 7.4

 

安装nginx

nginx 安装包地址

http://nginx.org/packages/centos/8/x86_64/RPMS/?spm=a2c4g.11186623.2.31.4f1623bfiSSL3R

 

dnf -y install http://nginx.org/packages/centos/8/x86_64/RPMS/nginx-1.18.0-1.el8.ngx.x86_64.rpm

 

install001.png 

 

查看nginx 版本

install002.png 

 

安装MYSQL5.7

安装wget

dnf install wget

 

下载mysql

https://dev.mysql.com/downloads/file/?id=489467

 

wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

 

rpm -ivh mysql80-community-release-el7-3.noarch.rpm

 

查看启用的MYSQL

 

dnf repolist enabled |grep mysql

 

#禁用app8.0 mysql enable

sudo dnf config-manager --set-disable AppStream

sudo dnf config-manager --disable mysql80-community

sudo dnf config-manager --enable mysql57-community

 

安装mysql5.7

dnf install  mysql mysql-server mysql-devel

 

查看mysql 版本

rpm -qa | grep mysql

 

Mysql 安装完后默认开机启动

启动服务

systemctl start mysqld

 

查看初始密码

cat /var/log/mysqld.log | grep 'temporary password'

 

登陆mysql

mysql -uroot -p

 

修改密码

set password for 'root'@'localhost'=password("Yy100200.");

flush privileges;

 

 

安装php

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

 

sudo dnf module list php

 

install003.png 

 

 

重置php模块

sudo dnf module reset php

 

启用7.4 模块

sudo dnf module enable php:remi-7.4

 

开启AppStream

sudo dnf config-manager --enable AppStream

 

安装php

dnf install -y php php-opcache php-gd php-curl php-mysqlnd

 

dnf install -y php-bcmath php-mbstring php-xmlwriter php-xmlreader php-cli php-ldap php-zip php-fileinfo

 

systemctl disable firewalld

systemctl enable nginx.service

systemctl enable php-fpm

systemctl stop firewalld

systemctl start php-fpm

systemctl restart nginx

 

重启nginx

install004.png 

 

PHP测试页

cd /usr/share/nginx/html

touch index.php

<?php

echo phinfo();

?>

 

 

 

错误

打开http://x.x.x.x/index.php  提示php页面下载的问题

 

检查 php-fpm 日志文件 如下


 install005.png

 

修改/etc/nginx/conf.d/default.conf

 

 

    location ~ \.php$ {

        root           /usr/share/nginx/html;

        fastcgi_pass   unix:/run/php-fpm/www.sock;

        fastcgi_index  index.php;

    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        include        fastcgi_params;

    }

 


 

 install006.png

 

重启php-fpm nginx

systemctl restart php-fpm

systemctl restart nginx

 

再次访问http://x.x.x.x/index.php


 install007.png

 

 

搞定