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. presentingViewController、presentedViewController区别

    解释两个属性:presentingViewController 和 presentedViewController A----(present)-----B----(present)-----C 1. ...

  2. 源码分析--LinkedList(JDK1.8)

    LinkedList与ArrayList一样都是List接口的实现类,底层用双向链表实现. LinkedList本身用一个内部类实现链表元素. private static class Node< ...

  3. I2C走线技巧

  4. linux的定时任务--crontab

    cron是一个linux下的定时执行工具,可以在无需人工干预的情况下运行作业.由于Cron 是Linux的内置服务,但它不自动起来,可以用以下的方法启动.关闭这个服务: /sbin/service c ...

  5. css盒子模型的宽度不包括margin

    看到教程上和一些博客上盒子模型的宽度 = content + padding + margin + border,应该是不包括margin的 <!DOCTYPE html> <htm ...

  6. [CodeForces - 1225E]Rock Is Push 【dp】【前缀和】

    [CodeForces - 1225E]Rock Is Push [dp][前缀和] 标签:题解 codeforces题解 dp 前缀和 题目描述 Time limit 2000 ms Memory ...

  7. PowerDesigner 小技巧

    PowerDesigner 重现快捷工具栏 palette :Tools -->customsize toolbars-->palette(调色板)勾选 如何在PDM中列表显示TABLE的 ...

  8. MySQL索引优化之双表示例

    select * from tableA a left join tableB b on a.f_id = b.id; 索引建tableB表上面, 因为left join 注定左表全都有,所以应该关心 ...

  9. flutter Container组件和Text组件

    在开始之前,我们先写一个最简单的入口文件:     后面,都是在这个结构的基础上面完成的. 由于Container组件和Text组件都是写在body里面的,所以下面,先将body抽离成一个组件的形式. ...

  10. python 简单抓取网页并写入excel实例

    # -*- coding: UTF-8 -*- import requests from bs4 import BeautifulSoup import xlwt import time #获取第一页 ...