mac php安装mysql扩展_(MAC) PHP扩展安装
前言
每個人的安裝環(huán)境不同,具體安裝依個人而異!
1、安裝之前先查看php.ini的位置,然后將擴展寫入配置文件。
php -i | grep php.ini
# php --ini
# Loaded Configuration File => /usr/local/lib/php.ini
sudo cp /etc/php.ini.default /usr/local/lib/php.ini
2、修改.bash_profile,增加如下幾行,這樣就可以方便使用php、phpize、php-config命令了!
PATH=/usr/local/bin:$PATH
3、查找擴展的資源包
(1)pecl.php.net/
(2)github
PHP安裝擴展方法
查看php.ini默認的擴展和編譯安裝時啟動的配置項是對應的。如果需要啟動某個擴展可以嘗試以下方案:
(1)編譯安裝PHP的時候啟動配置項,前提是配置項支持!
(2)下載對應擴展的資源包然后自己編譯安裝
(3)找到原安裝PHP的資源目錄,然后cd到ext及對應的擴展下編譯安裝。舉例:
# 進入PHP-7.1版本的資源目錄及擴展curl
cd /usr/local/opt/php-src/ext/curl
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
更多等待記錄…
igbinary
wget http://pecl.php.net/get/igbinary-3.1.5.tgz
tar zxvf igbinary-3.1.5.tgz
cd ~/opt/igbinary-3.1.5
sudo phpize --clean && sudo make clean
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
curl
wget https://curl.haxx.se/download/curl-7.72.0.tar.gz
tar -zxvf curl-7.72.0.tar.gz && cd curl-7.72.0
./configure && sudo make && sudo make install
cd /usr/local/opt/php-src/ext/curl
phpize --with-curl=/usr/local/opt/curl
./configure --with-php-config=php-config
sudo make && sudo make install
sockets
cd /usr/local/opt/php-src/ext/sockets
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
tidy
exif
fileinfo
ftp
zip
Redis
git clone git://github.com/phpredis/phpredis.git
#git checkout xxx # 可以自己查看該資源的分支
cd ~/opt/phpredis/
phpize
./configure --with-php-config=php-config --enable-redis-igbinary
sudo make && sudo make install
Memcache
git clone git://github.com/websupport-sk/pecl-memcache
cd ~/opt/pecl-memcache
phpize
./configure --with-php-config=php-config --with-zlib-dir=/usr/local/opt/zlib
sudo make && sudo make install
Memcached
# wget http://download.tangent.org/libmemcached-1.0.18.tar.gz
# sudo tar -zxvf libmemcached-1.0.18.tar.gz
# cd libmemcached-1.0.18 && sudo ./configure && sudo make && sudo make install
git clone https://github.com/php-memcached-dev/php-memcached.git
# git clone git://github.com/php-memcached-dev/php-memcached.git
cd ~/opt/php-memcached
phpize
sudo ./configure --with-php-config=/usr/local/bin/php-config --enable-memcached --with-libmemcached-dir=/usr/local --disable-memcached-sasl --enable-memcached-igbinary
sudo make && sudo make install
configure: error: Please reinstall the pkg-config distribution
wget pkgconfig.freedesktop.org/releases/...
swoole
# git clone git://github.com/swoole/swoole-src.git
wget https://github.com/swoole/swoole-src/archive/v4.5.3.tar.gz
tar -zxvf v4.5.3.tar.gz && cd swoole-src-4.5.3
# sudo make clean && phpize --clean
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
yar
安裝依賴:Curl、Json、Msgpack (Optional)
git clone https://github.com/laruence/yar.git
cd ~/opt/yar
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
mbstring
cd /usr/local/opt/php-src/ext/mbstring
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
PDO
先配置pdo.so,在配置pdo_mysql.so。
cd /usr/local/opt/php-src/ext/pdo
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
event
依賴擴展:socket
wget https://pecl.php.net/get/event-2.5.7.tgz
tar -zxvf event-2.5.7.tgz
cd ~/opt/event-2.5.7
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
mysqlnd
cd /usr/local/opt/php-src/ext/mysqlnd
sudo mv config9.m4 config.m4
phpize
export PHP_OPENSSL_DIR=yes
./configure --with-php-config=php-config
sudo make && sudo make install
mysqli
cd /usr/local/opt/php-src/ext/mysqli
phpize
./configure --with-php-config=php-config --with-mysqli=/usr/bin/mysql_config
sudo make && sudo make install
pdo_mysql
cd /usr/local/opt/php-src/ext/pdo_mysql
phpize clean && make clean
phpize
./configure --with-php-config=php-config --with-pdo-mysql=/usr/local/mysql
sudo make && sudo make install
zlib
cd /usr/local/opt/php-src/ext/zlib
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
gd
cd /usr/local/opt/php-src/ext/gd
phpize
./configure --with-php-config=php-config --with-zlib-dir=/usr/local/opt/zlib --with-jpeg-dir=/usr/local/opt/jpeg --with-webp-dir=/usr/local/opt/webp
sudo make && sudo make install
# 開發(fā)機搭建
# ./configure --with-freetype-dir=/usr/include/freetype2 --with-jpeg-dir=/usr/include
openssl
cd /usr/local/opt/php-src/ext/openssl
mv config0.m4 config.m4
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
crypto
wget https://pecl.php.net/get/crypto-0.3.1.tgz && tar -zxvf crypto-0.3.1.tgz
cd crypto-0.3.1
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
pcntl
cd /usr/local/opt/php-src/ext/pcntl
sudo phpize --clean && sudo make clean
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
php-fpm
cd /usr/local/opt/php-src/sapi/fpm/
phpize
./configure --with-php-config=php-config
寫個shell腳本吧
這里是一個一個的粘貼進來,也可以定義一個關聯(lián)數組。但是嘗試了下shell的關聯(lián)數組以字符串為下標獲取不到預期的值。先繞過去再說吧,有空再弄。
#!/bin/sh
#igbinary
cd ~/opt/igbinary-3.1.5
sudo phpize --clean && sudo make clean
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
# curl
cd /usr/local/opt/php-src/ext/curl
sudo phpize --clean && sudo make clean
phpize
./configure --with-php-config=php-config
sudo make && sudo make install
# ...
本作品采用《CC 協(xié)議》,轉載必須注明作者和本文鏈接
總結
以上是生活随笔為你收集整理的mac php安装mysql扩展_(MAC) PHP扩展安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux tomcat连接mysql步
- 下一篇: mybatis mysql自动连接数据库