此次实验在上次的  企业-mysql  实验基础上所做的实验(lnmp架构)


一、安装php

下载安装包

php-5.6.20.tar.bz2
[root@server1 ~]# tar jxf php-5.6.20.tar.bz2   解包

[root@server1 php-5.6.20]# ./configure --help  寻找帮助
--with-openssl   指定驱动 加密

--with-gd   图

--with-zlib       php网页压缩(防盗链)

--with-pear     功能模块的组件(安装)

安装依赖性

[root@server1 ~]# yum install libjpeg-turbo-devel-1.2.1-1.el6.x86_64
[root@server1 php-5.6.20]# yum install -y libxml2-devel
[root@server1 php-5.6.20]# yum install -y openssl-devel
[root@server1 php-5.6.20]# yum install -y curl-devel
[root@server1 ~]# yum install -y gd-devel-2.0.35-11.el6.x86_64.rpm
[root@server1 ~]# yum install -y gmp-devel
[root@server1 ~]# yum install libmcrypt-devel-2.5.8-9.el6.x86_64.rpm libmcrypt-2.5.8-9.el6.x86_64.rpm -y
[root@server1 ~]# yum install -y net-snmp-devel
[root@server1 ~]# yum install re2c-0.13.5-1.el6.x86_64.rpm -y

执行

[root@server1 php-5.6.20]# ./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl  --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash


[root@server1 php-5.6.20]# make && make install
编译完成

企业 - php nginx memcache_php


企业 - php nginx memcache_php_02


拷贝文件到指定路径

[root@server1 php-5.6.20]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini

企业 - php nginx memcache_php_03


[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@server1 fpm]# chmod +x /etc/init.d/php-fpm     加执行权限

企业 - php nginx memcache_安装 _04


修改php配置文件 

企业 - php nginx memcache_安装_05

企业 - php nginx memcache_php_06




开启服务,发现出错,说是没有用户

企业 - php nginx memcache_php_07

按照报错,新建用户


企业 - php nginx memcache_php_08

服务开启


企业 - php nginx memcache_php_09

php服务端口9000端口已开

企业 - php nginx memcache_安装 _10


二、安装nginx


下载

nginx-1.10.1.tar.gz
[root@server1 ~]# tar zxf nginx-1.10.1.tar.gz    解压

修改文件

[root@server1 core]# pwd
/root/nginx-1.10.1/src/core
[root@server1 core]# vim nginx.h

企业 - php nginx memcache_安装_11

[root@server1 cc]# pwd
/root/nginx-1.10.1/auto/cc
[root@server1 cc]# vim gcc

企业 - php nginx memcache_安装 _12


编译前安装依赖性

[root@server1 nginx-1.10.1]# yum install -y pcre-devel

进行编译

[root@server1 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-threads --user=nginx --group=nginx

[root@server1 nginx-1.10.1]# make && make install

企业 - php nginx memcache_安装 _13


[root@server1 sbin]# ln -s /usr/local/lnmp/nginx/sbin/nginx /usr/local/sbin/  做软连接

[root@server1 ~]# nginx -t      检测语法
企业 - php nginx memcache_安装 _14

开启服务,查看服务端口

[root@server1 ~]# nginx   开启服务
[root@server1 ~]# netstat -antlp
企业 - php nginx memcache_安装_15


修改配置文件

[root@server1 conf]# vim nginx.conf
企业 - php nginx memcache_安装 _16


企业 - php nginx memcache_安装 _17



[root@server1 conf]# nginx -t    检查语法
[root@server1 conf]# nginx -s reload   重新加载

企业 - php nginx memcache_安装_18


创建nginx访问php主页的页面

企业 - php nginx memcache_php_19

[root@server1 conf]# vim nginx.conf

企业 - php nginx memcache_php_20

[root@server1 conf]# nginx -t
[root@server1 conf]# nginx -s reload

浏览器访问

企业 - php nginx memcache_安装 _21




三、解决php和mysql的依赖关系 


企业 - php nginx memcache_安装_22

修改配置文件

[root@server1 etc]# vim php.ini

企业 - php nginx memcache_php_23


企业 - php nginx memcache_安装 _24

企业 - php nginx memcache_安装_25

修改完文件,重新加载

企业 - php nginx memcache_安装 _26


四、搭建基于lnmp的论坛


下载

Discuz_X3.2_SC_UTF8.zip 

[root@server1 ~]# yum install -y unzip  

[root@server1 ~]# unzip Discuz_X3.2_SC_UTF8.zip   解压

修改解压出的目录名字

企业 - php nginx memcache_安装 _27


企业 - php nginx memcache_安装_28


ngnx设置虚拟主机 实现基于域名访问nginx


vim  /usr/local/lnmp/nginx/conf/nginx.conf


企业 - php nginx memcache_安装_29

nginx -t   检测

nginx -s reload  加载 

企业 - php nginx memcache_安装_30



如下修改权限

企业 - php nginx memcache_安装 _31


企业 - php nginx memcache_php_32


企业 - php nginx memcache_安装_33


[root@server1 conf]# /etc/init.d/mysqld restart


[root@server1 install]# mysql -p

mysql> show databases;
mysql> use discuz
mysql> show tables;



五、memcoache 基于php的cache 


[root@server2 ~]#  yum install -y memcached

企业 - php nginx memcache_安装 _34

Telnet

Telnet协议是TCP/IP协议族中的一员,是Internet远程登陆服务的标准协议和主要方式。它为用户提供了在本地计算机上完成远程主机工作的能力。在终端使用者的电脑上使用telnet程序,用它连接到服务器终端使用者可以在telnet程序中输入命令,这些命令会在服务器上运行,就像直接在服务器的控制台上输入一样。可以在本地就能控制服务器。要开始一个telnet会话,必须输入用户名和密码来登录服务器。Telnet是常用的远程控制Web服务器的方法。


[root@server2 ~]# yum install telnet -y


企业 - php nginx memcache_安装 _35

企业 - php nginx memcache_php_36




企业 - php nginx memcache_php_37


[root@server1 bin]# vim ~/.bash_profile   环境变量

企业 - php nginx memcache_安装 _38


[root@server1 bin]# source ~/.bash_profile  


[root@server1 ~]# tar zxf memcache-2.2.5.tgz

企业 - php nginx memcache_php_39



[root@server1 memcache-2.2.5]# ./configure --prefix=/usr/local/lnmp/php/memcache

[root@server1 memcache-2.2.5]# make && make install

企业 - php nginx memcache_安装 _40


企业 - php nginx memcache_安装_41


企业 - php nginx memcache_安装_42


[root@server1 etc]# vim php.ini    修改配置文件

企业 - php nginx memcache_php_43

重新加载服务

企业 - php nginx memcache_安装 _44


拷贝文件

企业 - php nginx memcache_安装_45

查看端口

企业 - php nginx memcache_php_46


[root@server1 html]# vim example.php

企业 - php nginx memcache_安装_47

[root@server1 html]# vim memcache.php

企业 - php nginx memcache_安装_48



(client -> nginx -> php-fpm -> php -> memcached -> mysql)


企业 - php nginx memcache_安装_49



六、OpenResty

OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关

OpenResty® 通过汇聚各种设计精良的 Nginx 模块(主要由 OpenResty 团队自主开发),从而将 Nginx 有效地变成一个强大的通用 Web 应用平台。这样,Web 开发人员和系统工程师可以使用 Lua 脚本语言调动 Nginx 支持的各种 C 以及 Lua 模块,快速构造出足以胜任 10K 乃至 1000K 以上单机并发连接的高性能 Web 应用系统。

OpenResty® 的目标是让你的Web服务直接跑在 Nginx 服务内部,充分利用 Nginx 的非阻塞 I/O 模型,不仅仅对 HTTP 客户端请求,甚至于对远程后端诸如 MySQL、PostgreSQL、Memcached 以及 Redis 等都进行一致的高性能响应。


下载安装包

openresty-1.13.6.1.tar.gz

[root@server1 ~]# tar zxf openresty-1.13.6.1.tar.gz   解压

企业 - php nginx memcache_安装 _50

[root@server1 openresty-1.13.6.1]# gmake
[root@server1 openresty-1.13.6.1]# gmake install

企业 - php nginx memcache_php_51


[root@server1 nginx]# nginx -s stop   关掉之前的nginx服务

企业 - php nginx memcache_安装_52


浏览器访问该主机

企业 - php nginx memcache_php_53


企业 - php nginx memcache_安装_54


[root@server1 conf]# vim nginx.conf   修改配置文件

企业 - php nginx memcache_安装 _55


企业 - php nginx memcache_php_56


写页面,改访问顺序

企业 - php nginx memcache_安装 _57

企业 - php nginx memcache_php_58



企业 - php nginx memcache_安装_59


企业 - php nginx memcache_安装_60