centos7配置环境LNMP

#yum安装epel-release第三方软件包
yum install epel-release
#要验证EPEL仓库是否建立成功
yum repolist

  

xshell访问系统出现中文乱码的解决方法:
打开xshell选择文件-->属性-->终端-->终端右侧找到编码,然后把默认语言改成UTF-8
#安装php5.6.31
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm 

yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-fpm php-redis php-gd

#设置时区
vim /etc/php.ini
#date.timezone = "Asia/Shanghai"

#设置php-fpm运行用户组
vim /etc/php-fpm.d/www.conf
#user = nginx
#group = nginx
#listen = 127.0.0.1:9000 	前面;去掉
#listen.owner = nobody		前面;去掉
#listen.group = nobody		前面;去掉
#listen.mode = 0660		前面;去掉

  

#安装nginx
yum list nginx
yum install nginx

#启动nginx
systemctl start  nginx.service
systemctl status nginx.service
systemctl enable nginx.service
#启动php-fpm systemctl start php-fpm.service systemctl status php-fpm.service
systemctl enable php-fpm.service

  

#安装mysql5.7.20
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm 

#安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
#安装mysql server
yum install mysql-community-server

#启动mysqld
systemctl start mysqld.servoce
systemctl status mysqld.service
systemctl enable mysqld.service
#查看临时密码 grep 'A temporary password' /var/log/mysqld.log #登录设置root新密码 alter user 'root'@'localhost' identified by 'Abc123!@#'; #查看mysql版本 ->status; #新建用户 create user huirong identified by 'huirongAbc#123';

  

创建数据库命令
CREATE DATABASE `db_name` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
创建数据库脚本提示:sql_mode=only_full_group_by的问题
vim /etc/my.cnf
在socket=/var/lib/mysql/mysql.sock下面添加 sql_mode=''
#重启mysql systemctl restart mysqld.service
#安装redis3.2.10
yum list redis
yum install redis

#启动redis
systemctl start redis.service
systemctl status redis.service
systemctl enable redis.service #查看redis版本 redis-cli ->info

  

#yum安装lrzsz
yum list lrzsz
yum install lrzsz 
#rz上传 sz下载

  

查看系统版本的三种方法
lsb_release -a
cat /proc/version
uname -a
Nginx配置文件配置后需重启服务
1、nginx -t   测试nginx是否配置有误
2、若有问题请查看 /var/log/nginx/error.log文件 
需要给相应文件夹777权限  /var/lib/php 777权限【php写session】
3、若有问题请删除 /etc/nginx/nginx.conf 中80端口的配置
4、若非80端口启动报错请关闭防火墙
systemctl status firewall.service
systemctl stop firewall.service
非80端口访问提示403拒绝访问处理方法
1、关闭防火墙
systemctl status firewalld.service
systemctl stop firewalld.service
2、检查是否开启selinux
getenforce #查看是否开启了selinux  [disabled 或 permissive是关闭, enforcing是开启]
setenforce 0    ##设置SELinux 成为permissive模式
setenforce 1    ##设置SELinux 成为enforcing模式
 
原文地址:https://www.cnblogs.com/lovekingly/p/7691832.html