CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)

CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)

记录下在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 错误
CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)

详见 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

CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)

设置开机启动:

[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

CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)

如果显示 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

CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)

修改 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; }

CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)

配置完成重启 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信息,说明安装成功
    CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/113435.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Spring中bean的生命周期(最详细)

    Spring中bean的生命周期(最详细)SpringBean的生命周期是Spring面试热点问题。SpringBean的生命周期指的是从一个普通的Java类变成Bean的过程,深知Spring源码的人都知道这个给面试官讲的话大可讲30分钟以上,如果你不没有学习过Spring的源码,可能就知道Aware接口和调用init方法这样的生命周期,所以这个问题既考察对Spring的微观了解,又考察对Spring的宏观认识,想要答好并不容易!本文希望能够从源码角度入手,帮助面试者彻底搞定SpringBean的生命周期。首先你要明白一点,Sp

    2022年7月15日
    14
  • 百度爬虫robots.txt文件规范[通俗易懂]

    百度爬虫robots.txt文件规范[通俗易懂]robots.txt文件的格式 robots文件往往放置于根目录下,包含一条或更多的记录,这些记录通过空行分开(以CR,CR/NL, or NL作为结束符),每一条记录的格式如下所示:    “:” 在该文件中可以使用#进行注解,具体使用方法和UNIX中的惯例一样。该文件中的记录通常以一行或多行User-agent开始,后面加上若干Disallow和Allow行,详细情

    2022年5月2日
    43
  • 使用DataV制作实时销售数据可视化大屏

    使用DataV制作实时销售数据可视化大屏

    2022年4月2日
    346
  • gg修改器怎么编写lua脚本

    gg修改器怎么编写lua脚本gg修改器怎么编写lua脚本,gg修改器编写Lua脚本的例子从搜索冻结值的数10.搜索前7次的结果被冻结为8的值。gg.searchNumber(’10’,gg.TYPE_DWORD)localt=gg.getResults(7)fori,vinipairs(t)dot[i].value=’8’t[i].freeze=trueendgg.a…

    2025年9月15日
    7
  • 好玩的matlab程序_matlab怎么停止运行程序

    好玩的matlab程序_matlab怎么停止运行程序fs=44100;dt=1/fs;T16=0.125;t16=[0:dt:T16];[tempk]=size(t16);t4=linspace(0,4*T16,4*k);t8=linspace(0,2*T16,2*k);[tempi]=size(t4);[tempj]=size(t8);%Modificationfunctionsmod4=(t4.^4).*exp(-30*(t4.^0.5…

    2022年9月22日
    2
  • c++反编译工具_pc下载软件

    c++反编译工具_pc下载软件  昨天在逆向某App的时候,发现有个加密工具类中的native方法是用C语言编写的,隐藏在so文件中。某大佬推荐逆向工具unidbg,能在pc端直接调用so文件中的函数,最终成功解决了问题。逆向工具之unidbg目录一、`unidbg`引入二、`unidbg`概述三、`unidbg`使用姿势1、下载`unidbg`项目2、导入到IDEA中①、解压压缩包②、打开`IDEA`,导入解压的项目3、测试`unidbg`4、运行自己的`so`文件①、编写`EncryptUtilsJni`类②、参数说明③、执行结果

    2022年9月18日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号