(1)安装rpm 包
关闭防火墙
setenforce 0
systemctl stop firewalld
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
(2)安装nginx
yum install -y nginx
(3)启动nginx
#修改配置
vim /etc/nginx/nginx.conf
user nginx; 改成 user www; 保存并退出useradd www; 注意要创建用户www
#修改服务配置后要重启服务
systemctl restart nginx.service#查看nginx运行状态
systemctl status nginx,service
#安装httpd
yum -y install httpd
#查询httpd是否安装
rpm -qa | grep httpd
前期准备
yum -y install wget
yum -y install curl
yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel
yum -y install gcc*
yum install autoconf
yum -y install lsof vim
(1)导入源
yum install epel-release
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum update
sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
(2)安装yum-utils
#yum-utils 可以扩展yum的默认功能,用于管理yum存储库以及程序包,而无需进行任何手动配置,yum-utils提供的程序之一是yum-config-manager,可以使用它来启用Remi存储库作为默认存储库,以安装不同的PHP版本。
yum install yum-utils
(3)开始安装
yum -y install php74 php74-php-devel
yum install php74-php-gd php74-php-pdo php74-php-mbstring php74-php-cli php74-php-fpm php74-php-mysqlnd -y
php74 -v
(4)修改php-fpm配置
vim /etc/opt/remi/php74/php-fpm.d/www.conf
把user = apache和group = apache 改成
user = www group = www
(5)启动php-fpm
启动php-fpm 访问
systemctl restart php74-php-fpm
检查是否启动:
方式一:lsof -i:9000方式二:systemctl status php74-php-fpm
(1)官方yum方式安装
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
#如果需要升级包可以用下面的命令
rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
(2)安装需要的版本
查看所有版本
yum repolist all | grep mysql
这里5.7版本是不可用的 8.0的能用 所以需要先禁用8.0的然后开启5.7版本的
yum-config-manager --disable mysql80-community
yum-config-manager
yum -y install yum-utils
如果报错如下: The GPG keys listed for the “MySQL 5.7 Community Server” repository are already installed but they are not correct for this package. Check that the correct key URLs are configured for this repository
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
启用5.7版本
yum-config-manager --enable mysql57-community
(3)安装mysql
yum install -y mysql-community-server
验证MySQL
mysql --version
(4)启动mysql
启动
systemctl start mysqld.service
查看启动状态
systemctl status mysqld.service
(5)登录mysql
MySql服务器初始化会创建 'root@localhost’的一个超级用户账号。设置超级用户的密码并将其存储在错误日志文件中
grep 'temporary password' /var/log/mysqld.log
使用临时密码登录Mysql
mysql -uroot -p'上面grep到的密码'
重置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
如果密码设置的太简单可能会报错,解决方法如下:
set global validate_password_length=6;
set global validate_password_policy=0;
(6)开启远程连接
进入mysql库执行命令
use mysql;
select host ,user from user;修改权限,把root用户的host改为%
update user set host = "%" where user = "root";
刷新权限
flush privileges;
一定要注意关闭防火墙,不关闭防火墙无法远程连接
测试php-fpm 连接
创建/opt/www 并vim /opt/www/test_php.php
phpinfo();
?>保存并退出
授权: chown -R www.www /opt/www
vim /etc/nginx/conf.d/s1.conf
server {
listen 91;
server_name localhost;
location / {
root /opt/www;
index index.php index.html;
}
location ~ \.php$ {
root /opt/www;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}重启nginx访问ip:端口/test_php.php
如果出现报错先关闭setenforce 0,systemctl stop firewalld
回到根目录,创建soft目录
cd /soft/
将zsy20201119-13.zip下载下来
解压
unzip zsy20201119-13.zip
移动到/opt/下
mv /soft/zsy20201119-13/zsy20201119-13/ /opt/
设置zsy20201119-13的权限
chown -R www.www /opt/zsy20201119-13/
更改配置
vim /etc/nginx/conf.d/s1.conf
root /opt/www; 替换成 root /opt/zsy20201119-13;
重启nginx