nginx和mysql分开_nginx+php-fpm+mysql分离部署详解

本文详细介绍了如何将Nginx、PHP-FPM和MySQL部署到三台独立的主机上,涉及安装、配置及整合过程。首先分别在各主机上安装Nginx、MySQL和PHP,然后配置Nginx以支持PHP处理,接着整合Nginx与PHP,最后连接MySQL数据库,并安装和配置了缓存加速模块XCACHE和Memcache。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

相信大家将这三者部署到同一台主机应该已经不陌生了,今天在这里,给大家演示一下如何将三者部署到三台主机上。

实验系统:CentOS 6.6_x86_64

实验前提:大部分软件使用编译安装,请提前准备好编译环境,防火墙和selinux都关闭

实验软件:nginx-1.9.3 mariadb-10.0.20 php-5.6.11 memcache-2.2.7 xcache-3.2.0

实验拓扑:

220953072095524.png

一、安装nginx

1.解决依赖关系:

需要专门安装pcre-devel包:1 yum -y install pcre-devel

2.添加nginx用户:1 useradd -r nginx

3.解压并编译安装nginx:

copycode.gif1 tar xf nginx-1.9.3.tar.gz 

2 cd nginx-1.9.3 3 ./configure \ 4   --prefix=/usr/local/nginx \                    //安装位置 5   --sbin-path=/usr/local/nginx/sbin/nginx \            //程序文件 6   --conf-path=/etc/nginx/nginx.conf \                //配置文件安装位置 7   --error-log-path=/var/log/nginx/error.log \           //错误日志安装位置 8   --http-log-path=/var/log/nginx/access.log \           //访问日志安装位置 9   --pid-path=/var/run/nginx/nginx.pid  \              //pid文件位置10   --lock-path=/var/lock/nginx.lock \                //锁文件位置11   --user=nginx \                            //运行进程时使用的用户身份12   --group=nginx \                           //运行进程时使用的用户组13   --with-http_ssl_module \                      //支持ssl模块14   --with-http_flv_module \                      //支持flv模块15   --with-http_stub_status_module \                 //支持stub_status模块16   --with-http_gzip_static_module \                 //支持gzip_static模块17   --http-client-body-temp-path=/var/tmp/nginx/client/ \    //存储HTTP客户端请求body体的临时文件位置18   --http-proxy-temp-path=/var/tmp/nginx/proxy/ \        //存储HTTP代理的临时文件位置19   --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \        //存储fasycgi临时文件位置20   --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \         //存储uwsgi临时文件位置21   --http-scgi-temp-path=/var/tmp/nginx/scgi \          //存储scgi临时文件位置22   --with-pcre                             //支持pcre库23 make && make install

copycode.gif

4.提供脚本文件:

copycode.gif1 vim /etc/init.d/nginx  2 --------------------------------  3 #!/bin/sh  4 #  5 # nginx - this script starts and stops the nginx daemon  6 #  7 # chkconfig:   - 85 15   8 # description:  Nginx is an HTTP(S) server, HTTP(S) reverse \  9 #               proxy and IMAP/POP3 proxy server 10 # processname: nginx 11 # config:      /etc/nginx/nginx.conf 12 # config:      /etc/sysconfig/nginx 13 # pidfile:     /var/run/nginx.pid 14   15 # Source function library. 16 . /etc/rc.d/init.d/functions 17   18 # Source networking configuration. 19 . /etc/sysconfig/network 20   21 # Check that networking is up. 22 [ "$NETWORKING" = "no" ] && exit 0 23   24 nginx="/usr/local/nginx/sbin/nginx" 25 prog=$(basename $nginx) 26   27 NGINX_CONF_FILE="/etc/nginx/nginx.conf" 28   29 [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx 30   31 lockfile=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值