LNMP環境下安裝Redis,以及php的redis擴展

来源:https://www.cnblogs.com/zmdComeOn/archive/2018/09/06/9596799.html
-Advertisement-
Play Games

1.下載 2.解壓 3.重命名 4.編譯 有可能會出現 那就去安裝 成功了 安裝PHP-redis擴展 1.下載 2.解壓 3.找到phpize文件,生成配置 在redis-4.0.2文件夾中執行 4.配置 這個時候會報一些錯誤,打開php.ini 去除shell_exec,proc_open 5. ...


1.下載

sudo wget http://download.redis.io/releases/redis-4.0.9.tar.gz

2.解壓

sudo tar zvxf redis-4.0.9.tar.gz 

3.重命名

sudo mv redis-4.0.9/ redis

4.編譯

cd redis
sudo make
sudo make test
sudo make install

有可能會出現

You need tcl 8.5 or newer 

那就去安裝

sudo wget https://downloads.sourceforge.net/tcl/tcl8.6.8-src.tar.gz
sudo tar xzvf tcl8.6.8-src.tar.gz  -C /usr/local/  
cd  /usr/local/tcl8.6.1/unix/  
sudo ./configure  
sudo make  
sudo make install   

成功了

redis-server
27904:C 23 May 02:23:52.443 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
27904:C 23 May 02:23:52.443 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=27904, just started
27904:C 23 May 02:23:52.443 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
27904:M 23 May 02:23:52.445 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
27904:M 23 May 02:23:52.445 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
27904:M 23 May 02:23:52.445 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 27904
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                          
jiqing@jiqing-pad:~$ redis-cli
127.0.0.1:6379> set name jack
OK
127.0.0.1:6379> get name
"jack"
127.0.0.1:6379> 

安裝PHP-redis擴展

1.下載

sudo wget https://pecl.php.net/get/redis-4.0.2.tgz

2.解壓

sudo tar -zxvf redis-4.0.2.tgz 

3.找到phpize文件,生成配置

$whereis phpize
phpize: /usr/bin/phpize

在redis-4.0.2文件夾中執行

sudo /usr/bin/phpize 
drwxr-xr-x  2 root root     4096 5月  23 01:57 ./
drwxr-xr-x 10 root root     4096 5月  23 01:57 ../
-rwxr-xr-x  1 root root      837 5月  23 01:57 pear*
-rwxr-xr-x  1 root root      858 5月  23 01:57 peardev*
-rwxr-xr-x  1 root root      774 5月  23 01:57 pecl*
lrwxrwxrwx  1 root root        9 5月  23 01:57 phar -> phar.phar*
-rwxr-xr-x  1 root root    14833 5月  23 01:57 phar.phar*
-rwxr-xr-x  1 root root 48618304 5月  23 01:57 php*
-rwxr-xr-x  1 root root 48473272 5月  23 01:57 php-cgi*
-rwxr-xr-x  1 root root     3325 5月  23 01:57 php-config*
-rwxr-xr-x  1 root root     4534 5月  23 01:57 phpize*

4.配置

sudo ./configure  --with-php-config=/usr/local/php/bin/php-config 
sudo make
sudo make test

這個時候會報一些錯誤,打開php.ini

 sudo vi /usr/local/php/etc/php.ini 
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server

去除shell_exec,proc_open

sudo make install

5.添加擴展

extension=redis.so

查看

php -m
jiqing@jiqing-pad:/$ php -m |grep redis
redis

已經添加成功了!

進一步測試,

<?php
    $redis = new Redis();
    $redis->connect('127.0.0.1',6379);
    $redis->set('test','hello world!');
    echo $redis->get('test');
?>
hello world!
Process finished with exit code 0

成功!

進一步查看服務開啟情況!

jiqing@jiqing-pad:/home/wwwroot/default$ sudo netstat -anp|grep :6379
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      27904/redis-server  
tcp6       0      0 :::6379                 :::*                    LISTEN      27904/redis-server  
jiqing@jiqing-pad:/home/wwwroot/default$ sudo ps -ef |grep redis
jiqing    1576 32272  0 03:05 pts/1    00:00:00 grep --color=auto redis
jiqing   27904  1772  0 02:23 ?        00:00:02 redis-server *:6379

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • segmentfault對應博文頁面:https://segmentfault.com/a/1190000016300215 最近一直在閱讀ovs的源碼,看到用戶態代碼的時候,需要對用戶態的代碼進行調試,一開始想直接使用linux中的GDB進行調試,但是ovs的工程太過於複雜,從網上找了些文章,發現 ...
  • 訪問 https://extensions.gnome.org/ 網站(註意:需要安裝 chrome-gnome-shell rpm 包來使得系統能與web進行通信) 安裝插件: notifications alert 消息提醒 permanent notification 消息提醒,不消失 在用戶 ...
  • 在11上安裝mysql yum install mariadb mariadb-server -y 在mysql的配置文件my.cnf中加入 init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAM ...
  • 第1章 NFS介紹 1.1 NFS基本概述 NFS(Network File System)網路文件系統 主要功能是通過區域網絡讓不同的主機系統之間可以共用文件或目錄。 NFS(Network File System)網路文件系統 NFS系統和Windows網路共用、網路驅動器類似, 只不過wind ...
  • 快速啟動是首先在Windows 8中實現並延續到Windows 10的功能,可在啟動PC時提供更快的啟動時間。它是一個方便的功能,也是大多數人在不知情的情況下使用的功能,但還有一些功能會在他們掌握新PC時立即禁用它。 什麼是快速啟動? Windows PC通常以多種高級配置和電源介面(ACPI)電源 ...
  • 在Microsoft Edge中,當您打開多個選項卡時,瀏覽器將顯示“您要關閉所有選項卡嗎?” 警告,以防止您意外關閉重要標簽。 通常,在沒有第二個想法的情況下,您會立即禁用此功能,檢查提示中的“始終關閉所有選項卡”選項。唯一需要註意的是,Edge不包含重新啟用消息的設置,如果以後,您會發現它是您需 ...
  • 我造輪子,你造車,創客一起造起來!塔克創新資訊【塔克社區 www.xtark.cn 】【塔克博客 www.cnblogs.com/xtark/ 】 本文介紹X-CTR100控制器與樹莓派Linux系統組成機器人平臺。首先介紹與樹莓派串口通信,後介紹機器人平臺搭建。這種上下位機平臺架構常用於機器人RO... ...
  • 一、環境準備 系統:centos7 and centos6.8 172.16.1.11 二、開始安裝 安裝yum源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 安裝epe ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...