、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. JS Util1(basic)

    1.

  2. tftp 限制ip 限制ip段 或者多个ip段访问

    1 限制单个ip访问 tftp 配置tftp信息 vi /etc/xinetd.d/tftp 在 service tftp配置信息中添加  only_form =ip 重启 service xinet ...

  3. django的分页

    一.分页器的函数封装 # 分页计算最小页和最大页 def page_list_return(total, current=1): ''' 分页,返回本次分页的最小页数和最大页数列表 :param to ...

  4. github android

    作者:ruijun 链接:https://www.zhihu.com/question/37160415/answer/79569042 来源:知乎 著作权归作者所有,转载请联系作者获得授权. ### ...

  5. SourceInsight阅读Python---张子芳

    首先从http://www.sourceinsight.com/public/languages/下载Python的配置文件Python.CLF ,然后对SourceInsight作如下配置: (1) ...

  6. C++之检测文件结尾

    当使用文件作为输入流时,为了确保适时的结束文件读取操作,程序要靠检查文件尾来判断该何时停止读取.常用的检查文件尾方法有两种: 两种方式均已将 fin 与文件关联,即 均已声明 fin 输入流,并已调用 ...

  7. 更改MyEclipse 之 jsp、js、java、xml文件字体大小设置

    1.打开eclipse->window-->prefercess--->general--->appearance-->color and font ----> B ...

  8. “error LNK2019: 无法解析的外部符号”之分析

    最近在用VS 2008开发,初学遇到不少问题,最头疼的问题之一就是:LNK2019. 百度一下讲的并不够全面,反正都没解决我的问题. error LNK2019问题在VC 6.0中是error LNK ...

  9. 使用bat/vbs/ahk对Windows下进行自动化操作

    回想90年代,我们在DOS下使用各种命令链对操作进行简化和自动化,如DOS 5.0添加的DosKey,利用管道和重定向对多组命令进行链式操作.后来使用了Ubuntu和其它Linux发型版后,bash下 ...

  10. javascript中正则表达式的基础语法

    × 目录 [1]定义 [2]特点 [3]元字符[4]转义字符[5]字符组[6]量词[7]括号[8]选择[9]断言[10]模式[11]优先级[12]局限性 前面的话 正则表达式在人们的印象中可能是一堆无 ...