配置环境:redhat6.5
server1:redis(172.25.254.1)
server2:php(172.25.254.2)
server3:mysql(172.25.254.3)
配置步骤:
server2:
1、server2安装php的redis相应模块
2、nginx安装
[root@server2 php-fpm.d]# rpm -ivh nginx-1.8.0-1.el6.ngx.x86_64.rpm warning: nginx-1.8.0-1.el6.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEYPreparing... ########################################### [100%] 1:nginx ########################################### [100%]---------------------------------------------------------------------- Thanks for using nginx! Please find the official documentation for nginx here:* https://nginx.org/en/docs/Commercial subscriptions for nginx are available on:* https://nginx.com/products/ ----------------------------------------------------------------------[root@server2 php-fpm.d]# id nginxuid=498(nginx) gid=499(nginx) groups=499(nginx) |
3、nginx和php配置
1、php配置
[root@server2 php-fpm.d]# cd /etc/php-fpm.d/[root@server2 php-fpm.d]# id nginxuid=498(nginx) gid=499(nginx) groups=499(nginx)[root@server2 php-fpm.d]# vim www.conf 39 user = nginx 41 group = nginx [root@server2 php-fpm.d]# vim /etc/php.ini 946 date.timezone = Asia/Shanghai[root@server2 php-fpm.d]# /etc/init.d/php-fpm startStarting php-fpm: [ OK ][root@server2 php-fpm.d]# netstat -antlp | grep phptcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1125/php-fpm [root@server2 php-fpm.d]# vim /etc/php.ini |
2、nginx配置
[root@server2 ~]# cd /etc/nginx/conf.d/[root@server2 conf.d]# lsdefault.conf example_ssl.conf[root@server2 conf.d]# vim default.conf 10 index index.php index.html index.htm; 30 location ~ /.php$ { 31 root html; 32 fastcgi_pass 127.0.0.1:9000; 33 fastcgi_index index.php; 34 fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script _name; 35 include fastcgi_params; 36 }[root@server2 conf.d]# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful[root@server2 conf.d]# nginx [root@server2 conf.d]# netstat -anplt |grep nginxtcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1141/nginx |
php测试:
[root@server2 conf.d]# cd /usr/share/nginx/html/[root@server2 html]# vim index.php[root@server2 html]# cat index.php <!--phpphpinfo()-->[root@server2 html]# /etc/init.d/php-fpm reloadReloading php-fpm: [14-Jul-2018 01:09:13] NOTICE: configuration file /etc/php-fpm.conf test is successful [ OK ] |