Linux下部署php多版本共存

來源:互聯網
上載者:User
Linux下部署php多版本共存

  • Linux下部署php多版本共存
    • 背景說明
    • 開始安裝
    • phpini 配置
    • php-fpmconf 配置
    • 啟動 php-fpm
    • 修改nginx配置對需要的服務配置使用php-5445
    • 配置php-5445 的php54-fpm 開機自動啟動

背景說明

自php7問世,身為最新版本控的我馬上升級體驗,但是由於伺服器上還有舊程式在運行,只好部署一個php多版本共存環境。

現有環境是lnmp
- CentOS 6.7
- nginx 1.10.1
- mariadb-10.0.26
- php 7.0.8

為了更好相容舊的php程式,推薦使用5.4.45. 主要是相容mysql擴充。

開始安裝

首先要下載php-5.4.45.tar.gz源碼包。

通過源碼安裝

#tarxzvfphp-5.4.45.tar.gz#cdphp-5.4.45#./configure--prefix=/usr/local/php54--with-config-file-path=/usr/local/php54/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=/usr/local/freetype--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--with-gettext--disable-fileinfo--enable-intl--with-xsl#makeZEND_EXTRA_LIBS='-liconv'#makeinstall#cpphp.ini-production/usr/local/php/etc/php.ini

php.ini 配置

post_max_size = 50Mupload_max_filesize = 50Mdate.timezone = PRCshort_open_tag = Oncgi.fix_pathinfo=0max_execution_time = 300disable_functi>exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server

php-fpm.conf 配置

# vim /usr/local/php/etc/php-fpm.conf
[global]pid = /usr/local/php54/var/run/php-fpm.piderror_log = /usr/local/php54/var/log/php-fpm.loglog_level = notice[www]listen = /tmp/php54-cgi.socklisten.backlog = -1listen.allowed_clients = 127.0.0.1:9001listen.owner = wwwlisten.group = wwwlisten.mode = 0666user = wwwgroup = wwwpm = dynamicpm.max_children = 40pm.start_servers = 20pm.min_spare_servers = 20pm.max_spare_servers = 40request_terminate_timeout = 100request_slowlog_timeout = 0slowlog = var/log/slow.log

注意:重點是配置監聽連接埠和進程

啟動 php-fpm

# cp sapi/fpm/init.d.php-fpm /etc/init.d/php54-fpm# chmod +x /etc/init.d/php54-fpm# /etc/init.d/php54-fpm start

修改nginx配置,對需要的服務配置使用php-5.4.45

  location ~ [^/]\.php(/|$)  {      try_files $uri =404;      fastcgi_pass  unix:/tmp/php54-cgi.sock;      fastcgi_index index.php;      include fastcgi.conf;  }

配置php-5.4.45 的php54-fpm 開機自動啟動

# chkconfig --add php54-fpm# chkconfig php54-fpm on

chkconfig 功能說明:檢查,設定系統的各種服務。
文法:chkconfig [–add][–del][–list][系統服務]
chkconfig [–level <等級代號>][系統服務][on/off/reset]

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

    以上就介紹了 Linux下部署php多版本共存,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.