【转】phpize学习
為什么使用phpize?
比如剛開始安裝的時候使用
./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --disable-fileinfo
哪天需要使用新的擴展了,就需要重新安裝了,但是如果重新編譯整個源碼,就太費事了;phpize就是解決整個問題的
首先進到/home/jack/php-7.0.6/ext源碼的擴展目錄
然后執(zhí)行:
cd standard
./configure
make
make install?
?
Compiling shared PECL extensions with phpize
Sometimes, using the pecl installer is not an option. This could be because you're behind a firewall, or it could be because the extension you want to install is not available as a PECL compatible package, such as unreleased extensions from SVN. If you need to build such an extension, you can use the lower-level build tools to perform the build manually.
The phpize command is used to prepare the build environment for a PHP extension. In the following sample, the sources for an extension are in a directory named extname:
$ cd extname? 進入到源碼包中的擴展目錄(就是你下載的php的源碼包/home/jack/php-7.0.6/ext),這個擴展目錄,通俗理解,如果要安裝操作gd庫,那么下載到這個庫的源碼后,解壓源碼會有個一個目錄,進入這個目錄。
$ phpize? 運行phpize。路徑不一定在這個目錄下,但一般是在安裝目錄下(按照我理解,每個phpize與具體的版本有關,不可能通用),去尋找phpize運行。之后會生成了一個configure文件
$ ./configure???? 運行。??? 如果生成基于數(shù)據(jù)庫的擴展,需要加上參數(shù)運行:1,--with-php-config。2,"--with-具體的數(shù)據(jù)庫參數(shù)".比如, --with-pgsql、--with-mysql
$ make
# make install 將會生成一個extname.so的擴展,被放到了PHP extensions directory
?
A successful install will have created extname.so and put it into the PHP extensions directory(生成一個.so文件,自動放到php的擴展目錄下去,我覺得應該是phpize能夠自動偵測到php擴展目錄的位置).
You'll need to and adjust php.ini and add an extension=extname.so line before you can use the extension.
If the system is missing the phpize command, and precompiled packages (like RPM's) are used, be sure to also install the appropriate devel version of the PHP package as they often include the phpize command along with the appropriate header files to build PHP and its extensions.
Execute phpize --help to display additional usage information.
phpize的作用可以這樣理解:偵測環(huán)境(phpize工具是在php安裝目錄下,基于這點phpize對應了當時的php環(huán)境,所以是要根據(jù)該php的配置情況生成對應的configure文件),建立一個configure文件。必須在一個目錄下去運行phpize。那么phpize就知道你的的環(huán)境是哪個目錄,并且configure文件建立在該目錄下。
步驟總結:
一、cd /usr/src/php源碼包目錄/ext/擴展目錄/??
二、/usr/local/php5314/bin/phpize
三、./configure --with-php-config=/usr/local/php5314/bin/php-config
四、make && make install
?
ps:make install會自動將生成的.so擴展復制到php的擴展目錄下去,比如會提示已經安裝到?/usr/local/php/php-5.5.18/lib/php/extensions/no-debug-non-zts-20121212/目錄下去
五、剩下是配置php.ini
?
假如你的服務器上安裝了多個版本php,那么需要告訴phpize要建立基于哪個版本的擴展。通過使用--with-php-config=指定你使用哪個php版本。
比如:--with-php-config=/usr/local/php524/bin/php-config??
關于php-config文件:是在php編譯生成后(安裝好),放在安裝目錄下的一個文件。打開phpize文件內容會發(fā)現(xiàn),里面定義好了php的安裝目錄等變量
prefix='/usr/local/php'
phpize是編譯安裝時候生成好的,記錄了當時安裝的一些信息。并不能從其他地方拿個phpize來使用。
?phpize是在php安裝目錄下的一個文件。比如我安裝了兩個php5.2 和php5.3那么使用phpize也要使用對應版本的phpize才行。此時使用--with-php-config有什么作用?
?
phpize工具一般在哪里?
當php編譯完成后,php安裝目錄下的bin目錄下會有phpize這個腳本文件。所以是去安裝好的php安裝目錄去找。
?
轉載于:https://www.cnblogs.com/maxomnis/p/5452996.html
總結
以上是生活随笔為你收集整理的【转】phpize学习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用 SqlDataSource 插入、
- 下一篇: 叫化鸡是哪里的特色