、1.先修改yum源  https://webtatic.com

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2.安装nginx

yum install nginx

3.安装mysql5.7

yum -y install mysql-community-server

4.安装php

 yum install php70w-devel php70w.x86_64 php70w-pecl-redis  php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64  php70w-pdo.x86_64   php70w-mysqlnd  php70w-fpm php70w-opcache

5.开始简单的配置

添加运行目录

mkdir -p /var/run/mysqld/
chown mysql.mysql /var/run/mysqld/

mysql 配置

vim /etc/my.cnf

在[client] 下面添加
default-character-set=utf8

在 [mysqld] 下面添加

character_set_server=utf8
init_connect='SET NAMES utf8'

collation-server=utf8_general_ci

保存退出

获取初始密码

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

得到

注意 里面包括开头的 ;号

然后登陆mysql 修改密码

alter user root@localhost identified by 'tyzZ001!'

如果密码太过于简单可能不然修改因为mysql默认设置了密码复杂度 至少8位 必须包含 大小写字母数字及符号

查看密码策略:

show variables like '%password%';

说明:

validate_password_dictionary_file:密码策略文件,策略为STRONG才需要

validate_password_length:密码最少长度

validate_password_mixed_case_count:大小写字符长度,至少1个

validate_password_number_count :数字至少1个

validate_password_special_char_count:特殊字符至少1个 上述参数是默认策略MEDIUM的密码检查规则。

validate_password_policy:密码策略,默认为MEDIUM策略 ,共有如下三种密码策略:

0 or LOW                 Length

1 or MEDIUM           Length; numeric, lowercase/uppercase, and special characters

2 or STRONG          Length; numeric, lowercase/uppercase, and special characters; dictionary file

可以通过 set  GLOBAL validate_password_policy=0 来修改

或者修改/etc/my.cnf文件

validate_password_policy=0 #0(LOW),1(MEDIUM),2(STRONG)其中一种,注意2需要提供密码字典文件

如果不需要密码策略,添加my.cnf文件中添加如下配置禁用即可:

validate_password = off

添加一个可以在外部登陆的mysql用户

grant all privileges on *.* to 创建的用户名 @"%" identified by "密码";
flush privileges;

注意修改配置文件后需要重启mysql

配置nginx:

nginx可以的默认配置文件一般在:

/etc/nginx/nginx.conf

使用 cat 查看一下配置文件

这行表示nginx会引用  conf.d 这个文件夹下面所有.conf后缀的文件

那么在conf.d下面我们来建立我们自己的配置文件

vim /etc/nginx/conf.d/user.conf

在里面写入:

server {
listen ;#端口
server_name admin.com www.admin.com; # 域名 root /home/www/web/newomcat/admin; # 网站根目录
index index.php index.html index.htm;#默认的index # 建议放内网
# allow 192.168.0.0/;
# deny all; location / { if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?$ last;#去除url中的index.php 不需要可以不写 } } location ~ \.php$ {
try_files $uri = ;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

这样 简单的lnmp就安装好了

systemctl restart php-fpm   #启动php
systemctl restart nginx #启动nginx
systemctl restart mysqld #启动mysql

6安装redis

下载源码包:

wget http://download.redis.io/releases/redis-3.2.5.tar.gz

或者使用yum安装也可以

yum install redis

解压下载好的远吗包:

tar -zxf redis-3.2..tar.gz

进入解压后的文件夹

cd redis-3.2.

make编译安装

make

安装完成后 在目录下会有一个 src目录里面放的是 redis的命令 当前目录下会有一个redis.conf 这个是 redis的配置文件  我们需要对他们进行处理一下放别以后的使用

建立两个目录

mkdir -p /usr/local/redis/bin  命令目录
mkdir -p /usr/local/redis/etc 配置文件目录

将配置文件移动到/usr/local/redis/ext 目录   将 src下的mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server redis-trib.rb 这个几个文件移动到/usr/local/redis/bin这个目录

mv ./redis.conf /usr/local/redis/etc/
mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server redis-trib.rb /usr/local/redis/bin/

打开  /usr/local/redis/etc/redis.conf 文件 修改配置 让redis在启动时在后台运行

找到这一项 改为  yes 原来为 no

最后将其注册为系统服务

在/etc/init.d/目录下建立redis 文件

vim /etc/init.d/redis

写入内容

###########################
#!/bin/sh
#chkconfig:
#description:auto_run
PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=
EXEC=/usr/local/redis/bin/redis-server
REDIS_CLI=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/usr/local/redis/etc/redis.conf" case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${} stop
${} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&
exit
esac
###########################

保存退出

设置权限

chmod +x /etc/init.d/redis

设置自动启动:

chkconfig redis on

设置 mysql php nginx 自动启动

 systemctl enable redis
systemctl enable php-fpm
systemctl enable mysqld
systemctl enable nginx

转载请注明来源:http://www.cnblogs.com/phpshen/p/6222935.html

centos7 安装php7+mysql5.7+nginx+redis的更多相关文章

  1. centos7.6编译安装php7.2.11及redis/memcached/rabbitmq/openssl/curl等常见扩展

    centos7.6编译安装php7..11及redis/memcached/rabbitmq/openssl/curl等常见扩展 获取Php的编译参数方法: [root@eus-api-cms-bac ...

  2. Centos7 安装PHP7版本及php-fpm,redis ,php-redis,hiredis,swoole 扩展安装

    ============================PHP7.1 ========================================= 1. 更换rpm 源,执行下面两个 rpm - ...

  3. centos7安装PHP7的redis扩展

    前言: 在本篇博客中,我将给大家介绍如何在Centos7上安装PHP-Redis扩展,关于如何在Centos上安装redis的,可以参考另外一篇博客:Centos7安装redis 想要在php中操作r ...

  4. CentOS7 安装PHP7的swoole扩展:

    一.绪 Swoole简介 PHP异步网络通信引擎 最终编译为so文件作为PHP的扩展 准备工作 Linux环境 PHP7 swoole2.1 redis 源码安装PHP7 源码安装swoole htt ...

  5. 在ubuntu16.04上安装php7 mysql5.7 nginx1.10并支持http2

    安装nginx 首先更新软件包 并且安装nginx sudo apt-get update sudo apt-get install nginx 开放防火墙配置 sudo ufw allow 'Ngi ...

  6. CentOS7 安装 PHP7.2

    点击查看原文 安装源 安装 EPEL 软件包: $ sudo yum install epel-release 安装 remi 源: $ sudo yum install http://rpms.re ...

  7. centos7安装php7.3

    安装php7.3 CentOS/RHEL 7.x: yum install epel-release yum install http://rpms.remirepo.net/enterprise/r ...

  8. centos7 安装php7遇到的问题

    环境中安装过php 5.4,觉得版本太低了,因此删除旧版本安装了新版本 1. 安装epel-release 通过命令: rpm -ivh http://dl.fedoraproject.org/pub ...

  9. CentOS7 安装PHP7的redis扩展:

      phpredis-4.2.0.tar.gz:下载:wget https://github.com/phpredis/phpredis/archive/4.2.0.tar.gz   $ tar -z ...

随机推荐

  1. windows下面配置apache+http

    一.apache安装 下载并安装apache_2.2.9-win32-x86-openssl-0.9.8h-r2.msi(见附件),找到apache安装目录(C:\Program Files (x86 ...

  2. SpringMVC问题- MultipartConfig 配置问题以及解决方式

    http://www.cnblogs.com/weilu2/p/springmvc_fileupload_with_servlet_3_0.html

  3. leetcode bugfree note

    463. Island Perimeterhttps://leetcode.com/problems/island-perimeter/就是逐一遍历所有的cell,用分离的cell总的的边数减去重叠的 ...

  4. Spark on Yarn:任务提交参数配置

    当在YARN上运行Spark作业,每个Spark executor作为一个YARN容器运行.Spark可以使得多个Tasks在同一个容器里面运行. 以下参数配置为例子: spark-submit -- ...

  5. ssh+expect批量分发

    Expect安装 [root@web02 scripts]# yum install expect SSH密钥生成 [root@web02 scripts]# ssh-keygen -t dsa   ...

  6. Overview of the Oppia codebase(Oppia代码库总览)

    Oppia is built with Google App Engine. Its backend is written in Python, and its frontend is written ...

  7. android 设计

    引用:http://my.eoe.cn/blue_rain/archive/3631.html 1.一些概念 模式的定义: 每个模式都描述了一个在我们的环境中不断出现的问题,然后描述了该问题的解决方案 ...

  8. LDA( Latent Dirichlet Allocation)主题模型 学习报告

    1     问题描述 LDA由Blei, David M..Ng, Andrew Y..Jordan于2003年提出,是一种主题模型,它可以将文档集中每篇文档的主题以概率分布的形式给出,从而通过分析一 ...

  9. iOS8 关于预编译文件.pch的改变

    ios8 添加.pch文件 1, 新建文件 (command+N)选择other组,选择pch,输入文件名保存. eg: 创建的工程为Demo; 创建文件名为DemoPrefixHeader.pch ...

  10. 剖析javascript全局变量和局部变量

    首先要记住: javascript是弱类型语言,它只有一种变量类型(var),为变量赋值时会自动判断类型并进行转换. 全局变量和局部变量如何声明? 全局变量声明: 第一种方式(函数外) var a; ...