CentOS/LNMP

来自技术笔记
跳到导航 跳到搜索

其他[编辑 | 编辑源代码]

  1. 关闭 SELinux
  2. 更新软件:yum update
  3. 安装基础包: yum install screen git unzip zip curl htop

安装 Nginx[编辑 | 编辑源代码]

yum install nginx
systemctl enable nginx.service
systemctl start nginx.service

安装 MySQL[编辑 | 编辑源代码]

下载 rpm 包,找到对应版本,如 CentOS 7,找 Red Hat Enterprise Linux 7 / Oracle Linux 7

wget  https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
vim /etc/yum.repos.d/mysql-community.repo # 改为 5.7
yum update # 替换 mariadb 开源版本,如果提示『Recv failure: Connection reset by peer』,把 /etc/yum.repos.d 中的 mysql-community.* 的 http 改为 https
yum install mysql-server # 安装 MySQL 5.7
mysql -V # 成功安装 5.7
systemctl enable mysqld.service
systemctl start mysqld.service #  启动服务
# 查看密码
cat /var/log/mysqld.log|grep root
mysql_secure_installation

参考 https://itbilu.com/database/mysql/VJqKWnT1f.html

安装 PHP[编辑 | 编辑源代码]

yum install epel-release yum-utils -y
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm # 如果要删除,yum remove remi-release-7.7-1.el7.remi.noarch
yum-config-manager --enable remi-php71
yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql php-simplexml
sudo yum install php-fpm
chown -R root:nginx /var/lib/php
sudo systemctl enable php-fpm
sudo systemctl start php-fpm

Reids[编辑 | 编辑源代码]

yum install redis

yum install php-redis

sudo systemctl restart php-fpm

参考[编辑 | 编辑源代码]