LNMP环境

CentOS Linux release 7.4.1708

PHP 7.0.25

nginx version: nginx/1.12.2

mariadb: 5.5.56-MariaDB

一、环境准备:

操作系统: CentOS Linux release 7.4.1708

关闭防火墙

#systemctl stop firewalld

# setenforce 0

检查网络连通性:

#ping -c2 baidu.com

二、安装配置mysql

安装mariadb

# yum install -y mariadb-server mariadb

启动数据库并配置开机自启动

# systemctl start mariadb &&  systemctl enable mariadb

初始化数据库,配置root用户密码

# mysql_secure_installation

查看数据库状态

# systemctl status mariadb

三、安装Nginx

1.配置企业源

# yum install -y epel-release

2.安装nginx

# yum install -y nginx

3.设置开机自启动并启动服务

# systemctl enable nginx && systemctl start nginx

4.查看服务状态

# systemctl status nginx

# netstat  -lant | grep 80

5.浏览器访问http://localhost_ip

Nginx 默认的HTML根目录是:/usr/share/nginx/html,可以修改其下的 index.html 的内容再看看效果。

四、安装配置php7

1.配置源

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2.安装php7

#yum install 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-mysql.x86_64 php70w-pdo.x86_64 -y

3.安装php-fpm

#yum install php70w-fpm -y

4.编辑/etc/php.ini  取消764行注释,并设置为0

762 cgi.fix_pathinfo=0

编辑/etc/php-fpm.d/www.conf

8 user = nginx

10 group = nginx

34 listen.owner = apache

35 listen.group = apache

5.启动服务被开机自启

#systemctl start php-fpm &&  systemctl enable php-fpm

查看服务状态

#systemctl status php-fpm

五、配置Nginx

#vi /etc/nginx/nginx.conf

添加以下内容

server{

index  index.html index.htm index.php;

location / {

}

location ~ \.php$ {

root           html;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

}

重启服务

#systemctl restart nginx

#echo “<?php phpinfo();?>”  > /usr/share/nginx/html/index.php

六、访问确认

http://localhost_ip

根据 Server API 行看出,是通过 FPM/FastCGI 方式工作的

附:

更改index.php 测试php是否可以连接数据库 

<?php

$servername = "localhost";

$username = "username";

$password = "password";

// 创建连接

$conn = new mysqli($servername, $username, $password);

// 检测连接

if ($conn->connect_error){

  die("连接失败: " . $conn->connect_error);

}

echo "连接成功";

?>

参考:https://www.awaimai.com/671.html;http://www.runoob.com/php/php-mysql-connect.html

通过yum在CentOS7部署LNMP环境(Centos7.4+Nginx1.12+mariadb5.5.56+PHP7.0)的更多相关文章

  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. Centos7 搭建lnmp环境 (centos7+nginx+MySQL5.7.9+PHP7)

    阿里云一台服务器出现问题! 我估计是一键安装包环境的原因,所以打算重新搭建下环境! 首先,当然是先做好快照!安全第一! 对系统盘做更换系统操作,装上纯净版的centos. 装好后,进入系统 一.挂载数 ...

  3. CentOS7——搭建LNMP环境(WordPress案例)

    CentOS7--搭建LNMP环境(WordPress案例) LNMP组成介绍 LNMP(Linux-Nginx-MySQL-PHP)网站架构是目前国际流行的Web框架,该框架包括:Linux操作系统 ...

  4. Centos7之LNMP环境编译安装

    Centos7之LNMP环境编译安装 一.系统环境准备 注:安装时间过长,只做参考!!!1.系统信息 [root@localhost ~]# uname -r 3.10.0-957.el7.x86_6 ...

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

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

  6. 手动部署LNMP环境(CentOS 7)

    手动部署LNMP环境(CentOS 7) 一.修改 yum 源 [root@localhost ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/e ...

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

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

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

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

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

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

随机推荐

  1. 20180119-文件操作open用法

    官方文档 open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, open ...

  2. ubuntu vim8.1编译安装

    sudo apt-get install libncurses5-dev python-dev python3-dev libgtk-3-dev libatk1.0-dev libbonoboui2- ...

  3. zuul 详解

    zuul的简单使用与分析: https://www.jb51.net/article/106716.htm https://www.jianshu.com/p/ff863d532767 zuul自定义 ...

  4. CentOS下安装gdb的方法

    https://blog.csdn.net/zlk252620068/article/details/79564944

  5. 设置flex 为1

    父级的宽度: 375 用来每个子元素的宽度:40 设置了  flex:1,每个子元素的宽度为125 125*3= 375, 设置flex=1后子元素会平均的分配父级元素剩下的宽度

  6. C++ KMP文本匹配

    代码如下: 环境为VC #include <iostream> #include <algorithm> #include <string> #include &l ...

  7. Delphi Win API 函数 MulDiv

    Delphi Win API 函数 MulDiv 原型:function MulDiv(nNumber, nNumerator, nDenominator: Integer): Integer; st ...

  8. springboot实战(汪云飞)学习-1-1

    java EE开发的颠覆者 spring boot 实战 随书学习-1 1.学习案例都是maven项目,首先要在eclipse 中配置 maven,主要修改maven的配置文件:配置文件下载链接: h ...

  9. macOS 和 Linux 的内核区别

    有些人可能会认为 macOS 和 Linux 内核之间存在相似之处,因为它们可以处理类似的命令和类似的软件.有些人甚至认为苹果公司的 macOS 是基于 Linux 的.事实上是,两个内核有着截然不同 ...

  10. php nl2br()函数 语法

    php nl2br()函数 语法 作用:在字符串中的新行(\n)之前插入换行符dd马达 语法:nl2br(string,xhtml) 参数: 参数 描述 string 必须.规定要检查的字符串. xh ...