centos7.9 安装nginx,mysql5.7, php7.4

.检查当前安装的PHP包

yum list installed | grep php

如果有安装的PHP包,先删除他们

yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64

2.安装源

先删除以前的

 yum remove epel-release

yum install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

3.安装YUM管理工具

yum install yum-utils
  1. 安装nginx
yum install nginx
  1. 安装mysql5.7
yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

yum install mysql-community-server  --nogpgcheck

//开启mysql
service mysqld start

//查看mysql的root账号的密码
grep 'temporary password' /var/log/mysqld.log

不调整安全策略,只修改密码

//登录mysql
mysql -uroot -p

//修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

//修改root用户可远程登录
//GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH //GRANT OPTION; 

//刷新
flush privileges;
  1. 安装php7.4
yum search php73
yum search php74

#安装PHP

yum install php74-php-gd php74-php-pdo php74-php-mbstring php74-php-cli php74-php-fpm php74-php-mysqlnd

#启动FPM

service php74-php-fpm start
  1. 测试
    建立目录 /data/www
    配置nginx: /etc/nginx/conf.d/test.conf

server {
    listen          80;
    server_name     localhost;
    root            /data/www;
    index index.html index.php;

    
    location / {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
        }     
    }
    
    
    location ~ [^/]\.php(/|$) {
        fastcgi_pass   127.0.0.1:9000; 
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        set $path_info $fastcgi_path_info;
        fastcgi_param PATH_INFO       $path_info;
        try_files $fastcgi_script_name =404;
        include fastcgi.conf;
    }
    
}

/data/www/index.php

访问地址 : ip即可。会出现phpinfo信息

  1. 设置开机启动
systemctl enable nginx
systemctl enable mysqld
systemctl enable php74-php-fpm

9 查看哪些端口被占用

netstat -tlnp

你可能感兴趣的:(centos7.9 安装nginx,mysql5.7, php7.4)