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. linux典型应用对系统资源使用的特点

  2. shell函数与位置参数举例

  3. maven system path,加载本地jar

    当引用第三方包,且没有源代码时候,可以使用system path <dependency> <groupId>ctec</groupId> <artifact ...

  4. React(2) --super关键字

    参考:http://www.phonegap100.com/thread-4911-1-1.html Es6中的super可以用在类的继承中,super关键字,它指代父类的实例(即父类的this对象) ...

  5. 激活密钥许可证VMware Workstation Pro 15 激活许可证

    虚拟机 VMware Workstation Pro 15.5.0 及永久激活密钥 虚拟机下载地址:https://download3.vmware.com/software/wkst/file/VM ...

  6. 2.VUE前端框架学习记录二

    VUE前端框架学习记录二:Vue核心基础2(完结)文字信息没办法描述清楚,主要看编码实战里面,有附带有一个完整可用的Html页面,有需要的同学到脑图里面自取.脑图地址http://naotu.baid ...

  7. springBoot01-helloworld-完成一个简单的RESTful API

    1.访问http://start.spring.io/ 2.选择构建工具Maven Project.Spring Boot版本 2.0.1,以及一些工程基本信息 ,最后点击Generate Proje ...

  8. 如何通过Dataphin构建数据中台新增100万用户?

    欢迎来到数据中台小讲堂!这一期我们来看看,作为阿里巴巴数据中台(OneData - OneModel.OneID.OneService)方法论的产品载体,Dataphin如何帮助传统零售企业实现数字化 ...

  9. html插入链接的实现方法

    下面就为大家带来一篇html插入链接的实现方法.小编觉得挺不错的,现在就分享给大家,也给大家做个参考.一起跟随小编过来看看吧   每个网页都已一个地址,用URL()标识,通常在网站内部创建链接时,通常 ...

  10. hdu 5120 Intersection (圆环面积相交->圆面积相交)

    Problem Description Matt is a big fan of logo design. Recently he falls in love with logo made up by ...