-------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. Golang 字符串操作--使用strings、strconv包

    strings包 package main import ( "fmt" "strings" ) func main() { //func Count(s, s ...

  2. jvisualvm中VisualGC插件提示:不受此JVM支持

    Visual GC插件「不受此JVM支持」问题 - djp567的博客 - CSDN博客https://blog.csdn.net/djp567/article/details/78662047 jv ...

  3. 3proxy使用方法

    转自:DRL@fireinice写的教程 ******************************************************************************* ...

  4. Notepad++快捷使用

    用Notepad++写代码,要是有一些重复的代码想copy一下有木有简单的方法呢,确实还是有的不过也不算太好用.主要是应用键盘上的 Home 键 和 End 键.鼠标光标停留在一行的某处,按 Home ...

  5. iOS 10的两个坑

    iOS 10出现白屏幕,其他机型不会. 一个bug 手机连上电脑,在电脑端的Safari里,看到了如下的错误: SyntaxError: Cannot declare a let variable t ...

  6. vue上传图片

    在用这块代码前需要在主页面index引入<script src="http://at.alicdn.com/t/font_kfbh2nlnqrrudi.js">< ...

  7. 使用Random类生成指定范围的随机数

    目的:要生成在[min,max]之间的随机整数 public class RandomTest { public static void main(String[] args) { ; ; Rando ...

  8. vue-router路由懒加载(解决vue项目首次加载慢)

    懒加载:----------------------------------------------------? 也叫延迟加载,即在需要的时候进行加载,随用随载. 为什么需要懒加载? 像vue这种单 ...

  9. git客户端下载 和安装

    网址  https://git-scm.com/download/win 点击next 说明: (1)图标组件(Addition icons) : 选择是否创建桌面快捷方式. (2)桌面浏览(Wind ...

  10. Python--文件、文件夹、压缩包、处理模块shutil

    高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length])将文件内容拷贝到另一个文件中 1 import shutil 2 3 shuti ...