php擴展模塊安裝


一、安裝PHP(版本大於等於5.6):

1.安裝PHP的依賴包

准備包(依賴包可選擇yum或者源碼方式安裝。):

yum -yinstall gcc gcc-c++ make autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers patch perl-CPAN pcre-devel pcre libxslt libxslt-devel php-mcrypt  libmcrypt libmcrypt-devel mcrypt* mhash

源碼包:

php下載:http://php.net/downloads.php

1.2.安裝

tar -xf php-5.6.38.tar

cd php-5.6.38

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath  --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

 

make && make install

 

cp php.ini-development /usr/local/php/etc/php.ini


2.
安裝nginx

2.1下載安裝包

wget http://nginx.org/download/nginx-1.6.3.tar.gz

 

2.2.手動編譯安裝nginx

tar -zxf nginx-1.6.3.tar.gz

cd nginx-1.6.3

./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.6.3 --with-http_ssl_module --with-http_stub_status_module

 

make && make install

 

2.3.創建一個軟鏈接

cd /usr/local/

ln -s nginx-1.6.3 nginx

 

2.4.修改PATH變量

echo "export PATH=$PATH:/usr/local/nginx/sbin/:/usr/local/php/bin">>/etc/profile

source /etc/profile

 

2.5.nginx配置文件nginx.conf

user  www www;

 

worker_processes auto;

 

error_log  /data/logs/nginx/error.log  crit;

 

pid        /usr/local/nginx/logs/nginx.pid;

 

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 51200;

 

events

    {

        use epoll;

        worker_connections 51200;

        multi_accept on;

    }

 

http

    {

        include       mime.types;

        default_type  application/octet-stream;

 

        server_names_hash_bucket_size 128;

        client_header_buffer_size 32k;

        large_client_header_buffers 4 32k;

        client_max_body_size 50m;

 

        sendfile   on;

        tcp_nopush on;

 

        keepalive_timeout 60;

 

        tcp_nodelay on;

 

        fastcgi_connect_timeout 300;

        fastcgi_send_timeout 300;

        fastcgi_read_timeout 300;

        fastcgi_buffer_size 64k;

        fastcgi_buffers 4 64k;

        fastcgi_busy_buffers_size 128k;

        fastcgi_temp_file_write_size 256k;

 

        gzip on;

        gzip_min_length  1k;

        gzip_buffers     4 16k;

        gzip_http_version 1.1;

        gzip_comp_level 2;

        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;

        gzip_vary on;

        gzip_proxied   expired no-cache no-store private auth;

        gzip_disable   "MSIE [1-6]\.";

 

        #limit_conn_zone $binary_remote_addr zone=perip:10m;

        ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

 

        server_tokens off;

        access_log off;

 

        log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '

                            '$status $body_bytes_sent "$http_referer" '

                            '"$http_user_agent" $http_x_forwarded_for "$request_time"';

 

        include vhost/*.conf;

}

 

3.PHP: memcached

3.1.安裝SASL

檢測是否有已安裝了 SASL 相關環境包,如沒有,則執行 yum install cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib 安裝 SASL 相關環境。

3.2.安裝libmemcached

檢測下是否有已安裝了 libmemcached 源碼包,若沒有,則執行以下命令安裝 libmemcached 源碼包(推薦版本 libmemcached-1.0.18)。

wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz

tar zxvf libmemcached-1.0.18.tar.gz

cd libmemcached-1.0.18

./configure --prefix=/usr/local/libmemcached --enable-sasl

make

make install

cd ..

 

3.3.安裝memcached

wget http://pecl.php.net/get/memcached-2.2.0.tgz

tar zxvf memcached-2.2.0.tgz

cd memcached-2.2.0

phpize(如果系統中有兩套PHP環境,需絕對路徑調用該命令/usr/bin/phpize,該路徑為使用雲數據庫MemcachePHP環境路徑)

./configure --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl(注意這個參數)

make

make install

3.4.修改php配置

將上面紅色框部分拷貝到制定目錄

cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/*.so /usr/local/php/lib/php/extensions/

vim /usr/local/php/etc/php.ini

 

# 添加以下配置

[Memcached]

 extension=memcached.so

重啟php

php -m檢查是否加載了memcached

 

4.PHP:Mongodb

第一步:下載MongoDB安裝包

wget  http://pecl.php.net/get/mongo-1.6.16.tgz

具體版本可以到http://pecl.php.net/package/mongo這個網站查找

tar -zxf mongo-1.6.16.tgz

4.1.進入解壓目錄,運行phpize進行安裝准備

cd mongo-1.6.6

/usr/local/php/bin/phpize

 

4.2.安裝編譯

上述命令運行完后,在目錄下就生成了configure文件

使用./configure命令進行安裝配置,然后使用make && make install進行編譯安裝,命令如下:

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

 

4.3.編輯php.ini增加下述一行添加mongodb擴展

extension=mongo.so

重啟web容器,然后查看phpinfo,看到mongodb的內容就說明安裝成功。

 

 

 

1.下載phpredis3.1.2

  wget  https://github.com/phpredis/phpredis/archive/3.1.2.tar.gz

2.解壓后在phpredis3.1.2目錄下執行

  tar -zxf 3.1.2.tar.gz

3.執行configure

  cd phpredis-3.1.2/

    phpize

    ./configure --with-php-config=/usr/local/php/bin/php-config

4.安裝

  make && make install

默認情形下將會在/usr/local/php/lib/php/extensions/debug-non-zts-20131226/目錄下生成redis.so文件

將其拷貝到/usr/local/php/lib/php/extensions/

cp /usr/local/php/lib/php/extensions/debug-non-zts-20131226/*.so /usr/local/php/lib/php/extensions/

5.配置php.ini,在其最后加入

[Redis]

extensions=redis.so

6.重啟php 服務

7.檢查redis模塊是否加載了

php -m |grep redis

ts

 

make && make install

 

cp php.ini-development /usr/local/php/etc/php.ini


2.
安裝nginx

2.1下載安裝包

wget http://nginx.org/download/nginx-1.6.3.tar.gz

 

2.2.手動編譯安裝nginx

tar -zxf nginx-1.6.3.tar.gz

cd nginx-1.6.3

./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.6.3 --with-http_ssl_module --with-http_stub_status_module

 

make && make install

 

2.3.創建一個軟鏈接

cd /usr/local/

ln -s nginx-1.6.3 nginx

 

2.4.修改PATH變量

echo "export PATH=$PATH:/usr/local/nginx/sbin/:/usr/local/php/bin">>/etc/profile

source /etc/profile

 

2.5.nginx配置文件

nginx.conf

user  www www;

 

worker_processes auto;

 

error_log  /data/logs/nginx/error.log  crit;

 

pid        /usr/local/nginx/logs/nginx.pid;

 

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 51200;

 

events

    {

        use epoll;

        worker_connections 51200;

        multi_accept on;

    }

 

http

    {

        include       mime.types;

        default_type  application/octet-stream;

 

        server_names_hash_bucket_size 128;

        client_header_buffer_size 32k;

        large_client_header_buffers 4 32k;

        client_max_body_size 50m;

 

        sendfile   on;

        tcp_nopush on;

 

        keepalive_timeout 60;

 

        tcp_nodelay on;

 

        fastcgi_connect_timeout 300;

        fastcgi_send_timeout 300;

        fastcgi_read_timeout 300;

        fastcgi_buffer_size 64k;

        fastcgi_buffers 4 64k;

        fastcgi_busy_buffers_size 128k;

        fastcgi_temp_file_write_size 256k;

 

        gzip on;

        gzip_min_length  1k;

        gzip_buffers     4 16k;

        gzip_http_version 1.1;

        gzip_comp_level 2;

        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;

        gzip_vary on;

        gzip_proxied   expired no-cache no-store private auth;

        gzip_disable   "MSIE [1-6]\.";

 

        #limit_conn_zone $binary_remote_addr zone=perip:10m;

        ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

 

        server_tokens off;

        access_log off;

 

        log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '

                            '$status $body_bytes_sent "$http_referer" '

                            '"$http_user_agent" $http_x_forwarded_for "$request_time"';

 

        include vhost/*.conf;

}

 

3.PHP: memcached

3.1.安裝SASL

檢測是否有已安裝了 SASL 相關環境包,如沒有,則執行 yum install cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib 安裝 SASL 相關環境。

3.2.安裝libmemcached

檢測下是否有已安裝了 libmemcached 源碼包,若沒有,則執行以下命令安裝 libmemcached 源碼包(推薦版本 libmemcached-1.0.18)。

wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz

tar zxvf libmemcached-1.0.18.tar.gz

cd libmemcached-1.0.18

./configure --prefix=/usr/local/libmemcached --enable-sasl

make

make install

cd ..

 

3.3.安裝memcached

wget http://pecl.php.net/get/memcached-2.2.0.tgz

tar zxvf memcached-2.2.0.tgz

cd memcached-2.2.0

phpize(如果系統中有兩套PHP環境,需絕對路徑調用該命令/usr/bin/phpize,該路徑為使用雲數據庫MemcachePHP環境路徑)

./configure --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl(注意這個參數)

make

make install

3.4.修改php配置

將上面紅色框部分拷貝到制定目錄

cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/*.so /usr/local/php/lib/php/extensions/

vim /usr/local/php/etc/php.ini

 

# 添加以下配置

[Memcached]

 extension=memcached.so

重啟php

php -m檢查是否加載了memcached

 

4.PHP:Mongodb

第一步:下載MongoDB安裝包

wget  http://pecl.php.net/get/mongo-1.6.16.tgz

具體版本可以到http://pecl.php.net/package/mongo這個網站查找

tar -zxf mongo-1.6.16.tgz

4.1.進入解壓目錄,運行phpize進行安裝准備

cd mongo-1.6.6

/usr/local/php/bin/phpize

 

4.2.安裝編譯

上述命令運行完后,在目錄下就生成了configure文件

使用./configure命令進行安裝配置,然后使用make && make install進行編譯安裝,命令如下:

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

 

4.3.編輯php.ini增加下述一行添加mongodb擴展

extension=mongo.so

重啟web容器,然后查看phpinfo,看到mongodb的內容就說明安裝成功。

 

 

 

1.下載phpredis3.1.2

  wget  https://github.com/phpredis/phpredis/archive/3.1.2.tar.gz

2.解壓后在phpredis3.1.2目錄下執行

  tar -zxf 3.1.2.tar.gz

3.執行configure

  cd phpredis-3.1.2/

    phpize

    ./configure --with-php-config=/usr/local/php/bin/php-config

4.安裝

  make && make install

默認情形下將會在/usr/local/php/lib/php/extensions/debug-non-zts-20131226/目錄下生成redis.so文件

將其拷貝到/usr/local/php/lib/php/extensions/

cp /usr/local/php/lib/php/extensions/debug-non-zts-20131226/*.so /usr/local/php/lib/php/extensions/

5.配置php.ini,在其最后加入

[Redis]

extensions=redis.so

6.重啟php 服務

7.檢查redis模塊是否加載了

php -m |grep redis


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM