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

Centos7 nginx+php+redis environment construction

Jul 30, 2016 pm 01:30 PM
install nginx php phpredis redis

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.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

The Future of PHP: Adaptations and Innovations The Future of PHP: Adaptations and Innovations Apr 11, 2025 am 12:01 AM

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

How to build the redis cluster mode How to build the redis cluster mode Apr 10, 2025 pm 10:15 PM

Redis cluster mode deploys Redis instances to multiple servers through sharding, improving scalability and availability. The construction steps are as follows: Create odd Redis instances with different ports; Create 3 sentinel instances, monitor Redis instances and failover; configure sentinel configuration files, add monitoring Redis instance information and failover settings; configure Redis instance configuration files, enable cluster mode and specify the cluster information file path; create nodes.conf file, containing information of each Redis instance; start the cluster, execute the create command to create a cluster and specify the number of replicas; log in to the cluster to execute the CLUSTER INFO command to verify the cluster status; make

PHP: Is It Dying or Simply Adapting? PHP: Is It Dying or Simply Adapting? Apr 11, 2025 am 12:13 AM

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

How to implement the underlying redis How to implement the underlying redis Apr 10, 2025 pm 07:21 PM

Redis uses hash tables to store data and supports data structures such as strings, lists, hash tables, collections and ordered collections. Redis persists data through snapshots (RDB) and append write-only (AOF) mechanisms. Redis uses master-slave replication to improve data availability. Redis uses a single-threaded event loop to handle connections and commands to ensure data atomicity and consistency. Redis sets the expiration time for the key and uses the lazy delete mechanism to delete the expiration key.

How to view all keys in redis How to view all keys in redis Apr 10, 2025 pm 07:15 PM

To view all keys in Redis, there are three ways: use the KEYS command to return all keys that match the specified pattern; use the SCAN command to iterate over the keys and return a set of keys; use the INFO command to get the total number of keys.

How to read the source code of redis How to read the source code of redis Apr 10, 2025 pm 08:27 PM

The best way to understand Redis source code is to go step by step: get familiar with the basics of Redis. Select a specific module or function as the starting point. Start with the entry point of the module or function and view the code line by line. View the code through the function call chain. Be familiar with the underlying data structures used by Redis. Identify the algorithm used by Redis.

Summary of phpmyadmin vulnerabilities Summary of phpmyadmin vulnerabilities Apr 10, 2025 pm 10:24 PM

The key to PHPMyAdmin security defense strategy is: 1. Use the latest version of PHPMyAdmin and regularly update PHP and MySQL; 2. Strictly control access rights, use .htaccess or web server access control; 3. Enable strong password and two-factor authentication; 4. Back up the database regularly; 5. Carefully check the configuration files to avoid exposing sensitive information; 6. Use Web Application Firewall (WAF); 7. Carry out security audits. These measures can effectively reduce the security risks caused by PHPMyAdmin due to improper configuration, over-old version or environmental security risks, and ensure the security of the database.

See all articles