002-LAMP

来源:互联网 发布:淘宝看店宝收费吗 编辑:程序博客网 时间:2024/05/16 19:31

002-LAMP

model

            user        httpd               (cgi)                                        php*.so(libphp5.so)            -----------------       -------------------------               MySQL            kernelclient                            diskIO

关键字,简单理解…可能理解错误

同步:
用户态程序系统调用时是否等待内核态处理IO并返回结果,等待(或查询)为同步

异步:
用户态程序系统调用时是否等待内核态处理IO并返回结果,不等待(系统调用直接返回)且用户态程序可以处理其他事情为异步

同步和异步是进程的行为

阻塞:
用户态程序能否立即得到结果,不能就是阻塞,无论是等待还是轮询

非阻塞:
用户态程序能否立即得到结果,能就是非阻塞

阻塞和非阻塞是进程等待调用结果的状态

sendfile:
transfer data between file descriptors。
client请求server资源的时候,首先内核态的网络模块处理,然后把request交给httpd,httpd得知资源位置位于disk上,发起内核IO调用读取disk上的文件,kernel读取文件之后,会把文件内容传递给用户进程httpd,httpd获得内容之后再次发起socket连接即又一次把相同的内容交给kernel,这是一种低效的方式。sendfile就是直接通过kernel把disk上的内容发送到client端。

epoll:
I/O event notification facility。
monitoring multiple file descriptors to see if I/O is possi‐ble on any of them. The epoll API can be used either as an edge-triggered or a level-triggered interface and scales well to large numbers of watched file descriptors.边缘触发效率高,水平触发反复通知。
参考链接:http://www.cnblogs.com/Anker/p/3254269.html

php工作模式

cgi

简单理解就是httpd server在接受client 的dynamic resource requests的时候,会fork() 出一个新的进程来执行request。

httpd

php作为httpd的模块,php解释器在httpd server启动的时候就启动了,httpd server不会fork() 新的进程,而是自己就有能力处理dynamic requests。

fast_cgi

httpd-2.4使用mod_proxy_fcgi模块使httpd与cgi交互,即和传统的cgi不同,并不是每次一个dynamic request就fork() 一个进程,二是在client发送dynamic request之前就已经有很多很多的进程等待这些request了。

php使用php-MySQL与mariadb交互

CentOS 6不支持fast cgi

快速部署

安装程序及启动服务

1 CentOS 7

yum -y install httpd php php-mysql mariadb-serveryum -y install httpd php-fpm php-mysql mariadb-serversystemctl start httpdsystemctl start mariadb.service

2 CentOS6
yum -y install httpd php php-mysql mysql-server

service httpd startservice mysqld start

php配置

php配置文件被<font color=099ff size=5 face="΢ÈíÑźÚ">php-common</font> 包提供,配置文件为    /etc/php.ini,/etc/php.d/*.ini配置文件在php解释器启动时被读取,对配置文件的修改如何生效?    Modules:重启httpd服务器    fast cgi:重启php-fpm解释器

-

ini:    [MySQL] #Section Header    directive=value #指令格式

-

php.ini的核心配置选项文档:http://php.net/manual/zh/ini.core.phpphp.ini配置选项列表:http://php.net/manual/zh/ini.list.php

mariadb(mysql)

内容庞大,单独成节
0 0
原创粉丝点击