设为首页 加入收藏

TOP

linux+Nginx+Mysql+Php(一)
2017-10-12 17:58:14 】 浏览:10040
Tags:linux Nginx Mysql Php

LNMP简介

LAMPLinux apache mysql php---比较早的web服务。

LNMPLinux nginx mysql php---比较潮流,新的webn服务,使用率上升趋势(国内非常流行)。

 

  NginxEngine X),是俄罗斯人开发的,开源的www服务软件,软件一共780K(非常小),是一款静态(htmljscssjpg等)www软件,静态小文件高并发,同时占用资源很少。

 

  Nginx使用平台(linux unix windows都可以)和apache一样。

 

Nginx的功能:

a.www web服务---http 80

b.负载均衡(反向代理proxy

c.web cache

 

nginx的优点:

1.配置简单,灵活。

2.高并发(静态小文件),静态1-2W

3.占用资源少,2W并发开10个线程服务,内存消耗几百兆。

4.功能种类比较多(web cache proxy代理),每个功能都不是很强。

5.支持epoll模型,使得nginx支持高并发。

6.nginx配合动态服务和apache有区别。

7.利用nginx可以对IP限速。可以限制连接数。

 

实现原理:nginxapache--php--mysql

 

nginx的应用场合:

1.静态服务(图片,视频),另一个lighttpd(社区不活跃)。并发:1-3Whtmljscss.flv

2.动态服务:nginx+fastcgi方式运行phpjsp。并发:500-1500,类似于apache+phplighttpd+fcgi php

3.反向代理,负载均衡。日PV2000W以下,都可以用nginx做代理。haproxyF5a10

4.缓存服务,SQUID,VARNI.

 

nginx和其它web服务器对比:

1)apache

a.稳定强大

b.Prefork模式取消了进程创建开销,性能很高。

c.处理动态业务数据时,因关联到后端的引擎和数据库,瓶颈不在apache本身

d.高并发时消耗系统资源相对来说多一些

e.基于传统的select模型

2)nginx

a.基于异步IO模型(epollkqueue),性能强,能够支持上万并发

b.对小文件支持很好,性能很高(限静态小文件)

c.代码优美,扩展库必须编译进行主程序

d.消耗资源相对低

3)Lighttpd(百度贴吧,豆瓣)

a.基于异步IO模型,性能和nginx相近

b.扩展是SO模式,比nginx要灵活

c.全球使用率较低,安全性没有apache以及nginx

d.通过插件(mod secdownload)可实现文件URL地址加密

 

企业生产场景如何选择web服务器(推荐):

静态业务:高并发,用nginxlighttpd

动态业务:采用nginxapache均可

既有动态又有静态业务:nginxapache都可以,单选

对外业务nginx,对内业务apache

 

安装,配置nginx

1.安装准备:[root@localhost ~]# yum install pcre* -y

          [root@localhost ~]# yum install openssl* -y

2.编译:

./configure --prefix=/application/nginx1.12.0 \

--user=nginx \

--group=nginx \

--with-http_stub_status_module \

--with-http_ssl_module

3.启动检查:

[root@localhost application]# /application/nginx/sbin/nginx -t

nginx: the configuration file /application/nginx1.12.0/conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx1.12.0/conf/nginx.conf test is successful

[root@localhost application]# /application/nginx/sbin/nginx

[root@localhost application]# netstat -lntup|grep nginx(另外80端口也可以查)

 

 

 

出现这个界面表示成功

[root@localhost application]# vim /application/nginx/html/index.html   修改主页内容

 

4.关于nginx模块

1Nginx core modules(必须的),包括Main Events

2Standard HTTP modules(虽然不是必须的,但是缺省都会安装,不建议改动),包括Core  Acess  FastCGI  Gzip(压缩模块,性能优化)  LOG(日志模块)  Proxy RewriteURL重写模块)  Upstream(负载均衡模块)等等

提示:缺省条件下,这两组模块都会安装。修改配置文件,主要是根据这2组模块的功能来修改模块的参数。官网能够查看模块的参数。

 

5.nginx的配置

[root@localhost conf]# egrep -v "#|^$" nginx.conf.default >nginx.conf(去掉注释#行)

[root@localhost conf]# vim nginx.confcairui.org是别名)

 

 

[root@localhost conf]# mkdir /application/nginx/html/www

[root@localhost conf]# touch /application/nginx/html/www/index.html

[root@localhost conf]# vim /application/nginx/html/www/index.html

[root@localhost conf]# /application/nginx/sbin/nginx -t

nginx: the configuration file /application/nginx1.12.0/conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx1.12.0/conf/nginx.conf test is successful

[root@localhost conf]# /application/nginx/sbin/nginx -s reload

修改windows本地hosts文件,保证在win命令提示符内能ping通来自虚拟

首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇CentOS 7 for ARM 安装一键Lnmp失.. 下一篇Cent OS 安装配置 步骤

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目