首頁  >  文章  >  後端開發  >  Linux下部署php多版本共存

Linux下部署php多版本共存

WBOY
WBOY原創
2016-07-28 08:28:341211瀏覽

Linux下部署php多版本共存

  • Linux下部署php多版本共存
    • 背景說明
    • 開始安裝
    • 背景說明
    • 開始安裝
    • 背景說明
    • 開始安裝
    • 背景說明
    開始安裝
背景說明開始安裝

背景說明

開始安裝

背景說明

開始安裝>phpini 設定

php-fpmconf 設定

啟動php-fpm

修改nginx設定對所需的服務設定使用php-5445

<code><span>#</span><span>tar</span><span>xzvf</span><span>php</span><span>-</span><span>5</span><span>.</span><span>4</span><span>.</span><span>45</span><span>.</span><span>tar</span><span>.</span><span>gz</span><span>#</span><span>cd</span><span>php</span><span>-</span><span>5</span><span>.</span><span>4</span><span>.</span><span>45</span><span>#</span><span>.</span><span>/configure</span><span>-</span><span>-</span><span>prefix=/usr/local/php54</span><span>-</span><span>-</span><span>with</span><span>-</span><span>config</span><span>-</span><span>file</span><span>-</span><span>path=/usr/local/php54/etc</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>fpm</span><span>-</span><span>-</span><span>with</span><span>-</span><span>fpm</span><span>-</span><span>user=www</span><span>-</span><span>-</span><span>with</span><span>-</span><span>fpm</span><span>-</span><span>group=www</span><span>-</span><span>-</span><span>with</span><span>-</span><span>mysql=mysqlnd</span><span>-</span><span>-</span><span>with</span><span>-</span><span>mysqli=mysqlnd</span><span>-</span><span>-</span><span>with</span><span>-</span><span>pdo</span><span>-</span><span>mysql=mysqlnd</span><span>-</span><span>-</span><span>with</span><span>-</span><span>iconv</span><span>-</span><span>dir</span><span>-</span><span>-</span><span>with</span><span>-</span><span>freetype</span><span>-</span><span>dir=/usr/local/freetype</span><span>-</span><span>-</span><span>with</span><span>-</span><span>jpeg</span><span>-</span><span>dir</span><span>-</span><span>-</span><span>with</span><span>-</span><span>png</span><span>-</span><span>dir</span><span>-</span><span>-</span><span>with</span><span>-</span><span>zlib</span><span>-</span><span>-</span><span>with</span><span>-</span><span>libxml</span><span>-</span><span>dir=/usr</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>xml</span><span>-</span><span>-</span><span>disable</span><span>-</span><span>rpath</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>bcmath</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>shmop</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>sysvsem</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>inline</span><span>-</span><span>optimization</span><span>-</span><span>-</span><span>with</span><span>-</span><span>curl</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>mbregex</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>mbstring</span><span>-</span><span>-</span><span>with</span><span>-</span><span>mcrypt</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>ftp</span><span>-</span><span>-</span><span>with</span><span>-</span><span>gd</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>gd</span><span>-</span><span>native</span><span>-</span><span>ttf</span><span>-</span><span>-</span><span>with</span><span>-</span><span>openssl</span><span>-</span><span>-</span><span>with</span><span>-</span><span>mhash</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>pcntl</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>sockets</span><span>-</span><span>-</span><span>with</span><span>-</span><span>xmlrpc</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>zip</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>soap</span><span>-</span><span>-</span><span>with</span><span>-</span><span>gettext</span><span>-</span><span>-</span><span>disable</span><span>-</span><span>fileinfo</span><span>-</span><span>-</span><span>enable</span><span>-</span><span>intl</span><span>-</span><span>-</span><span>with</span><span>-</span><span>xsl</span><span>#</span><span>make</span><span>ZEND_EXTRA_LIBS='</span><span>-</span><span>liconv'</span><span>#</span><span>make</span><span>install</span><span>#</span><span>cp</span><span>php</span><span>.</span><span>ini</span><span>-</span><span>production</span><span>/usr/local/php/etc/php</span><span>.</span><span>ini</span></code>

<code>post_max_size = <span>50</span>M
upload_max_filesize = <span>50</span>M
date.timezone = PRC
short_open_tag = On
cgi.fix_pathinfo=<span>0</span>
max_execution_time = <span>300</span>
disable_functi>exec,<span>system</span>,<span>chroot</span>,scandir,chgrp,<span>chown</span>,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,<span>readlink</span>,<span>symlink</span>,popepassthru,stream_socket_server</code>
背景說明

自2777名提交新版本的php相信我馬上升級體驗,但由於伺服器上還有舊程式在運行,只好部署一個php多版本共存環境。
<code><span># vim /usr/local/php/etc/php-fpm.conf</span></code>
<code>[global]
pid = /usr/local/php54/var/run/php-fpm<span>.pid</span>
error_log = /usr/local/php54/var/log/php-fpm<span>.log</span>
log_level = notice

[www]
listen = /tmp/php54-cgi<span>.sock</span>
listen<span>.backlog</span> = -<span>1</span>
listen<span>.allowed</span>_clients = <span>127.0</span><span>.0</span><span>.1</span>:<span>9001</span>
listen<span>.owner</span> = www
listen<span>.group</span> = www
listen<span>.mode</span> = <span>0666</span>
user = www
group = www
pm = dynamic
pm<span>.max</span>_children = <span>40</span>
pm<span>.start</span>_servers = <span>20</span>
pm<span>.min</span>_spare_servers = <span>20</span>
pm<span>.max</span>_spare_servers = <span>40</span>
request_terminate_timeout = <span>100</span>
request_slowlog_timeout = <span>0</span>
slowlog = var/log/slow<span>.log</span></code>
現有環境是lnmp
- CentOS 6.7

- nginx 1.10.1

- mariadb-10.0.26
- php 7.0.8

為了更好相容舊的php程序,建議使用5.4.45. 主要是相容mysql擴充。
<code><span># cp sapi/fpm/init.d.php-fpm /etc/init.d/php54-fpm</span><span># chmod +x /etc/init.d/php54-fpm</span><span># /etc/init.d/php54-fpm start</span></code>

開始安裝

<code>  location ~ [^<span>/]\.php(/</span>|<span>$)</span>
  {
      try_files <span>$uri</span> =<span>404</span>;
      fastcgi_pass  <span>unix:</span>/tmp/php54-cgi.sock;
      fastcgi_index index.php;
      <span>include</span> fastcgi.conf;
  }</code>
首先要下載php-5.4.45.tar.gz原始碼包。

透過原始碼安裝
<code><span># chkconfig --add php54-fpm</span><span># chkconfig php54-fpm on</span></code>

php.ini 設定

php-fpm.conf 設定
php-fpm.conf 設定

php-fpm.conf 設定

注意:重點是配置監聽埠和進程啟動php-fpm修改nginx配置,對需要的服務配置使用php-5.4.45修改nginx配置,對需要的服務配置使用php-5.4.45修改nginx配置,對需要的服務配置使用php-5.4.45設定php-5.4.45 的php54-fpm 開機自動啟動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 ').text(i)); }; $numbering.fadeIn(1700); }); }); 以上就介紹了 Linux下部署php多版本共存,包含了面向的內容,希望對PHP教學有興趣的朋友有幫助。
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn