当前位置: 首页 > article >正文

LNMP架构环境搭建(Linux+Nginx+Mysql+PHP)

一、LNMP环境介绍


        LNMP代表的就是:Linux系统下“Nginx+Mysql+PHP”这种网站服务器架构。Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器。MYSQL是一个小型关系型数据库管理系统。PHP是一种在服务器端执行的嵌入式HTML文本的脚本语言。这4种软件均为免费开源软件,组合到一起,就成为一个免费、高效、扩展性强的网站服务系统。

        搭建网站服务器环境有很多可选方案,例如微软的Windows2012、LAMP等。那么为什么要使用LNMP呢?LNMP的优势主要有以下4点。

      (1)作为web服务器:相比Apache,Nginx使用更少的资源,支持更多的并发连接,实现更高效的效率。

      (2)作为负载均衡服务器:Nginx既可以在内部直接支持Rails和PHP,也可以支持作为HTTP代理服务器对外进行服务。Nginx用C编写,不仅是系统资源开销还是CPU使用效率都比Perlbal要更好的多。

      (3)作为邮件代理服务器:Nginx同时也是一个非常优秀的邮件代理服务器(最早开发这个产品的目的之一也就是作为邮件代理服务器),Last/fm描述了成功并且美妙的使用经验。

      (4)Nginx安装非常的简单,配置文件非常简洁,性能稳定、功能丰富、运维简单、处理静态文件速度快且消耗系统资源极少。

二、LNMP环境搭建


准备一台web服务器,

(一)安装配置部署Nginx

[root@localhost ~]# yum install -y nginx

[root@localhost ~]# systemctl start nginx

[root@localhost ~]# systemctl status nginx

测试

 

[root@localhost ~]# vim /etc/nginx/nginx.conf

location ~ \.php$ {

root /usr/share/nginx/html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

[root@localhost ~]# systemctl restart nginx

(二)php-fpm部署

[root@localhost ~]# yum -y install php-fpm php-mysql php-gd

[root@localhost ~]# systemctl start php-fpm

[root@localhost ~]# systemctl enable php-fpm

[root@localhost ~]# systemctl status php-rpm

[root@localhost ~]# netstat -anpt | grep 9000

 测试

[root@localhost ~]# vim /usr/share/nginx/html/index.php

<?php

phpinfo();

?>

(三)Mysql部署

[root@localhost ~]# yum install -y mariadb-server mariadb

[root@localhost ~]# systemctl start mariadb.service

[root@localhost ~]# systemctl enable mariadb.service

[root@localhost ~]# mysqladmin password '123123'

[root@localhost ~]# mysql -uroot -p123123

MariaDB [(none)]> create database bbs;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on bbs.* to phptest@'192.168.163.169' identified by '123123';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

测试

[root@localhost ~]# vim /usr/share/nginx/html/index.php

<?php

$link=mysql_connect('192.168.163.169','phptest','123123');

if ($link)

        echo "Successfuly";

else

        echo "Faile";

mysql_close( );

?>

(四)上线

[root@localhost ~]# wget https://cn.wordpress.org/wordpress-4.9.1-zh_CN.zip

[root@localhost ~]# unzip wordpress-4.9.1-zh_CN.zip

[root@localhost ~]# rm -rf /usr/share/nginx/html/*

[root@localhost ~]# rm -rf /usr/share/nginx/html/*

[root@localhost ~]# cp -rp /root/wordpress* /usr/share/nginx/html/

[root@localhost ~]# chown -R nginx.nginx /usr/share/nginx/html/*

 

 

http://www.lryc.cn/news/2417770.html

相关文章:

  • 数组详细讲解
  • loki介绍
  • 正确配置安装和卸载Cygwin
  • Windows server 2016——SQL server 简介与安装
  • 都2023年了,Servlet还有必要学习吗?一文带你快速了解Servlet
  • Activiti入门及案例
  • window硬盘管理
  • 什么是UTF-8编码
  • spice新手学习手册
  • 我的docker随笔38:用 registry 搭建私有仓库
  • 常用概率分布的矩母函数、特征函数以及期望、方差的推导
  • ActiveMQ:消息的优先级与抢占机制
  • Tomcat下载及配置(IDEA)
  • Linux服务器JDK安装环境变量配置详细步骤
  • 【Java技术专题】「Guava技术系列」Guava-Collections实战使用相关Guava不一般的集合框架
  • CountDownLatch 和 CyclicBarrier 使用场景详解
  • 2024年安卓最全理解Android虚拟机体系结构,2024年最新Android高级工程师进阶学习
  • U盘启动盘怎么制作?
  • Regression算法之通俗讲解
  • UTF-8基础
  • 算法刷题笔记——动态规划篇
  • 损失函数MSE和MAE的区别以及如何选择
  • c语言md5函数头文件,【C】md5函数实现代码
  • 【Java】lambda表达式的3种写法
  • MyCat 管理及监控
  • 高级 Perl:文件处理与模块使用
  • 一文彻底了解ES6中的var、let、const基本用法以及暂时性死区和变量提升的区别
  • 深入浅出单例模式(全网最详细且通俗易懂讲解)
  • GPIO是啥
  • 都这麽大了还不快了解IDS?