手动部署LNMP环境(CentOS 7)

一、修改 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

需要修改mysql或者php版本,对应的修改yum源和命令即可

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),则需要调整防火墙规则的配置。

开启80/443端口:

[root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
[root@localhost ~]# firewall-cmd --zone=public --add-port=443/tcp --permanent

出现 success 表明添加成功

命令含义:

--zone #作用域

--add-port=80/tcp #添加端口,格式为:端口/通讯协议

--permanent #永久生效,没有此参数重启后失效

修改 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 信息
<?php echo phpinfo(); ?>
  • 浏览器访问 http://<内网IP地址>/phpinfo.php,如果看到 PHP信息,说明安装成功

欢迎转载,转载请注明出处!

独立域名博客:flywill.com

欢迎关注公众微信号:Java小镇V

分享自己的学习 & 学习资料 & 生活

想要交流的朋友也可以加微信号备注入群:EscUpDn

手动部署LNMP环境(CentOS 7)的更多相关文章

  1. 手动编译部署LNMP环境(CentOS7.5+Nginx-1.18.0+MySQL-5.7.30+PHP-7.4.14)

    在平时运维工作中,经常需要用到LNMP应用框架.LNMP环境是指在Linux系统下,由Nginx + MySQL + PHP组成的网站服务器架构. 可参考前面的文章: 如何在CentOS 7上搭建LA ...

  2. 【转载】Centos系统快速部署LNMP环境

    PHP语言在Linux系统上运行的时候,需要在Linux系统上部署相应的Nginx.MySQL.PHP等环境,只有将这些环境参数都设置好,PHP相关应用程序才可正常运行,部署环境的方法有很多种,可手动 ...

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

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

  4. 十九.部署LNMP环境、构建LNMP平台、地址重写

    proxy client web1 web2   1.部署LNMP环境 1.1 部署nginx(前面已部署过) 1.2 部署mariadb ]# yum -y install mariadb mari ...

  5. 通过yum在CentOS7部署LNMP环境(Centos7.4+Nginx1.12+mariadb5.5.56+PHP7.0)

    LNMP环境 CentOS Linux release 7.4.1708 PHP 7.0.25 nginx version: nginx/1.12.2 mariadb: 5.5.56-MariaDB ...

  6. 高级运维(三):部署Lnmp环境、构建Lnmp平台、地址重写

    一.部署LNMP环境 目标: 安装部署Nginx.MariaDB.PHP环境 1> 安装部署Nginx.MariaDB.PHP.PHP-FPM: 2> 启动Nginx.MariaDB.FP ...

  7. ansible-playbook通过github拉取部署Lnmp环境

    1. 配置服务器初始化  1.1) 关闭防火墙和selinux 1 [root@test-1 ~]# /bin/systemctl stop firewalld 2 [root@test-1 ~]# ...

  8. centos-6.5安装部署LNMP环境

    安装部署前,确保安装了gcc和gcc-c++ 系统信息: [root@zww ~]# cat /etc/redhat-release CentOS release 6.5 (Final) [root@ ...

  9. RedHat6.2 x86手动配置LNMP环境

    因为公司要求用RedHat配,顺便让我练习一下Linux里面的操作什么的. 折腾来折腾去终于搞好了,其实也没那么难嘛.但是也要记录一下. 首先,是在服务器里面用VMware搭建的RedHat6.2 x ...

随机推荐

  1. Ubuntu 终端中文回显乱码

    参考文章 : http://wiki.ubuntu.org.cn/%E4%BF%AE%E6%94%B9locale 所用 Ubuntu的版本 : 猜想是这样的: 1.字符的编码和显示时,所处的环境不是 ...

  2. PHP array_udiff_assoc

    1.函数的参数:返回数组的差集,比较时包括键值. 2.函数的参数: @params array $array @params array $array1 @params array $array2 . ...

  3. HTML 元素居中的方法

    网址:http://www.cnblogs.com/asqq/archive/2012/04/09/2438745.html 1. 元素的定位的方法选择 :absolute . 2. 给定元素的宽和高 ...

  4. 6.Linux文件属性及软硬链接

    1.文件属性 使用ll -h 查看的详细信息,每一列都是干什么的 第一列第一个字符 表示文件类型---> rw-r--r-- 文件权限 1 这个文件被链接次数 root 文件的拥有者(用户) r ...

  5. LeetCode初级算法--设计问题01:Shuffle an Array (打乱数组)

    LeetCode初级算法--设计问题01:Shuffle an Array (打乱数组) 搜索微信公众号:'AI-ming3526'或者'计算机视觉这件小事' 获取更多算法.机器学习干货 csdn:h ...

  6. 深度讲解Linux内存管理和Linux进程调度-打通任督二脉

    我在多年的工程生涯中发现很多工程师碰到一个共性的问题:Linux工程师很多,甚至有很多有多年工作经验,但是对一些关键概念的理解非常模糊,比如不理解CPU.内存资源等的真正分布,具体的工作机制,这使得他 ...

  7. dubbo初学采坑记

    写在前面的话 dubbo 现在是apache组织旗下的项目,相信国内也有很多人使用.最近一个同事离职,我就接手了他的项目.远程通讯就是用的dubbo框架来实现的.使用Intelij idea 写了一个 ...

  8. JVM学习记录3--垃圾收集器

    贴个图 Serial收集器 最简单的收集器,单线程,收集器会暂停用户线程,称为"stop the world". ParNew收集器 Serial收集器的多线程版本,其它类似.默认 ...

  9. Java集合框架个人学习笔记

    从网上粘贴的结构图 Collection ├List │├LinkedList │├ArrayList │└Vector(了解,已过时) │ └Stack └Set    Map ├Hashtable ...

  10. Leetcode算法【34在排序数组中查找元素】

    在之前ARTS打卡中,我每次都把算法.英文文档.技巧都写在一个文章里,这样对我的帮助是挺大的,但是可能给读者来说,一下子有这么多的输入,还是需要长时间的消化. 那我现在改变下方式,将每一个模块细分化, ...