Home php教程 php手册 debian下安装php的一些扩展geoip,mongo,redis,libevent,proctitl

debian下安装php的一些扩展geoip,mongo,redis,libevent,proctitl

Jun 06, 2016 pm 07:58 PM
debian geoip php Install Expand

因为项目的关系,需要安装一些新的扩展 debian xfce 7.2 x64 下面3个都是通过apt-get安装的。 PHP 5.4.4-14deb7u5 (cli) nginx1.2.1 apache 2.2.22 1: 通过默认的方法安装(最优),大部分常用的都在debian的仓库里面,可以下载到注意,#是代表root 可通过su -

因为项目的关系,需要安装一些新的扩展

debian xfce 7.2 x64   下面3个都是通过apt-get安装的。

PHP 5.4.4-14+deb7u5 (cli)

nginx1.2.1

apache 2.2.22

1: 通过默认的方法安装(最优),大部分常用的都在debian的仓库里面,可以下载到  注意,#是代表root 可通过su - 输入密码后进入root

#apt-get install php5-geoip
#apt-get install php-apc
#apt-get install libevent-dev
Copy after login

2:通过pecl 安装(其次)
#pecl install mongo
#pecl install channel://pecl.php.net/libevent-0.1.0
#pecl install channel://pecl.php.net/proctitle-0.1.2
#pecl install inotify
#pecl install yaf
Copy after login


pecl 安装完后,需要做几个事情,一个是把 对应的so文件加到对应的ini,其次是把ini链接到conf.d

比如上面的3个扩展,pecl后 

在debian的

/usr/lib/php5/20100525/mongo.so
/usr/lib/php5/20100525/libevent.so
/usr/lib/php5/20100525/proctitle.so
/usr/lib/php5/20100525/inotify.so
/usr/lib/php5/20100525/yaf.so
Copy after login

Copy after login
Copy after login

php5在/etc/php5 执行下面的shell命名,这是建立一些配置文件,debian的php的php.ini 把配置文件分散到了/etc/php5/conf.d, 而conf.d 的内容都来自/etc/php5/mods-available/ 为了debian包的严谨,我们这里就作两次链接,而不是直接去conf.d 建对应的.ini 文件.

#echo "extension=mongo.so" > /etc/php5/mods-available/mongo.ini
#echo "extension=libevent.so" > /etc/php5/mods-available/libevent.ini
#echo "extension=proctitle.so" > /etc/php5/mods-available/proctitle.ini
#echo "extension=inotify.so" > /etc/php5/mods-available/inotify.ini
#echo "extension=yaf.so" > /etc/php5/mods-available/yaf.ini
#ln -s /etc/php5/mods-available/mongo.ini /etc/php5/conf.d/mongo.ini
#ln -s /etc/php5/mods-available/libevent.ini /etc/php5/conf.d/libevent.ini
#ln -s /etc/php5/mods-available/proctitle.ini /etc/php5/conf.d/proctitle.ini
#ln -s /etc/php5/mods-available/inotify.ini /etc/php5/conf.d/inotify.ini
#ln -s /etc/php5/mods-available/yaf.ini /etc/php5/conf.d/yaf.ini
Copy after login
Copy after login
Copy after login
重启下nginx的php5-fcgi or apache,可以看到这些模块已经加载成功

3:通过扩展的源码安装(编译安装,对于debian不是很推荐,前提是仓库没有) 安装的是php-redis 扩展

(redis server需要你自己安,编译的环境这些软件参考我前面的文章安装就行了,gcc之类的

#wget https://redis.googlecode.com/files/redis-2.6.14.tar.gz
#tar -zxvf redis
#make
Copy after login

#tar -zxvf nicolasff-phpredis-2.1.3-124-gd4ad907.tar.gz
#cd nicolasff-phpredis-00233a3
#phpize
#./configure --with-php-config=/usr/bin/php-config
Copy after login
#make && make install
#echo "extension=redis.so" > /etc/php5/mods-available/redis.ini
#ln -s /etc/php5/mods-available/redis.ini /etc/php5/conf.d/redis.ini
Copy after login

同上,需要重启server


4:通过php源码安装(开关某些php默认安装了但是关闭的扩展,这里我们要开启的是pcntl)

#mkdir php
#cd php
#apt-get source php5
Copy after login

  这里我们进去 php5-(版本号)/ext/pcntl 
#cd php5-5.4.4/ext/pcntl
#phpize
#./configure
#make && make install
#echo "extension=pcntl.so" > /etc/php5/mods-available/pcntl.ini
#ln -s /etc/php5/mods-available/pcntl.ini /etc/php5/conf.d/pcntl.ini
Copy after login

同上,重启server就可以了
如果php报错,PHP Warning: Module ‘pcntl’ already loaded in Unknown on line 0
那就说明已经装上了,现在是重复装的,需要把上面添加的两个pcntl.ini文件删除掉。 然后去把php.ini 文件里面的
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,

加  ; 注释掉。重启server就可以了, 注意,php.ini 在apache2,nginx里面都不同的, apache2的在/etc/php5/apache2/php.ini  nginx我指定的是cgi里面的/etc/php5/cgi/php.ini 
看你server用的哪个,就去注释掉哪个就可以了




5. 通过git clone来安装uv(需要你有git环境)



#git clone https://github.com/chobie/php-uv.git --recursive
#cd php-uv
#cd libuv && make
#cd ..
#phpize
#./configure
Copy after login

如果phpize报错说找不到config.m4 说明你用的是64位的, 需要执行下面的几个步骤

#make clean 
#cd ./libuv
#make clean
Copy after login

然后修改下php-uv/libuv/Makefile 

#vim Makefile
Copy after login

大概是改27行的位置, 加上-fPIC

ifdef MSVC
uname_S := MINGW
endif

CPPFLAGS += -Iinclude -Iinclude/uv-private -fPIC

CARES_OBJS =
CARES_OBJS += src/ares/ares__close_sockets.o
Copy after login
重新执行前面的
#make
#cd ..
#phpize
#./configure
#make && make install 
Copy after login

即可, 然后就

#echo "extension=uv.so" > /etc/php5/mods-available/uv.ini
#ln -s /etc/php5/mods-available/uv.ini /etc/php5/conf.d/uv.ini
Copy after login

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 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 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles