Home > Backend Development > PHP Tutorial > Centos7 nginx+php+redis environment construction

Centos7 nginx+php+redis environment construction

WBOY
Release: 2016-07-30 13:30:11
Original
1028 people have browsed it

1. nginx install:
Download the nginx package (package) corresponding to the current system version

<code><span># wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm</span>
建立nginx的yum仓库
<span># rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm</span>
下载并安装nginx
<span># yum install nginx</span>
启动nginx服务
systemctl start nginx
配置
默认的配置文件在 /etc/nginx 路径下,使用该配置已经可以正确地运行nginx;如需要自定义,修改其下的 nginx.conf 等文件即可。
测试
在浏览器地址栏中输入部署nginx环境的机器的IP,如果一切正常,应该能看到如下字样的内容。

/etc/nginx/nginx.conf <span>delete</span> the comment <span>#</span><span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>#</span>
 location ~ \.php$ {
        root           html;
        fastcgi_pass   <span>127.0</span><span>.0</span><span>.1</span>:<span>9000</span>;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  <span>/usr/share/nginx/html/</span>$fastcgi_script_name;
        include        fastcgi_params;
    }
<span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>#</span>service nginx restart</code>
Copy after login

2, redis install:

<code>wget http://download<span>.redis</span><span>.io</span>/releases/redis-<span>3.0</span><span>.0</span><span>.tar</span><span>.gz</span>
tar zxvf redis-<span>3.0</span><span>.0</span><span>.tar</span><span>.gz</span>
cd redis-<span>3.0</span><span>.0</span>
./configure<span>;make;make install</span>
redis-server /etc/redis<span>.conf</span></code>
Copy after login

3, php-redis install:

<code>error:the GPG keys listed for the <span>"CentOS-7 - Updates - 163.com"</span> repository are already insta
rpm <span>--</span><span>import</span> /etc/pki/rpm<span>-gpg</span>/RPM<span>-GPG</span><span>-KEY</span><span>-CentOS</span><span>-</span><span>7</span>
cd /tmp
wget https:<span>//github.com/nicolasff/phpredis/zipball/master -O php-redis.zip</span>
unzip php<span>-redis</span><span>.</span>zip
解压后目录是:nicolasff<span>-phpredis</span><span>-</span><span>21</span>d6614
cd nicolasff<span>-phpredis</span><span>-</span><span>21</span>d6614
phpize
<span>.</span>/configure
make
make install
确认一下so文件已经放置到正确目录
ll /usr/lib/php/modules/redis<span>.</span>so
vi /etc/php<span>.</span>ini 
add the following content<span>.</span>
extension<span>=</span>redis<span>.</span>so
<span>[</span>root@localhost phpredis<span>-phpredis</span><span>-fc673f5</span><span>]</span><span># ll /usr/lib64/php/modules/redis.so</span></code>
Copy after login

4, php-fpm install:

<code>so <span>as</span><span>to</span> parse <span>the</span> php <span>by</span> nginx
yum install php-fpm</code>
Copy after login

5, start php-fpm nginx

<code>vi /etc/php<span>-fpm</span><span>.</span>conf daemonize <span>=</span> yes
php<span>-fpm</span><span>-c</span> /etc/php<span>.</span>ini
service nginx restart</code>
Copy after login

6, test nginx and php

<code>http://localhost/test.php
<span><span><?php</span><span>echo</span> phpinfo();
<span>?></span></span></code>
Copy after login

Copyright statement: This article is the original article of the blogger and may not be reproduced without the permission of the blogger.

The above introduces the Centos7 nginx+php+redis environment construction, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template