-------Nginx----------PHP+NFS------------MySql------
192.168.56.202 192.168.56.201 192.168.56.200
安装MySql
安装Nginx
[root@localhost nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
[root@localhost nginx-1.6.0]# make && make install
[root@localhost nginx-1.6.0]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
[root@localhost nginx-1.6.0]# nginx -t
[root@localhost nginx-1.6.0]# nginx
测试:http://192.168.56.202

安装PHP
[root@localhost php-5.3.28]# yum install gd libxml2-devel libjpeg-devel libpng-devel -y
[root@localhost php-5.3.28]# ./configure --prefix=/usr/local/php
--with-gd
--with-zlib
--with-mysql=mysqlnd
--with-pdo-mysql=mysqlnd
--with-mysqli=mysqlnd
--with-config-file-path=/usr/local/php
--enable-mbstring
--enable-fpm
--with-jpeg-dir=/usr/lib
[root@localhost php-5.3.28]# cp php.ini-development /usr/local/php/php.ini
[root@localhost php-5.3.28]# vim /usr/local/php/php.ini
default_charset = "utf-8"
short_open_tag = On
[root@localhost php-5.3.28]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-5.3.28]# chmod +x /etc/init.d/php-fpm
[root@localhost php-5.3.28]#chkconfig --add php-fpm
[root@localhost php-5.3.28]#chkconfig php-fpm on
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# vim php-fpm.conf
pid = run/php-fpm.pid
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
[root@localhost ~]# service php-fpm start

整合nginx与PHP
Nginx server 192.156.56.202
[root@localhost ~]# mkdir /www
[root@localhost ~]# chown -R nginx.nginx /www/

[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
location / {
root /www;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /www;
fastcgi_pass 192.168.56.201:9000; //注意为PHP服务器
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}

[root@localhost ~]#/etc/init.d/nginx restart
在PHP服务器上,建立nginx用户,要保证和nginx服务器上的nginx用户id号、组id号一致
[root@localhost ~]# useradd nginx
[root@localhost ~]# vim /usr/local/php/etc/php-fpm.conf
listen = 192.168.56.201:9000     
user = nginx
group = nginx
[root@localhost ~]# /etc/init.d/php-fpm restart

在PHP服务器上,创建NFS共享
[root@localhost ~]# mkdir /www
[root@localhost ~]# chown -R nginx.nginx /www
[root@localhost ~]# vim /etc/exports
/www 192.168.56.0/24(rw,no_root_squash,sync)
no_root_squash:登入 NFS 主机使用分享目录的使用者,如果是 root 的话,那么对于这个分享的目录来说,他就具有 root 的权限!这个项
目『极不安全』,不建议使用!
root_squash:在登入 NFS 主机使用分享之目录的使用者如果是 root 时,那么这个使用者的权限将被压缩成为匿名使用者,通常他的 UID
与 GID 都会变成 nobody 那个系统账号的身份。
[root@localhost ~]# service nfs start

nginx服务器挂载nfs文件,并测试php,测试成功后删除index.php:
[root@localhost ~]# showmount -e 192.168.56.201 //查看共享
[root@localhost ~]# mount -t nfs 192.168.56.201:/www /www
[root@localhost ~]# vim /www/index.php
[root@localhost ~]# service nginx restart

整合PHP与MYSQL
在mysql服务器上创建php服务器能够访问的数据库和用户:
mysql> grant all on *.* to 'root'@'192.168.56.201' identified by 'redhat'
//注意授权的是PHP服务器的登录地址
mysql> flush privileges;
[root@localhost ~]# unzip Discuz_7.2_FULL_SC_UTF8.zip
[root@localhost ~]# mv upload/* /www/
[root@localhost ~]# chmod -R 777 /www/*

浏览器登录:http://http://192.168.56.202/install //注意mysql地址为:192.168.56.200
在mysql服务器上测试:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| discuz |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)

分离式部署LNMP的更多相关文章

  1. Linux系统——LNMP分离式部署

    #### 安装nginx ```[root@localhost ~]# tar xf nginx-1.10.2.tar.gz -C /usr/src/[root@localhost ~]# cd /u ...

  2. LNMP分离式部署

    #### LNMP组合工作流程 在LNMP组合工作时,首先是用户通过浏览器输入域名请求Nginx Web服务,如果请求是静态资源,则由Nginx解析返回给用户:如果是动态请求(.php结尾),那么Ng ...

  3. LNMP分离式部署实例[转]

    很多人在练习部署LNMP环境的时候,大都数是部署在同一个虚拟机上面的.但是实际工作中,我们一般都是分离部署的. 今天我就用3台虚拟机,部署下LNMP环境.以供参考! 网络拓扑图: 首先准备3台虚拟机: ...

  4. 在ConoHa上Centos7环境下源码安装部署LNMP

    本文记录了从源码,在Centos 7上手动部署LNMP环境的过程,为了方便以后对nginx和mariadb进行升级,这里采用yum的方式进行安装. 1.建立运行网站和数据库的用户和组 groupadd ...

  5. 【转载】Centos系统快速部署LNMP环境

    PHP语言在Linux系统上运行的时候,需要在Linux系统上部署相应的Nginx.MySQL.PHP等环境,只有将这些环境参数都设置好,PHP相关应用程序才可正常运行,部署环境的方法有很多种,可手动 ...

  6. Docker Compose 一键部署LNMP

    Docker Compose 一键部署LNMP 目录结构 [root@localhost ~]# tree compose_lnmp/ compose_lnmp/ ├── docker-compose ...

  7. Docker Compose部署lnmp

    参考:https://github.com/micooz/docker-lnmp 一.简介 使用Dcoekr镜像部署lnmp(Linux.Nginx.MySQL.PHP7). 1.1 结构 app └ ...

  8. Docker swarm 使用服务编排部署lnmp

    一.简介 目的:在Docker Swarm集群中,使用stack服务编排搭建lnmp来部署WordPress 使用私有仓库的nginx和php镜像 mysql使用dockerhup最新镜像 使用nfs ...

  9. 使用Docker 一键部署 LNMP+Redis 环境

    使用Docker 部署 LNMP+Redis 环境 Docker 简介 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linu ...

随机推荐

  1. NGINX Docs | Load Balancing Apache Tomcat Servers with NGINX Open Source and NGINX Plus

    NGINX Docs | Load Balancing Apache Tomcat Servers with NGINX Open Source and NGINX Plushttps://docs. ...

  2. zabbix使用jmx监控tomcat

    zabbix监控Tomcat/JVM实例性能(115) – 运维生存时间http://www.ttlsa.com/zabbix/zabbix-use-jmx-monitor-tomcat/ zabbi ...

  3. Migrate MySQL database using dump and restore

    kaorimatz/mysqldump-loader: Load a MySQL dump file using LOAD DATA INFILEhttps://github.com/kaorimat ...

  4. freemarker数值格式化

    语法:number?string(exp) 说明:根据给定的格式化表达式将数值格式化为字符串. 参数:格式化字符串,"0"表示固定占位(至少有这个位数,不足位数用0代替),&quo ...

  5. Java语言中姐种遍历List的方法总结

    遍历 List 的方法: 1. for 2. advanced for 3. Iterator 4. while 5. ListIterator List<E> list 1. for f ...

  6. 无法启动此程序,因为计算机丢失MSVCR110.dll

    解决方法下: 1.首先是打开浏览器,在浏览器的地址栏里输入 http://www.microsoft.com/zh-CN/download/details.aspx?id=30679 这个网址来进行相 ...

  7. js笔记2

    原型:prototype 和 __proto__ prototype 给他即将生成的对象继承下去的属性 prototype: 显式原型,每个function下都有prototype属性,该属性是一个对 ...

  8. SELECT IDENT_CURRENT(tableName)和自增长列的纠结

    项目中要用到一个功能:主表主键为自增长,要求在插入主表数据前先获得主表要插入数据的主键ID值,用在插入子表时获取主键ID.在网上搜了一下,发现SELECT IDENT_CURRENT(TableNam ...

  9. vpx

    VPX 编辑 本词条缺少名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧! VPX总线是VITA(VME International Trade Association, VME国际贸易协 ...

  10. iPhone

    电报交流***vpnpay app不能用了,只要能下载就可以用,谨慎卸载 升级.网络链接不成功的,多试几次,毕竟程序不会运行你的错误操作 ,重新添加链接服务器,继续搞!耐心的进行下面操作即可链接,如有 ...