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. Win10电脑查看已连接过WiFi密码的命令

    运行中输入CMD,回车,打开命令行窗口. 输入:netsh wlan show profiles    执行后,会列出搜友已连接过的WiFi名字: 输入:netsh wlan show profile ...

  2. Codeforces Round #394 (Div. 2) - C

    题目链接:http://codeforces.com/contest/761/problem/C 题意:给定n个长度为m的字符串.每个字符串(字符串下标从0到m-1)都有一个指针,初始指针指向第0个位 ...

  3. python常用函数 S

    slice(int,int) 切片,可以为切片命名增加可读性. 例子: sorted(iterable, key) 排序,支持传入参数,例如通过itemgetter传入参数(itemgetter可以传 ...

  4. 《Redis深度历险:核心原理和应用实践》学习笔记一

    1.redis五种数据结构 1.1 String字符串类型,对应java字符串类型 用户信息序列化后,可以用string类型存入redis中批量读写string类型,见效网络消耗数字类型的string ...

  5. css3系列--概述

    CSS3分成了不同类别,称为“modules”.而每一个“modules”都有于CSS2中额外增加的功能,以及向后兼容.CSS3早于1999年已经开始制订.[18]直到2011年6月7日,CSS 3 ...

  6. WPF 几种常用控件样式的总结

    这里把wpf中几种常用样式总结一下,后期可以直接拷贝使用,呵呵 一.Button <ResourceDictionary xmlns="http://schemas.microsoft ...

  7. (HY000): Can't connect to MySQL server on '129.28.149.240' (113)

    环境 mysql5.7 ubuntu 一. 解决方法 1.首先确保mysql开启了远程授权:https://blog.csdn.net/cryhelyxx/article/details/401146 ...

  8. rem字体+百分比布局表格

    效果图: 上源码 <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  9. POJ 3481 Double Queue (treap模板)

    Description The new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest ...

  10. 2017 ACM-ICPC乌鲁木齐网络赛 B. Out-out-control cars(计算几何 直线相交)

    题目描述 Two out-of-control cars crashed within about a half-hour Wednesday afternoon on Deer Park Avenu ...