Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18. [笔记] Linux 重装 PHP #19

Open
ccforward opened this issue Jul 27, 2015 · 0 comments
Open

18. [笔记] Linux 重装 PHP #19

ccforward opened this issue Jul 27, 2015 · 0 comments
Assignees

Comments

@ccforward
Copy link
Owner

起因

服务器上本来有多个版本的PHP,因为误操作把一个老版本的PHP给误删,只好重装。

因为好久没装过环境了,有些生疏,所以把编译安装过程简单记下来

安装环境

因为历史原因,一些老的服务必须依赖 PHP-5.3.27 所以以此版本为例

编译PHP

  1. 解压 tar -zxvf php-5.3.27.tar.gz
  2. 配置,下面是一个生产环境的php配置
./configure --prefix=/usr/local/php-5.3.27 \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--enable-xml \
--enable-pdo \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-mcrypt \
--with-curlwrappers \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-pear \
--with-bz2 \
  1. make

  2. make install

  3. 复制配置文件 php.ini

    cp php.ini-development  /usr/local/php-5.3.27/lib/php.ini
    

    PS: 这个版本的 php.ini 文件要放在bin目录下,之前一直按照 php5.6 放在etc目录下,导致出现各种问题,看了 ./php -i | grep ini 后才发现

    Configuration File (php.ini) Path => /usr/local/php-5.3.27/lib
    
  4. 配置 php-fpm
    因为用了 nginx 做为服务器,所以用 php-fpm 做个 FastCGI 管理器

    1. 进入 etc 目录 cp php-fpm.conf.default php-fpm.conf
    2. 开启 pid = run/php-fpm.pid
    3. 配置 php-fpm.conf user=www group=wwwlisten = 127.0.0.1:9527
      端口要根据 nginx 的 vhost 配置文件来做具体修改
    4. 配置 php-fpm 启动脚本
      复制之前的 cp /etc/init.d/php-fpm /etc/init.d/php-fpm5327
      附一个脚本源码 php-fpm
      启动 fpm ./php-fpm5327 start

安装 memcached 扩展

是 memcached 不是 memcache

安装libmemcached

  1. wget http://launchpad.net/libmemcached/1.0/0.42/+download/libmemcached-0.42.tar.gz
  2. tar -zxvf libmemcached-0.42.tar.gz
  3. cd libmemcached-0.42
    ./configure --prefix=/usr/local/libmemcached --with-memcached
    make && make install

安装 memcached 扩展

  1. 下载 解压 不再多写
  2. /usr/local/php-5.3.27/bin/phpize
  3. ./configure --with-php-config=/usr/local/php-5.3.27/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached
  4. make && make install

安装 php mongo 扩展

  1. /usr/local/php-5.3.27/bin/phpize
  2. ./configure --with-php-config=/usr/local/php-5.3.27/bin/php-config
  3. make && make install

安装 mysql_pdo

  1. ./usr/local/php-5.3.27/bin/phpize
  2. ./configure -with-php-config=/usr/local/php-5.3.27/bin/php-config -with-pdo-mysql=/usr/local/mysql
  3. make && make install

根据需要安装完各种扩展后 重启 fpm 即可:
/etc/init.d/php-fpm5327 restart

@ccforward ccforward self-assigned this Jul 27, 2015
@ccforward ccforward changed the title 18. [笔记] LInux 重装 PHP 18. [笔记] Linux 重装 PHP Jul 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant