环境设定
base2 | 172.25.78.12 | nginx+php |
---|---|---|
base3 | 172.25.78.13 | redis端 |
base4 | 172.25.78.14 | mysql端 |
# 1.在base2(nginx+php)上
配置nginx和php(这里的nginx只是提供了负载均衡,所以版本要求不高)
[root@base2 ~]# killall redis-server
[root@base2 ~]# ls
gearmand-1.1.12-18.el7.x86_64.rpm
php-fpm-5.4.16-46.el7.x86_64.rpm
libevent-devel-2.0.21-4.el7.x86_64.rpm
php-mysql-5.4.16-46.el7.x86_64.rpm
libgearman-1.1.12-18.el7.x86_64.rpm
php-pdo-5.4.16-46.el7.x86_64.rpm
libgearman-devel-1.1.12-18.el7.x86_64.rpm
php-pecl-gearman-1.1.2-1.el7.x86_64.rpm
libzip-0.10.1-8.el7.x86_64.rpm
php-pecl-igbinary-1.2.1-1.el7.x86_64.rpm
openssl-1.0.2k-16.el7.x86_64.rpm
php-pecl-redis-2.2.8-1.el7.x86_64.rpm
openssl-libs-1.0.2k-16.el7.x86_64.rpm
php-process-5.4.16-46.el7.x86_64.rpm
php-cli-5.4.16-46.el7.x86_64.rpm
php-xml-5.4.16-46.el7.x86_64.rpm
php-common-5.4.16-46.el7.x86_64.rpm
[root@base2 ~]# yum install -y *.rpm # 安装php
注:当服务器上有openssl-devel开发包时,会有冲突,所以要先删除
[root@base2 ~]# tar zxf nginx-1.14.2.tar.gz
[root@base2 ~]# cd nginx-1.14.2
[root@base2 nginx-1.14.2]# vim auto/cc/gcc
171 # debug
172 #CFLAGS="$CFLAGS -g"
[root@base2 nginx-1.14.2]# vim src/core/nginx.h
14 #define NGINX_VER "nginx/"
[root@base2 nginx-1.14.2]# ./configure --prefix=/usr/local/nginx
[root@base2 nginx-1.14.2]# make && make install
[root@base2 ~]# cd /usr/local/nginx/conf/
[root@base2 conf]# vim nginx.conf
location / {
root html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
[root@base2 conf]# ln -s /usr/local/nginx/sbin/nginx /sbin
[root@base2 conf]# nginx -t
[root@base2 conf]# nginx # 开启nginx服务
[root@base2 conf]# vim /etc/php.ini
878 date.timezone =Asia/Shanghai
[root@base2 conf]# vim /etc/php-fpm.d/www.conf
39 user = nginx
41 group = nginx
[root@base2 conf]# systemctl start php-fpm
[root@base2 conf]# systemctl status php-fpm # 开启php服务
[root@base2 conf]# netstat -antlp # 查看php的端口