12.1LNMP架構介紹12.2 MySQL安裝12.3/12.4 PHP安裝12.5 Nginx介紹

12.1 LNMP架構介紹

  • Linux+Nginx+MySQL+PHP LNMP

  • nginx 和Apache 在架構裏面擔任的角色是類似的 在LAMP裏,PHP和Apache是一個整體,php的解析是交給Apache來執行的,只不過需要加載一個php 的模塊libphp.so

  • 在LNMP裏,PHP會啓動一個服務(php-fpm),Nginx會把用戶請求的php交給php-fpm服務去進行處理(用戶數據與mysql的交互就是由php-fpm來做的,處理好結果以後再告訴Nginx,然後通過Nginx告訴用戶的瀏覽器),用戶的靜態請求將由Nginx直接進行處理(Nginx在處理靜態數據的性能上要比Apache快),

  • Nginx對靜態爲主的網站,處理用戶併發會很大,速度也會快很多

  • 參照下圖進行理解: 

194048340.png?p_w_picpathslim

# 12.2 MySQL安裝

-  cd /usr/local/src
-  wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz 
-  tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
-  mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql
-  cd /usr/local/mysql
-  useradd mysql
-  mkdir /data/
-  ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
-  cp support-files/my-default.cnf  /etc/my.cnf 
-  cp support-files/mysql.server /etc/init.d/mysqld
-  vi /etc/init.d/mysqld
-  定義basedir和datadir
-  /etc/init.d/mysqld start

- 先進入到src 目錄下 ,之前我們安裝過了mysql,
- 這裏會先把之前安裝的mysql 先刪除掉 再重新安裝一遍

```
Last login: Sat Oct 14 19:42:30 2017
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# ls
apr-1.6.2              httpd-2.4.27.tar.gz                        php-7.1.6.tar.bz2
apr-1.6.2.tar.gz       mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz  phpredis-develop
apr-util-1.6.0         php-5.6.30                                 phpredis-develop.zip
apr-util-1.6.0.tar.gz  php-5.6.30.tar.gz
httpd-2.4.27           php-7.1.6
[root@localhost src
```

- 先看下mysql服務有沒有啓動 ,如果有就先關閉
```
[root@localhost src]# ps aux |grep mysql
root       1290  0.0  0.1 115392  1684 ?        S    19:42   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql      1541  0.1 46.0 1300792 460400 ?      Sl   19:42   0:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock
root       2285  0.0  0.0 112680   980 pts/0    S+   20:08   0:00 grep --color=auto mysq
[root@localhost src]# service mysqld stop
Shutting down MySQL.. SUCCESS! 
[root@localhost src]# ps aux |grep mysql
root       2326  0.0  0.0 112680   980 pts/0    R+   20:11   0:00 grep --color=auto mysq
[root@localhost src]#
```
- 把之前的mysql目錄給刪掉,還有把mysqld 啓動的腳本給刪掉,
- 把所有安裝包 都統一放到一個路徑下/usr/local/src/ 下
```
[root@localhost src]# rm -rf /usr/local/mysql
[root@localhost src]# rm -rf /etc/init.d/mysqld
[root@localhost src]# 
[root@localhost src]# pwd
/usr/local/src
[root@localhost src]# 
```
- 解壓, 把文件改名
```
[root@localhost src]# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz


mysql-5.6.36-linux-glibc2.5-x86_64/sql-bench/innotest1b
mysql-5.6.36-linux-glibc2.5-x86_64/sql-bench/test-insert
mysql-5.6.36-linux-glibc2.5-x86_64/sql-bench/test-select
[root@localhost src]# 

[root@localhost src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/
apache2.4/ apr-util/  etc/       include/   lib64/     php/       sbin/      src/
apr/       bin/       games/     lib/       libexec/   php7/      share/     
[root@localhost src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
[root@localhost src]# ls /usr/local/mysql/
bin      data  include  man         README   share      support-files
COPYING  docs  lib      mysql-test  scripts  sql-bench
[root@localhost src]# 

[root@localhost src]# cd /usr/local/mysql/
[root@localhost mysql]# 
```
- 需要創建mysql用戶,因爲之前我們已經創建過了,創建/data/mysql/目錄,這個我們也創建了,就把底下的文件刪除掉
```
[root@localhost mysql]# ls /data/
mysql  wwwroot
[root@localhost mysql]# id mysql
uid=1000(mysql) gid=1000(mysql) 組=1000(mysql)
[root@localhost mysql]# rm -rf /data/mysql/*
[root@localhost mysql]# 
```
- 然後j就是初始化 ,初始化的過程就是把一些它啓動需要的目錄給它生成,
```
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql


New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

[root@localhost mysql]# echo $?
0
[root@localhost mysql]# 
```
- 然後再把配置文件拷貝過去,之前已經拷貝過了,編輯配置文件/etc/my.cnf 指定datadir socket位置
```
[root@localhost mysql]# vim /etc/my.cnf

[mysqld]
datadir=/data/mysql
socket=/tmp/mysql.sock


```
- 然後拷貝一個啓動腳本過來,編輯文件
```
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql]# vim /etc/init.d/mysql

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

basedir=/usr/local/mysql
datadir=/data/mysql

# Default value, in seconds, afterwhich the script should timeout waiting
# for server start. 
# Value here is overriden by value in my.cnf. 
# 0 means don't wait at all
:wq             
```
- 保存退出後,把服務名字改爲mysqld, 這個時候可以嘗試 啓動了
```
[root@localhost mysql]# mv /etc/init.d/mysql /etc/init.d/mysqld

[root@localhost mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/localhost.localdomain.err'.
. SUCCESS! 
[root@localhost mysql]# ps aux |grep mysql
root       2591  0.0  0.1 113264  1616 pts/0    S    20:44   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql      2728  7.9 44.9 1300792 449556 pts/0  Sl   20:44   0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock
root       2754  0.0  0.0 112680   976 pts/0    S+   20:44   0:00 grep --color=auto mysq
[root@localhost mysql]# 
```
- 然後把這個mysqld 加入到服務列表裏面去
```
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig mysqld on
[root@localhost mysql]# 

[root@localhost mysql]# !ps
ps aux |grep mysql
root       2591  0.0  0.1 113264  1616 pts/0    S    20:44   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql      2728  0.4 44.9 1300792 449556 pts/0  Sl   20:44   0:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock
root       2794  0.0  0.0 112680   976 pts/0    S+   20:48   0:00 grep --color=auto mysq
[root@localhost mysql]# 

```








# 12.3 PHP安裝 (上)
- 因爲php在LNMP和LAMP有差別,在LAMP的時候,他是Apache的模塊,需要用apxs2 指定Apache的路徑,使用apxs的工具進行自動配置模塊的加載
- 在LNMP裏,需要指定mysql的路徑,但是不需要制動Nginx的路徑,因爲是LNMP中,PHP是作爲一個獨立的服務在運行的,和Nginx沒有直接的關係,所以他也不需要依賴Nginx的什麼東西



- 先進入到src/目錄下 ,因爲之前編譯過PHP,所以只需要進入PHP的目錄下執行make clean 把之前編譯過的那些文件,全部刪掉
```
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# ls
apr-1.6.2              httpd-2.4.27.tar.gz                        php-7.1.6.tar.bz2
apr-1.6.2.tar.gz       mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz  phpredis-develop
apr-util-1.6.0         php-5.6.30                                 phpredis-develop.zip
apr-util-1.6.0.tar.gz  php-5.6.30.tar.gz
httpd-2.4.27           php-7.1.6
[root@localhost src]# cd php-5.6.30
[root@localhost php-5.6.30]# ls
acinclude.m4      main                      README.PARAMETER_PARSING_API
aclocal.m4        makedist                  README.REDIST.BINS
build             Makefile                  README.RELEASE_PROCESS
buildconf         Makefile.frag             README.SELF-CONTAINED-EXTENSIONS
buildconf.bat     Makefile.fragments        README.STREAMS
CODING_STANDARDS  Makefile.gcov             README.SUBMITTING_PATCH
config.guess      Makefile.global           README.TESTING
config.log        Makefile.objects          README.TESTING2
config.nice       makerpm                   README.UNIX-BUILD-SYSTEM
config.status     meta_ccld                 README.WIN32-BUILD-SYSTEM
config.sub        missing                   run-tests.php
configure         mkinstalldirs             sapi
configure.in      modules                   scripts
CREDITS           netware                   server-tests-config.php
ext               NEWS                      server-tests.php
EXTENSIONS        pear                      snapshot
footer            php5.spec                 stamp-h.in
generated_lists   php5.spec.in              stub.c
genfiles          php.gif                   tests
header            php.ini-development       travis
include           php.ini-production        TSRM
INSTALL           README.EXT_SKEL           UPGRADING
install-sh        README.GIT-RULES          UPGRADING.INTERNALS
libphp5.la        README.input_filter       vcsclean
libs              README.MAILINGLIST_RULES  win32
libtool           README.md                 Zend
LICENSE           README.namespaces
ltmain.sh         README.NEW-OUTPUT-API
[root@localhost php-5.6.30]# 

[root@localhost php-5.6.30]# make clean
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f 
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp5.la sapi/cli/php sapi/cgi/php-cgi    libphp5.la modules/* libs/*
[root@localhost php-5.6.30]# 
```
- 現在就是一個剛剛解壓的狀態,下面來編譯針對nginx的編譯
- 這時候需要改個名字 叫php-fpm ,因爲之前系統裏 有php目錄,和php7 目錄
```
[root@localhost php-5.6.30]# ls /usr/local/php
php/  php7/ 
[root@localhost php-5.6.30]# ls /usr/local/php
bin  etc  include  lib  php
[root@localhost php-5.6.30]# ls /usr/local/php7
bin  etc  include  lib  php  var
[root@localhost php-5.6.30]# 
```
- 下面開始編譯 
- --prefix=/usr/local/php-fpm 指定路徑 ,--with-config-file-path=/usr/local/php-fpm/etc 配置文件所在路徑,之前是/php/etc/ 現在是/php-fpm/etc/ ,
- --enable-fpm 必須需要加上,不加速就沒有辦法啓動這個服務了。
- --with-fpm-user=php-fpm --with-fpm-group=php-fpm 指定它的用戶和group
- --with-pdo-mysql=/usr/local/mysql 指定mysql 路徑 後面的都是之前講lamp的時候這些都用過,
```
[root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl  --with-openssl



checking whether to enable ctype functions... yes
checking for cURL support... yes
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/
[root@localhost php-5.6.30]# echo $?
1
[root@localhost php-5.6.30]# 
```
- 有錯誤,少了一個curl  用yum 安裝下 libcurl-devel包
```
[root@localhost php-5.6.30]# yum install -y libcurl-devel
已加載插件:fastestmirror
base                                                              | 3.6 kB  00:00:00     


已安裝:
  libcurl-devel.x86_64 0:7.29.0-42.el7                                                   

作爲依賴被升級:
  curl.x86_64 0:7.29.0-42.el7               libcurl.x86_64 0:7.29.0-42.el7              

完畢!
[root@localhost php-5.6.30]# 


完畢!
[root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl  --with-openssl



Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
[root@localhost php-5.6.30]# 

```
- 由於在之前lamp大部分包都安裝過了,現在也不會有太多的錯誤出現
- make && make install
```
[root@localhost php-5.6.30]# make && make install


Installing PEAR environment:      /usr/local/php-fpm/lib/php/
[PEAR] Archive_Tar    - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util       - installed: 1.3.0
[PEAR] PEAR           - installed: 1.10.1
Wrote PEAR system config file at: /usr/local/php-fpm/etc/pear.conf
You may want to add: /usr/local/php-fpm/lib/php to your php.ini include_path
/usr/local/src/php-5.6.30/build/shtool install -c ext/phar/phar.phar /usr/local/php-fpm/bin
ln -s -f phar.phar /usr/local/php-fpm/bin/phar
Installing PDO headers:           /usr/local/php-fpm/include/php/ext/pdo/
[root@localhost php-5.6.30]# echo $?
0
[root@localhost php-5.6.30]# 


```
- 完成,查看下php-fpm 下的文件 比之前php 多了 sbin  var 
```
[root@localhost php-5.6.30]# ls /usr/local/php-fpm/
bin  etc  include  lib  php  sbin  var
[root@localhost php-5.6.30]# ls /usr/local/php/
bin  etc  include  lib  php
[root@localhost php-5.6.30]# 
[root@localhost php-5.6.30]# ls /usr/local/php-fpm/sbin/
php-fpm
[root@localhost php-5.6.30]# 
[root@localhost php-5.6.30]# ls /usr/local/php-fpm/var/
log  run
[root@localhost php-5.6.30]# 
```
- log 下面存放日誌的,run 下面存放pid的,日誌pid 都可以指定
- 可以使用 -m  ,-i都是可以的
```
[root@localhost php-5.6.30]# ls /usr/local/php-fpm/var/log/
[root@localhost php-5.6.30]# ls /usr/local/php-fpm/var/run/
[root@localhost php-5.6.30]# 

[root@localhost php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -m
[PHP Modules]
cgi-fcgi
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]


[root@localhost php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -i




PHP License
This program is free software; you can redistribute it and/or modify
it under the terms of the PHP License as published by the PHP Group
and included in the distribution in the file:  LICENSE

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you did not receive a copy of the PHP license, or have any
questions about PHP licensing, please contact [email protected].
[root@localhost php-5.6.30]# 
```
- /usr/local/php-fpm/sbin/php-fpm -t 這個用來測試 他自己配置文件的語法的
- 也可以看到 用-t 最後發現,這配置文件php-fpm.conf不存在,也就是說你要想啓動php-fpm的服務,你首先要給它配置 配置文件
```
[root@localhost php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -t
[14-Oct-2017 22:03:35] ERROR: failed to open configuration file '/usr/local/php-fpm/etc/php-fpm.conf': No such file or directory (2)
[14-Oct-2017 22:03:35] ERROR: failed to load configuration file '/usr/local/php-fpm/etc/php-fpm.conf'
[14-Oct-2017 22:03:35] ERROR: FPM initialization failed
[root@localhost php-5.6.30]# 
```
- 下面來配置這個服務,讓這個服務起來
-  cp php.ini-production /usr/local/php-fpm/etc/php.ini  把這個php.ini 先做一個拷貝,咱們已經制定了它的配置文件 所在的路徑在/php-fpm/etc/php.ini,所有需要把這個配置文件給拷貝過去,
```
[root@localhost php-5.6.30]# ls /usr/local/php-fpm/etc/
pear.conf  php-fpm.conf.default
[root@localhost php-5.6.30]# 
```
- etc目錄下是沒有php.ini的
- php.ini-development  php.ini-production  ,一個是開發環境中,一個是生產環境中用,假如你做了一個lnmp環境,這個環境是給開發人員用的,也就是你測試的用,
- 如果是正式線上的 用php.ini-production
```
  
[root@localhost php-5.6.30]# p php.ini-
php.ini-development  php.ini-production   
[root@localhost php-5.6.30]# cp php.ini-development /usr/local/php-fpm/etc/php.ini
[root@localhost php-5.6.30]# 

```
- 創建一個 php-fpm.conf 直接寫入,加上一些內容
```

[root@localhost php-5.6.30]# cd /usr/local/php-fpm/etc/
[root@localhost etc]# ls
pear.conf  php-fpm.conf.default  php.ini
[root@localhost etc]# vim php-fpm.conf

[root@localhost etc]# vim php-fpm.conf

[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
#listen = 127.0.0.1:9000
listen.mode = 666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
~                                                                                     
~                                                                                        
:wq   
```
- 下面拷貝啓動的腳本
```
[root@localhost etc]# cd /usr/local/src/php-5.6.30/
[root@localhost php-5.6.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-5.6.30]# 
```
- 改下權限, 啓動服務 提示錯誤 cannot get uid for user 'php-fpm' php-fpm這個用戶不存在
```
[root@localhost php-5.6.30]# chmod 755 /etc/init.d/php-fpm
[root@localhost php-5.6.30]# chkconfig --add php-fpm
[root@localhost php-5.6.30]# chkconfig php-fpm on

[root@localhost php-5.6.30]# service php-fpm start
Starting php-fpm [14-Oct-2017 22:35:15] NOTICE: PHP message: PHP Deprecated:  Comments starting with '#' are deprecated in Unknown on line 1 in Unknown on line 0
[14-Oct-2017 22:35:15] ERROR: [pool www] cannot get uid for user 'php-fpm'
[14-Oct-2017 22:35:15] ERROR: FPM initialization failed
 failed
[root@localhost php-5.6.30]# 
```
- 做個檢測看看有沒有錯 
```
[root@localhost php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -t
[14-Oct-2017 22:36:01] NOTICE: PHP message: PHP Deprecated:  Comments starting with '#' are deprecated in Unknown on line 1 in Unknown on line 0
[14-Oct-2017 22:36:01] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful

[root@localhost php-5.6.30]# 
```
-  提示錯誤 cannot get uid for user 'php-fpm' php-fpm這個用戶不存在
-  添加一個一個用戶php-fpm ,再來啓動
```
[root@localhost php-5.6.30]# useradd php-fpm
[root@localhost php-5.6.30]# 

[root@localhost php-5.6.30]# service php-fpm start
Starting php-fpm [14-Oct-2017 22:38:46] NOTICE: PHP message: PHP Deprecated:  Comments starting with '#' are deprecated in Unknown on line 1 in Unknown on line 0
 done
[root@localhost php-5.6.30]# 


[root@localhost php-5.6.30]# ps aux |grep php-fpm
root     118681  0.0  0.4 123564  4936 ?        Ss   22:38   0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf)
php-fpm  118682  0.0  0.4 123564  4712 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118683  0.0  0.4 123564  4712 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118684  0.0  0.4 123564  4712 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118685  0.0  0.4 123564  4712 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118686  0.0  0.4 123564  4716 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118687  0.0  0.4 123564  4716 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118688  0.0  0.4 123564  4716 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118689  0.0  0.4 123564  4716 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118690  0.0  0.4 123564  4716 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118691  0.0  0.4 123564  4716 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118692  0.0  0.4 123564  4716 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118693  0.0  0.4 123564  4720 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118694  0.0  0.4 123564  4720 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118695  0.0  0.4 123564  4720 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118696  0.0  0.4 123564  4720 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118697  0.0  0.4 123564  4720 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118698  0.0  0.4 123564  4720 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118699  0.0  0.4 123564  4720 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118700  0.0  0.4 123564  4720 ?        S    22:38   0:00 php-fpm: pool www
php-fpm  118701  0.0  0.4 123564  4720 ?        S    22:38   0:00 php-fpm: pool www
root     118703  0.0  0.0 112680   980 pts/0    R+   22:39   0:00 grep --color=auto php-fpm
[root@localhost php-5.6.30]# 

[root@localhost php-5.6.30]# vim /usr/local/php-fpm/etc/php-fpm.conf
[root@localhost php-5.6.30]# ls -l /tmp/php-fcgi.sock
srw-rw-rw-. 1 root root 0 10月 14 22:38 /tmp/php-fcgi.sock
[root@localhost php-5.6.30]# 
```
- php也安裝完了 服務也啓動起來了











# 12.5 Nginx介紹
-  Nginx官網 nginx.org,最新版1.13,最新穩定版1.12 
-  Nginx應用場景:web服務、反向代理、負載均衡
-  Nginx著名分支,淘寶基於Nginx開發的Tengine,使用上和Nginx一致,服務名,配置文件名都一樣,和Nginx的最大區別在於Tenging增加了一些定製化模塊,在安全限速方面表現突出,另外它支持對js,css合併
-  Nginx核心+lua相關的組件和模塊組成了一個支持lua的高性能web容器openresty,參考http://jinnianshilongnian.iteye.com/blog/2280928









### - 擴展
- Nginx爲什麼比Apache Httpd高效:原理篇 http://www.toxingwang.com/linux-unix/linux-basic/1712.html
- apache和nginx工作原理比較 http://www.server110.com/nginx/201402/6543.html
- mod_php 和 mod_fastcgi以及php-fpm的比較 http://dwz.cn/1lwMSd
- 概念瞭解:CGI,FastCGI,PHP-CGI與PHP-FPMhttp://www.nowamagic.net/librarys/veda/detail/1319/ https://www.awaimai.com/371.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章