11.32 php擴展模塊安裝php
擴展html
apache rewrite教程 mysql
http://coffeelet.blog.163.com/blog/static/13515745320115842755199/ linux
http://www.cnblogs.com/top5/archive/2009/08/12/1544098.htmlgit
apache rewrite 出現死循環 github
http://ask.apelearn.com/question/1043redis
php錯誤日誌級別參考 sql
http://ask.apelearn.com/question/6973apache
php開啓短標籤 json
http://ask.apelearn.com/question/120
php.ini詳解
http://legolas.blog.51cto.com/2682485/493917
~~1.
PHP動態擴展模塊(PHP源碼包裏ext下沒有須要的模塊的狀況下的安裝方法)
/usr/local/src/php-7.1.6/ext/
例如咱們php已經安裝好了,可是發現少了一個模塊。可是又不能重新編譯php,那麼能夠用下面這種方式(實際上就是編譯出一個.so的文件):
/usr/local/php/bin/php -m //查看模塊
[PHP Modules] bz2 Core ctype date dom ereg exif fileinfo filter gd hash iconv json libxml mbstring mcrypt mysql mysqli openssl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session SimpleXML soap sockets SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib [Zend Modules]
下面安裝一個redis的模塊 在lamp架構下,一般當作一個緩存來用
cd /usr/local/src/
wget https://codeload.github.com/phpredis/phpredis/zip/develop
mv develop phpredis-develop.zip
unzip phpredis-develop.zip
cd phpredis-develop
/usr/local/php/bin/phpize 生成configure文件(此處需生成一個configure模塊),注意輸出是否報錯
./configure --with-php-config=/usr/local/php/bin/php-config 通常只須要加--with就能夠了
make && make install
/usr/local/php/bin/php -i |grep extension_dir 查看擴展模塊存放目錄,咱們能夠在php.ini中去自定義該路徑,但針對這樣擴展的模塊,咱們不用去改他的路徑,默認就好
vim /usr/local/php/etc/php.ini 增長一行配置(能夠放到文件最後一行)
extension=redis.so
~~2.
假如在PHP源碼包裏ext下有須要的模塊的狀況下的安裝方法
(/usr/local/src/php-7.1.6/ext/)
cd /usr/local/src/php-7.1.6/ext/
cd zip cd到須要安裝的這個模塊目錄下
/usr/local/php7/bin/phpize 直接執行,生成.configure
./configure --with-php-config=/usr/local/php7/bin/php-config
make&&make install
實例:
~~1.
[root@axinlinux-01 ~]# /usr/local/php/bin/php -m
[PHP Modules]
[root@axinlinux-01 ~]# cd /usr/local/src
[root@axinlinux-01 src]# wget https://codeload.github.com/phpredis/phpredis/zip/develop
[root@axinlinux-01 src]# du -sh develop
236K develop
[root@axinlinux-01 src]# mv develop phpredis-develop.zip
[root@axinlinux-01 src]# unzip phpredis-develop.zip
[root@axinlinux-01 src]# cd phpredis-develop/
[root@axinlinux-01 phpredis-develop]# ls 要生成一個.configure的文件,才能編譯
arrays.markdown cluster.markdown COPYING debian.control library.c package.xml redis_array.h redis_cluster.c redis_session.c tests Changelog.md common.h crc16.h INSTALL.markdown library.h php_redis.h redis_array_impl.c redis_cluster.h redis_session.h cluster_library.c config.m4 CREDITS ISSUE_TEMPLATE.md mkdeb-apache2.sh README.markdown redis_array_impl.h redis_commands.c rpm cluster_library.h config.w32 debian liblzf mkdeb.sh redis_array.c redis.c redis_commands.h serialize.list
[root@axinlinux-01 phpredis-develop]# /usr/local/php7/bin/phpize 該命令生成.configure
Configuring for: PHP Api Version: 20160303 Zend Module Api No: 20160303 Zend Extension Api No: 320160303
Cannot find autoconf. Please check your autoconf installation and the 有報錯(少autoconf包)
$PHP_AUTOCONF environment variable. Then, rerun this script.
[root@axinlinux-01 phpredis-develop]# yum install -y autoconf
[root@axinlinux-01 phpredis-develop]# /usr/local/php7/bin/phpize 從新生成
Configuring for: PHP Api Version: 20160303 Zend Module Api No: 20160303 Zend Extension Api No: 320160303 這樣的輸出纔是正常
[root@axinlinux-01 phpredis-develop]# ls 會看到configure這個文件
acinclude.m4 Changelog.md config.guess configure.in debian liblzf missing php_redis.h redis_array_impl.h redis_commands.h serialize.list aclocal.m4 cluster_library.c config.h.in config.w32 debian.control library.c mkdeb-apache2.sh README.markdown redis.c redis_session.c tests arrays.markdown cluster_library.h config.m4 COPYING INSTALL.markdown library.h mkdeb.sh redis_array.c redis_cluster.c redis_session.h autom4te.cache cluster.markdown config.sub crc16.h install-sh ltmain.sh mkinstalldirs redis_array.h redis_cluster.h rpm build common.h configure CREDITS ISSUE_TEMPLATE.md Makefile.global package.xml redis_array_impl.c redis_commands.c run-tests.php
[root@axinlinux-01 phpredis-develop]# ./configure --with-php-config=/usr/local/php7/bin/php-config
[root@axinlinux-01 phpredis-develop]# echo $?
0
[root@axinlinux-01 phpredis-develop]# make
[root@axinlinux-01 phpredis-develop]# make install
Installing shared extensions: /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/
這個路徑就是咱們要的.so的文件
[root@axinlinux-01 phpredis-develop]# ls /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/
opcache.so redis.so
[root@axinlinux-01 phpredis-develop]# /usr/local/php7/bin/php -m 並無這個模塊,說明如今php還不支持他
[PHP Modules] bz2 Core ctype date dom exif fileinfo filter gd hash iconv json libxml mbstring mcrypt mysqli openssl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session SimpleXML soap sockets SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib [Zend Modules]
[root@axinlinux-01 phpredis-develop]# /usr/local/php7/bin/php -i | grep -i extension_dir 查看一下,不用改
extension_dir => /usr/local/php7/lib/php/extensions/no-debug-zts-20160303 => /usr/local/php7/lib/php/extensions/no-debug-zts-20160303 sqlite3.extension_dir => no value => no value
[root@axinlinux-01 phpredis-develop]# vim /usr/local/php7/etc/php.ini
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll 搜索extension,在一長串extension的最下面加上extension=redis.so
[root@axinlinux-01 phpredis-develop]# /usr/local/php7/bin/php -m |grep redis
redis 這時候就有了
[PHP Modules] bz2 Core ctype date dom exif fileinfo filter gd hash iconv json libxml mbstring mcrypt mysqli openssl pcre PDO pdo_mysql pdo_sqlite Phar posix redis Reflection session SimpleXML soap sockets SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib [Zend Modules]
~~2.
[root@axinlinux-01 php7]# cd /usr/local/src/php-7.1.6/ext/
[root@axinlinux-01 ext]# ls
bcmath curl exif ftp iconv ldap mysqlnd pcntl pdo_mysql pgsql recode skeleton sqlite3 tidy xmlrpc bz2 date ext_skel gd imap libxml oci8 pcre pdo_oci phar reflection snmp standard tokenizer xmlwriter calendar dba ext_skel_win32.php gettext interbase mbstring odbc pdo pdo_odbc posix session soap sysvmsg wddx xsl com_dotnet dom fileinfo gmp intl mcrypt opcache pdo_dblib pdo_pgsql pspell shmop sockets sysvsem xml zip ctype enchant filter hash json mysqli openssl pdo_firebird pdo_sqlite readline simplexml spl sysvshm xmlreader zlib
以上是php源碼包裏自帶的可用的模塊,咱們須要的這裏有的話,就可直接安裝
[root@axinlinux-01 ext]# /usr/local/php7/bin/php -m |grep zip 假如咱們編譯zip
[root@axinlinux-01 ext]# cd zip 首先cd到這個zip目錄下來
[root@axinlinux-01 zip]# ls
config.m4 config.w32 CREDITS examples lib LICENSE_libzip php_zip.c php_zip.h tests TODO zip_stream.c
[root@axinlinux-01 zip]# /usr/local/php7/bin/phpize 直接執行,生成.configure
Configuring for: PHP Api Version: 20160303 Zend Module Api No: 20160303 Zend Extension Api No: 320160303
[root@axinlinux-01 zip]# ./configure --with-php-config=/usr/local/php7/bin/php-config
[root@axinlinux-01 zip]# echo $?
0
[root@axinlinux-01 zip]# make
[root@axinlinux-01 zip]# echo $?
0
[root@axinlinux-01 zip]# make install
Installing shared extensions: /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/
[root@axinlinux-01 zip]# echo $?
0
[root@axinlinux-01 zip]# ls /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/
opcache.so redis.so zip.so