记录下在CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)过程笔记。

工具

  • VMware版本号 : 12.0.0

  • CentOS版本 : 7.0

一、修改 yum 源

[root@localhost ~]# rpm -Uvh https://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@localhost ~]# rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

Webtatic:https://webtatic.com
MySQL:https://dev.mysql.com/downloa...

二、安装 Nginx、MySQL、PHP

[root@localhost ~]# yum -y install nginx
[root@localhost ~]# yum -y install mysql-community-server
[root@localhost ~]# yum -y install php70w-devel php70w.x86_64 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 php70w-pecl-redis php70w-pecl-mongo

三、配置

1、配置 MySQL
MySQL 安装完成之后,在 /var/log/mysqld.log 文件中给 root 生成了一个默认密码
通过下面的方式找到root 默认密码,然后登录 MySQL 进行修改:

[root@localhost ~]# systemctl start mysqld    # 启动 MySQL
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log # 查找默认密码
2017-04-10T02:58:16.806931Z 1 [Note] A temporary password is generated for root@localhost: iacFXpWt-6gJ

登录 MySQL

[root@localhost ~]# mysql -uroot -p'iacFXpWt-6gJ'  

修改root 默认密码:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyPass1!';

或者:

mysql> set password for 'root'@'localhost'=password('123abc'); 


MySQL5.7 默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。

否则会提示 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 错误

详见 MySQL 官网密码策略详细说明:https://dev.mysql.com/doc/ref...

配置默认编码为 utf8
修改 /etc/my.cnf 配置文件,在 [mysqld] 下添加编码配置,配置完成后重启:

[root@localhost ~]# vim /etc/my.cnf
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
[root@localhost ~]# systemctl restart mysqld # 重启 MySQL

设置开机启动:

[root@localhost ~]# systemctl enable mysqld

默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket 文件:/var/run/mysqld/mysqld.pid

2、配置 Nginx
安装完成以后查看自己防火墙是否开启,如果已开启,我们需要修改防火墙配置,开启 Nginx 外网端口访问。

[root@localhost ~]# systemctl status firewalld

如果显示 active (running),则需要调整防火墙规则的配置。

修改 /etc/firewalld/zones/public.xml文件,在zone一节中增加
保存后重新加载 firewalld 服务:

[root@localhost ~]# vim /etc/firewalld/zones/public.xml
<zone>
...
<service name="nginx"/>
<zone>
[root@localhost ~]# systemctl reload firewalld

修改 Nginx 配置:

[root@localhost ~]# vim /etc/nginx/nginx.conf

server {} 里添加:

location / {
#定义首页索引文件的名称
index index.php index.html index.htm;
} # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置.
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

配置完成重启 Nginx

[root@localhost ~]# systemctl start nginx    # 启动 Nginx

:本文只是简单配置 Nginx,具体更多配置请自行百度。

设置开机启动:

[root@localhost ~]# systemctl enable nginx

3、设置开机启动 php-fpm

[root@localhost ~]# systemctl enable php-fpm
[root@localhost ~]# systemctl start php-fpm # 启动 php-fpm

四、测试

  • /usr/share/nginx/html 文件下创建php文件,输出 phpinfo 信息

  • 浏览器访问 http://<内网IP地址>/phpinfo.php,如果看到 PHP信息,说明安装成功

LNMP环境搭建(Discuz论坛)  http://www.linuxidc.com/Linux/2016-03/129334.htm

Ubuntu 14.04下apt-get方法安装LNMP环境  http://www.linuxidc.com/Linux/2016-07/133683.htm

CentOS 7源码编译安装PHP5.6和Nginx1.7.9及MySQL(搭建LNMP环境) http://www.linuxidc.com/Linux/2015-12/126200.htm

Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL  http://www.linuxidc.com/Linux/2014-05/102351.htm

CentOS 6.8 编译安装LNMP 简述  http://www.linuxidc.com/Linux/2017-05/143667.htm

Ubuntu 16.04 下源码配置LNMP开发环境 http://www.linuxidc.com/Linux/2016-09/135381.htm

CentOS 7源码编译安装PHP5.6和Nginx1.7.9及MySQL(搭建LNMP环境) http://www.linuxidc.com/Linux/2015-12/126200.htm

CentOS 7源码安装最新版LNMP环境 http://www.linuxidc.com/Linux/2015-04/116058.htm

CentOS 6.8 安装LNMP环境(Linux+Nginx+MySQL+PHP)   http://www.linuxidc.com/Linux/2017-04/142880.htm

Ubuntu系统下LNMP环境的搭建  http://www.linuxidc.com/Linux/2017-04/142610.htm

编译LNMP之Nginx+php-fpm  http://www.linuxidc.com/Linux/2017-10/147535.htm

Ubuntu 16.04 LTS下LNMP环境配置简述  http://www.linuxidc.com/Linux/2017-05/144252.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2018-01/150669.htm

CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)的更多相关文章

  1. 亚马逊AWS EC2云实例AMI安装LNMP环境(3)——Mysql5.5

    概括:这里选择亚马逊EC2的Linux AMI实例,该Linux服务器是亚马逊预配置的Linux环境,内置多个YUM源,属于亚马逊首推的稳定Linux服务器.默认登录用户名为ec2-user,执行ro ...

  2. CentOS编译安装LNMP环境

    这里是教大家如何在centos下利用源码编译安装LNMP环境. 工具/原料 centos服务器一台 自用电脑一台 准备篇 配置好IP.DNS .网关,确保使用远程连接工具能够连接服务器 配置防火墙,开 ...

  3. docker中基于centos镜像部署lnmp环境 php7.3 mysql8.0 最新版

    Docker是一个开源的应用容器引擎,基于Go语言并遵从Apache2.0协议开源. Docker可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然后发布到任何流行的Linux机器上 ...

  4. Centos 7.3 搭建php7,mysql5.7,nginx1.10.1,redis

    一.安装nginx 更新系统软件(非必要) # yum update 安装nginx 1.下载nginx # wget http://nginx.org/download/nginx-1.15.2.t ...

  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. 亚马逊AWS EC2云实例AMI安装LNMP环境(2)——PHP5.6

    概括:这里选择亚马逊EC2的Linux AMI实例,该Linux服务器是亚马逊预配置的Linux环境,内置多个YUM源,属于亚马逊首推的稳定Linux服务器.默认登录用户名为ec2-user,执行ro ...

  7. 亚马逊AWS EC2云实例AMI安装LNMP环境(1)——Nginx安装

    概括:这里选择亚马逊EC2的Linux AMI实例,该Linux服务器是亚马逊预配置的Linux环境,内置多个YUM源,属于亚马逊首推的稳定Linux服务器.默认登录用户名为ec2-user,执行ro ...

  8. Centos 6.8编译安装LNMP环境

    Centos 6.8编译安装LNMP环境 参考资料: http://www.jb51.net/article/107429.htm https://phperzh.com/articles/1360 ...

  9. 阿里云Ubuntu安装LNMP环境之PHP7

    在QQ群很多朋友问阿里云服务器怎么安装LNMP环境,怎么把项目放到服务器上面去,在这里,我就从头开始教大家怎么在阿里云服务器安装LNMP环境. 在这之前,我们先要知道什么是LNMP. L: 表示的是L ...

随机推荐

  1. webstorm/phpstorm破解版教程网址

    http://idea.lanyus.com/ http://www.php.cn/tool/phpstorm/408348.html 如果正版到期了,重新安装不能再次免费试用的话,之后我就用老版的w ...

  2. CSS中各种居中方法

    CSS中各种居中方法,本文回顾一下,便于后续的使用. 水平居中方法 1.行内元素居中 行内元素居中是只针对行内元素的,比如文本(text).图片(img).按钮等行内元素,可通过给父元素设置 text ...

  3. php require_once的使用方法

    学习笔记 require_once 语句和 require 语句完全相同,唯一区别是 PHP 会检查该文件是否已经被包含过,如果是则不会再次包含. equire_once() 为了避免重复加载文件. ...

  4. Web渗透三字经

    网络上曾流传一段Web渗透三字经,如下: 用搜索 找注入 没注入 就旁注 没旁注 用0day 没0day 扫目录 找后台 爆账户 传小马 放大马 拿权限 挂页面 放暗链 清数据 清日志 留后门 然后我 ...

  5. 洛谷 P2955 [USACO09OCT]奇数偶数Even? Odd?【字符串/易错】

    题目描述 Bessie's cruel second grade teacher has assigned a list of N (1 <= N <= 100) positive int ...

  6. Lambada. 计算和

    Lambada. 计算和 import java.util.Arrays; import java.util.List; public class ListLambada { public stati ...

  7. SDUT-3376_数据结构实验之查找四:二分查找

    数据结构实验之查找四:二分查找 Time Limit: 30 ms Memory Limit: 65536 KiB Problem Description 在一个给定的无重复元素的递增序列里,查找与给 ...

  8. 洛谷2254 BZOJ1499 瑰丽华尔兹题解

    洛谷链接 BZ链接 一个很容易想到的做法就是用f[i][j][t]表示t时刻在i,j处的可以滑动的最大值 f[i][j][t]=max(f[i][j][t-1],f[*i][*j][t-1]),这样大 ...

  9. oralce基本select语句

    SELECT  [DISTINCT]  *|{column1,column2,column3. . .}   FROM    table l  select指定查询哪些列的数据. l  column指 ...

  10. 微信小程序中支持es7的async语法

    最近在原生的微信小程序项目中需要把原来es6的promise方法改成es7的async await,这样代码看起来更直观,也方便以后的兄弟维护,但是改了代码之后项目就报错了. 提示的错误是:regen ...