Home > Backend Development > PHP Tutorial > Upgrade PHP from 5.4 to 5.5 on CentOS, centosphp5.45.5_PHP tutorial

Upgrade PHP from 5.4 to 5.5 on CentOS, centosphp5.45.5_PHP tutorial

WBOY
Release: 2016-07-13 10:21:37
Original
940 people have browsed it

Upgrade PHP from 5.4 to 5.5 on CentOS, centosphp5.45.5

Upgrade PHP from 5.4 to 5.5 on CentOS

Abstract: This article records the process of upgrading PHP from 5.4.8 to 5.5.13 on CentOS 6.3.

1. Overview

In a project I worked on, I recently upgraded a series of system software on the production server, including Git, Nginx, MySQL and PHP. This article talks about the process of upgrading PHP. For upgrading other software, please see the articles listed below.

  • Upgrade git from 1.7.1 to 1.7.12.4 on CentOS
  • Upgrade Nginx from 1.2.4 to 1.6.0 on CentOS
  • Upgrade MySQL from 5.5 to 5.6 on CentOS
  • Upgrade PHP from 5.4 to 5.5 on CentOS (this article)

Before I joined this project, PHP on the server had been installed and set up, and I just used it normally. Now one year has passed, all development work has come to an end, and it is time to upgrade the software on the server. Upgrading should be done frequently, not to catch up with the latest version, but when the official version is released, it should be updated in time to obtain the latest corrections and patches, avoid vulnerabilities on the server, and reduce security risks.

The upgrade was carried out on June 13-14 this year, and I only had time to make a record today for future reference.

2. Plan

A plan is a plan, which is preparation in advance (including psychological), more detailed steps, and countermeasures for various situations and accidents. Of course, we cannot cover everything and predict everything, otherwise we will become gods, so Always be prepared to perform unscripted, think out of the box.

2.1 Understand the situation

The plan must be targeted, so you need to "step into it" first.

By using commands such as find on the system, or using the phpinfo() function on the web page to display information about PHP, you can find that PHP is installed in the /usr/local/php directory. This shows that PHP is compiled and installed from source code, because yum and rpm will not be installed to the path /usr/local/php. Following the prompts from QQ group friends, I found that the source code of PHP 5.4.8 is located in the /usr/local/src/php-5.4.8 directory, and further confirmed that PHP was compiled and installed from the source code.

View PHP version:

# /usr/local/php/bin/php -<span>v
PHP </span><span>5.4</span>.<span>8</span> (cli) (built: Nov <span>13</span> <span>2012</span> <span>00</span>:<span>08</span>:<span>08</span><span>)
Copyright (c) </span><span>1997</span>-<span>2012</span><span> The PHP Group
Zend Engine v2.</span><span>4.0</span>, Copyright (c) <span>1998</span>-<span>2012</span> Zend Tehnologies
Copy after login

Check the operation of PHP-FPM again. After reading the documentation in those two days, I learned that there is such a thing as PHP-FPM (FastCGI Process Manager), which has been included in PHP after 5.4. For details, see reference materials []13][14].

View the ports used by PHP-FPM:

# netstat -ntpul | <span>grep</span> php-<span>fpm
tcp        </span><span>0</span>      <span>0</span> <span>127.0</span>.<span>0.1</span>:<span>9000</span>              <span>0.0</span>.<span>0.0</span>:*                   LISTEN      <span>2881</span>/php-fpm
Copy after login

View the progress of PHP-FPM:

# <span>ps</span> aux | <span>grep</span> php-<span>fpm
USER       PID </span>%CPU %<span>MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      </span><span>2881</span>  <span>0.0</span>  <span>0.2</span> <span>204172</span>  <span>2064</span> ?        Ss    <span>2013</span>  <span>38</span>:<span>09</span> php-fpm: master process (/usr/local/php/etc/php-<span>fpm.conf)
www      </span><span>18982</span>  <span>0.0</span>  <span>1.4</span> <span>212796</span> <span>14816</span> ?        S    <span>19</span>:<span>12</span>   <span>0</span>:<span>03</span> php-<span>fpm: pool www
www      </span><span>18983</span>  <span>0.0</span>  <span>1.4</span> <span>211996</span> <span>14572</span> ?        S    <span>19</span>:<span>13</span>   <span>0</span>:<span>03</span> php-<span>fpm: pool www
www      </span><span>18984</span>  <span>0.0</span>  <span>1.4</span> <span>212276</span> <span>14876</span> ?        S    <span>19</span>:<span>13</span>   <span>0</span>:<span>03</span> php-<span>fpm: pool www
root     </span><span>19144</span>  <span>0.0</span>  <span>0.0</span> <span>103236</span>   <span>864</span> pts/<span>0</span>    S+   <span>23</span>:<span>29</span>   <span>0</span>:<span>00</span> <span>grep</span> php-fpm
Copy after login

Check the version of PHP-FPM:

# /usr/local/php/sbin/php-fpm -<span>v
PHP </span><span>5.4</span>.<span>8</span> (fpm-fcgi) (built: Nov <span>13</span> <span>2012</span> <span>00</span>:<span>15</span>:<span>58</span><span>)
Copyright (c) </span><span>1997</span>-<span>2012</span><span> The PHP Group
Zend Engine v2.</span><span>4.0</span>, Copyright (c) <span>1998</span>-<span>2012</span> Zend Technologies
Copy after login

Check the time of the last system startup, this is because the installed things may not take effect without restarting:

# <span>who</span> -<span>b
         system boot  </span><span>2013</span>-<span>01</span>-<span>04</span> <span>01</span>:<span>07</span><span>
# </span><span>last</span><span> reboot
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>279.14</span>.<span>1</span>. Fri Jan  <span>4</span> <span>01</span>:<span>07</span> - <span>20</span>:<span>36</span> (<span>526</span>+<span>19</span>:<span>29</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Mon Nov <span>12</span> <span>17</span>:<span>53</span> - <span>20</span>:<span>36</span> (<span>579</span>+<span>02</span>:<span>42</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Thu May <span>10</span> <span>17</span>:<span>12</span> - <span>17</span>:<span>13</span>  (<span>00</span>:<span>01</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Wed May  <span>9</span> <span>15</span>:<span>31</span> - <span>15</span>:<span>36</span>  (<span>00</span>:<span>04</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Wed May  <span>9</span> <span>15</span>:<span>03</span> - <span>15</span>:<span>29</span>  (<span>00</span>:<span>26</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Wed May  <span>9</span> <span>10</span>:<span>09</span> - <span>12</span>:<span>26</span>  (<span>02</span>:<span>16</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Thu May  <span>3</span> <span>17</span>:<span>23</span> - <span>17</span>:<span>25</span>  (<span>00</span>:<span>02</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Fri May  <span>4</span> <span>01</span>:<span>17</span> - <span>17</span>:<span>22</span>  (-<span>7</span>:-<span>54</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Fri Apr <span>20</span> <span>21</span>:<span>33</span> - <span>17</span>:<span>22</span> (<span>12</span>+<span>19</span>:<span>48</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Sat Apr <span>21</span> <span>03</span>:<span>39</span> - <span>17</span>:<span>22</span> (<span>12</span>+<span>13</span>:<span>42</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Fri Apr <span>20</span> <span>18</span>:<span>02</span> - <span>17</span>:<span>22</span> (<span>12</span>+<span>23</span>:<span>19</span><span>)
reboot   system boot  </span><span>2.6</span>.<span>32</span>-<span>220.13</span>.<span>1</span>. Thu Apr <span>19</span> <span>19</span>:<span>51</span> - <span>17</span>:<span>59</span>  (<span>22</span>:<span>07</span>)
Copy after login

In fact, this kind of worry is unnecessary, because Linux is different from Windows. Basically, newly installed things have a command line to restart. As long as you know the corresponding command line, there is no need to restart the entire system.

Summary, the existing PHP 5.4.8 is installed in the /usr/local/php directory and is compiled and installed. The source code is located in the /usr/local/src/php-5.4.8 directory. The advantage of compiling and installing is that you can customize it yourself, add or remove PHP extensions, etc. It is recommended that you do not use compilation and installation unless necessary, because such installation is troublesome to operate, has relatively high requirements for operators, and cannot use tools such as yum and rpm, making it inconvenient to upgrade and uninstall.

This is also the reason why I cannot directly upgrade PHP using the yum update php command, because yum or rpm do not know how to compile and install PHP from source code. Here are the results of my attempt:

# <span>yum</span><span> update php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 </span>* base: mirrors.<span>163</span><span>.com
 </span>*<span> epel: mirrors.hust.edu.cn
 </span>* extras: mirrors.<span>163</span><span>.com
 </span>*<span> remi: mirrors.hustunique.com
 </span>* remi-<span>php55: mirrors.hustunique.com
 </span>* updates: mirrors.<span>163</span><span>.com
Setting up Update Process
Package(s) php available, but not installed.
No Packages marked </span><span>for</span> Update
Copy after login

It can be seen that yum did not find the installed php package, so there is nothing to upgrade. Compiling and installing alone, no one wants to see it, and it seems that it will live in a corner for the rest of its life.

2.2 Confirm the plan

After consulting and discussing with other friends in several CakePHP and PHP-related QQ groups (15,000 words are omitted here), in fact, this is mixed with the above "stepping points" . Here I would like to express special thanks to two friends, Christian in the CakePHP group and the Linux administrator (Freax) in the rigorous PHP HHVM MySQL group. Finally, with the help of friends, the following plan points were formed:

  • Keep the original compiled and installed PHP 5.4.8, there is no need to touch it, just don’t use it
  • Use yum to install PHP 5.5.13 and configure PHP-FPM 5.5.13 to use another port (such as 9001)
  • Modify Nginx configuration and use PHP-FPM 5.5.13 on the new port
  • How to restart PHP-FPM?
    Answer: php-fpm defaults to a binary file after 5.4, and is no longer started by service php-fpm start. You can add this command to /etc/rc.local (link to /etc/rc.d/rc.local)

The preliminary research and planning took almost 2 days, and the subsequent installation and configuration only took 3-4 hours.

3. Install and configure PHP 5.5.13

According to the documents I read in the past two days, I determined to use remi to install the library and yum to install PHP 5.5.13.

3.1 Add remi installation library

The following operations are based on reference material [4]: ​​

# <span>wget</span> http:<span>//</span><span>dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm</span>
# <span>wget</span> http:<span>//</span><span>rpms.famillecollet.com/enterprise/remi-release-6.rpm</span>
# rpm -Uvh remi-release-<span>6</span>*.rpm epel-release-<span>6</span>*.rpm
Copy after login

3.2 Use yum to install PHP 5.5.13

From the previous output of phpinfo() under PHP 5.4.8, I know the PHP extension installed on the old PHP 5.4.8, thus determining the following packages that need to be installed (parameters after the command yum install):

# <span>yum</span> <span>install</span> php php-fpm php-gd php-mysqlnd php-mcrypt php-mbstring php-<span>pdo
Dependencies Resolved

</span>================================================================================<span>
 Package                Arch      Version                   Repository     Size
</span>================================================================================<span>
Installing:
 libjpeg</span>-turbo          x86_64    <span>1.2</span>.<span>1</span>-<span>3</span>.el6_5             updates       <span>174</span><span> k
     replacing  libjpeg.x86_64 6b</span>-<span>46</span><span>.el6
 libjpeg</span>-turbo-devel    x86_64    <span>1.2</span>.<span>1</span>-<span>3</span>.el6_5             updates        <span>96</span><span> k
     replacing  libjpeg</span>-devel.x86_64 6b-<span>46</span><span>.el6
 php                    x86_64    </span><span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55    <span>2.6</span><span> M
 php</span>-fpm                x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55    <span>1.3</span><span> M
 php</span>-gd                 x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55     <span>69</span><span> k
 php</span>-mbstring           x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55    <span>958</span><span> k
 php</span>-mcrypt             x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55     <span>40</span><span> k
 php</span>-mysqlnd            x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55    <span>261</span><span> k
 php</span>-pdo                x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55    <span>109</span><span> k
Installing </span><span>for</span><span> dependencies:
 apr</span>-util-ldap          x86_64    <span>1.3</span>.<span>9</span>-<span>3</span>.el6_0.<span>1</span>           base           <span>15</span><span> k
 fontconfig             x86_64    </span><span>2.8</span>.<span>0</span>-<span>3</span>.el6               base          <span>186</span><span> k
 gd</span>-<span>last</span>                x86_64    <span>2.1</span>.<span>0</span>-<span>2</span>.el6.remi          remi          <span>129</span><span> k
 httpd                  x86_64    </span><span>2.2</span>.<span>15</span>-<span>30</span>.el6.centos      updates       <span>821</span><span> k
 httpd</span>-tools            x86_64    <span>2.2</span>.<span>15</span>-<span>30</span>.el6.centos      updates        <span>73</span><span> k
 libX11                 x86_64    </span><span>1.5</span>.<span>0</span>-<span>4</span>.el6               base          <span>584</span><span> k
 libX11</span>-common          noarch    <span>1.5</span>.<span>0</span>-<span>4</span>.el6               base          <span>192</span><span> k
 libXau                 x86_64    </span><span>1.0</span>.<span>6</span>-<span>4</span>.el6               base           <span>24</span><span> k
 libXpm                 x86_64    </span><span>3.5</span>.<span>10</span>-<span>2</span>.el6              base           <span>51</span><span> k
 libmcrypt              x86_64    </span><span>2.5</span>.<span>8</span>-<span>9</span>.el6               epel           <span>96</span><span> k
 libtiff                x86_64    </span><span>3.9</span>.<span>4</span>-<span>10</span>.el6_5            updates       <span>343</span><span> k
 libxcb                 x86_64    </span><span>1.8</span>.<span>1</span>-<span>1</span>.el6               base          <span>110</span><span> k
 libxslt                x86_64    </span><span>1.1</span>.<span>26</span>-<span>2</span>.el6_3.<span>1</span>          base          <span>452</span><span> k
 mailcap                noarch    </span><span>2.1</span>.<span>31</span>-<span>2</span>.el6              base           <span>27</span><span> k
 php</span>-cli                x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55    <span>2.5</span><span> M
 php</span>-common             x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55    <span>1.0</span><span> M
 php</span>-pear               noarch    <span>1</span>:<span>1.9</span>.<span>4</span>-<span>28</span>.el6.remi       remi          <span>373</span><span> k
 php</span>-pecl-jsonc         x86_64    <span>1.3</span>.<span>5</span>-<span>1</span>.el6.remi.<span>5.5</span>      remi-php55     <span>46</span><span> k
 php</span>-pecl-<span>zip</span>           x86_64    <span>1.12</span>.<span>4</span>-<span>1</span>.el6.remi.<span>5.5</span>     remi-php55    <span>269</span><span> k
 php</span>-process            x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55     <span>54</span><span> k
 php</span>-xml                x86_64    <span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi         remi-php55    <span>206</span><span> k
 t1lib                  x86_64    </span><span>5.1</span>.<span>2</span>-<span>6</span>.el6_2.<span>1</span>           base          <span>160</span><span> k

Transaction Summary
</span>================================================================================<span>
Install      </span><span>31</span> Package(s)
Copy after login

yum自动计算出需要的依赖安装包,总共有31个安装包需要下载、安装。

下面询问是否继续下载,回答y,并按回车即可继续:

Total download size: <span>13</span><span> M
Is this ok [y</span>/<span>N]: y
Downloading Packages:
(</span><span>1</span>/<span>31</span>): apr-util-ldap-<span>1.3</span>.<span>9</span>-<span>3</span>.el6_0.<span>1</span>.x86_64.rpm         |  <span>15</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>2</span>/<span>31</span>): fontconfig-<span>2.8</span>.<span>0</span>-<span>3</span>.el6.x86_64.rpm                | <span>186</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>3</span>/<span>31</span>): gd-<span>last</span>-<span>2.1</span>.<span>0</span>-<span>2</span>.el6.remi.x86_64.rpm              | <span>129</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>4</span>/<span>31</span>): httpd-<span>2.2</span>.<span>15</span>-<span>30</span>.el6.centos.x86_64.rpm            | <span>821</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>5</span>/<span>31</span>): httpd-tools-<span>2.2</span>.<span>15</span>-<span>30</span>.el6.centos.x86_64.rpm      |  <span>73</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>6</span>/<span>31</span>): libX11-<span>1.5</span>.<span>0</span>-<span>4</span>.el6.x86_64.rpm                    | <span>584</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>7</span>/<span>31</span>): libX11-common-<span>1.5</span>.<span>0</span>-<span>4</span>.el6.noarch.rpm             | <span>192</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>8</span>/<span>31</span>): libXau-<span>1.0</span>.<span>6</span>-<span>4</span>.el6.x86_64.rpm                    |  <span>24</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>9</span>/<span>31</span>): libXpm-<span>3.5</span>.<span>10</span>-<span>2</span>.el6.x86_64.rpm                   |  <span>51</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>10</span>/<span>31</span>): libjpeg-turbo-<span>1.2</span>.<span>1</span>-<span>3</span>.el6_5.x86_64.rpm          | <span>174</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>11</span>/<span>31</span>): libjpeg-turbo-devel-<span>1.2</span>.<span>1</span>-<span>3</span>.el6_5.x86_64.rpm    |  <span>96</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>12</span>/<span>31</span>): libmcrypt-<span>2.5</span>.<span>8</span>-<span>9</span>.el6.x86_64.rpm                |  <span>96</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>13</span>/<span>31</span>): libtiff-<span>3.9</span>.<span>4</span>-<span>10</span>.el6_5.x86_64.rpm               | <span>343</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>14</span>/<span>31</span>): libxcb-<span>1.8</span>.<span>1</span>-<span>1</span>.el6.x86_64.rpm                   | <span>110</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>15</span>/<span>31</span>): libxslt-<span>1.1</span>.<span>26</span>-<span>2</span>.el6_3.<span>1</span>.x86_64.rpm             | <span>452</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>16</span>/<span>31</span>): mailcap-<span>2.1</span>.<span>31</span>-<span>2</span>.el6.noarch.rpm                 |  <span>27</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>17</span>/<span>31</span>): php-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm                | <span>2.6</span> MB     <span>00</span>:<span>00</span><span>
(</span><span>18</span>/<span>31</span>): php-cli-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm            | <span>2.5</span> MB     <span>00</span>:<span>00</span><span>
(</span><span>19</span>/<span>31</span>): php-common-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm         | <span>1.0</span> MB     <span>00</span>:<span>00</span><span>
(</span><span>20</span>/<span>31</span>): php-fpm-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm            | <span>1.3</span> MB     <span>00</span>:<span>00</span><span>
(</span><span>21</span>/<span>31</span>): php-gd-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm             |  <span>69</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>22</span>/<span>31</span>): php-mbstring-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm       | <span>958</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>23</span>/<span>31</span>): php-mcrypt-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm         |  <span>40</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>24</span>/<span>31</span>): php-mysqlnd-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm        | <span>261</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>25</span>/<span>31</span>): php-pdo-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm            | <span>109</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>26</span>/<span>31</span>): php-pear-<span>1.9</span>.<span>4</span>-<span>28</span>.el6.remi.noarch.rpm           | <span>373</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>27</span>/<span>31</span>): php-pecl-jsonc-<span>1.3</span>.<span>5</span>-<span>1</span>.el6.remi.<span>5.5</span>.x86_64.rpm  |  <span>46</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>28</span>/<span>31</span>): php-pecl-<span>zip</span>-<span>1.12</span>.<span>4</span>-<span>1</span>.el6.remi.<span>5.5</span>.x86_64.rpm   | <span>269</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>29</span>/<span>31</span>): php-process-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm        |  <span>54</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>30</span>/<span>31</span>): php-xml-<span>5.5</span>.<span>13</span>-<span>3</span>.el6.remi.x86_64.rpm            | <span>206</span> kB     <span>00</span>:<span>00</span><span>
(</span><span>31</span>/<span>31</span>): t1lib-<span>5.1</span>.<span>2</span>-<span>6</span>.el6_2.<span>1</span>.x86_64.rpm                | <span>160</span> kB     <span>00</span>:<span>00</span>
--------------------------------------------------------------------------------<span>
Total                                           </span><span>3.6</span> MB/s |  <span>13</span> MB     <span>00</span>:<span>03</span>
Copy after login

之后还有一些Is this ok [y/N]:的问题,一律回答y。经过一轮问答和安装,最后完成时的小结为:

<span>Installed:
  libjpeg</span>-turbo.x86_64 <span>0</span>:<span>1.2</span>.<span>1</span>-<span>3</span><span>.el6_5
  libjpeg</span>-turbo-devel.x86_64 <span>0</span>:<span>1.2</span>.<span>1</span>-<span>3</span><span>.el6_5
  php.x86_64 </span><span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  php</span>-fpm.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  php</span>-gd.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  php</span>-mbstring.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  php</span>-mcrypt.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  php</span>-mysqlnd.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  php</span>-pdo.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi

Dependency Installed:
  apr</span>-util-ldap.x86_64 <span>0</span>:<span>1.3</span>.<span>9</span>-<span>3</span>.el6_0.<span>1</span><span>
  fontconfig.x86_64 </span><span>0</span>:<span>2.8</span>.<span>0</span>-<span>3</span><span>.el6
  gd</span>-<span>last</span>.x86_64 <span>0</span>:<span>2.1</span>.<span>0</span>-<span>2</span><span>.el6.remi
  httpd.x86_64 </span><span>0</span>:<span>2.2</span>.<span>15</span>-<span>30</span><span>.el6.centos
  httpd</span>-tools.x86_64 <span>0</span>:<span>2.2</span>.<span>15</span>-<span>30</span><span>.el6.centos
  libX11.x86_64 </span><span>0</span>:<span>1.5</span>.<span>0</span>-<span>4</span><span>.el6
  libX11</span>-common.noarch <span>0</span>:<span>1.5</span>.<span>0</span>-<span>4</span><span>.el6
  libXau.x86_64 </span><span>0</span>:<span>1.0</span>.<span>6</span>-<span>4</span><span>.el6
  libXpm.x86_64 </span><span>0</span>:<span>3.5</span>.<span>10</span>-<span>2</span><span>.el6
  libmcrypt.x86_64 </span><span>0</span>:<span>2.5</span>.<span>8</span>-<span>9</span><span>.el6
  libtiff.x86_64 </span><span>0</span>:<span>3.9</span>.<span>4</span>-<span>10</span><span>.el6_5
  libxcb.x86_64 </span><span>0</span>:<span>1.8</span>.<span>1</span>-<span>1</span><span>.el6
  libxslt.x86_64 </span><span>0</span>:<span>1.1</span>.<span>26</span>-<span>2</span>.el6_3.<span>1</span><span>
  mailcap.noarch </span><span>0</span>:<span>2.1</span>.<span>31</span>-<span>2</span><span>.el6
  php</span>-cli.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  php</span>-common.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  php</span>-pear.noarch <span>1</span>:<span>1.9</span>.<span>4</span>-<span>28</span><span>.el6.remi
  php</span>-pecl-jsonc.x86_64 <span>0</span>:<span>1.3</span>.<span>5</span>-<span>1</span>.el6.remi.<span>5.5</span><span>
  php</span>-pecl-<span>zip</span>.x86_64 <span>0</span>:<span>1.12</span>.<span>4</span>-<span>1</span>.el6.remi.<span>5.5</span><span>
  php</span>-process.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  php</span>-xml.x86_64 <span>0</span>:<span>5.5</span>.<span>13</span>-<span>3</span><span>.el6.remi
  t1lib.x86_64 </span><span>0</span>:<span>5.1</span>.<span>2</span>-<span>6</span>.el6_2.<span>1</span><span>

Replaced:
  libjpeg.x86_64 </span><span>0</span>:6b-<span>46</span>.el6          libjpeg-devel.x86_64 <span>0</span>:6b-<span>46</span><span>.el6

Complete</span>!
Copy after login

3.3 配置PHP-FPM的启动

因为使用yum安装,安装过程已经拷贝好了PHP-FPM的服务daemon,只需确保PHP-FPM服务能在系统重启时自动启动就行了:

# chkconfig php-fpm on
Copy after login

查看PHP-FPM服务的自启动状态:

# chkconfig --list php-<span>fpm
php</span>-fpm         <span>0</span>:off   <span>1</span>:off   <span>2</span>:on    <span>3</span>:on    <span>4</span>:on    <span>5</span>:on    <span>6</span>:off
Copy after login

正确。

3.4 停止PHP-FPM 5.4.8

查看PHP-FPM 5.4.8的进程:

# <span>ps</span> aux | <span>grep</span> php-<span>fpm
root      </span><span>2881</span>  <span>0.0</span>  <span>0.1</span> <span>204172</span>  <span>1972</span> ?        Ss    <span>2013</span>  <span>38</span>:<span>13</span> php-fpm: master process (/usr/local/php/etc/php-<span>fpm.conf)
www      </span><span>19378</span>  <span>0.0</span>  <span>1.4</span> <span>212764</span> <span>14736</span> ?        S    <span>10</span>:<span>30</span>   <span>0</span>:<span>14</span> php-<span>fpm: pool www
www      </span><span>19379</span>  <span>0.0</span>  <span>1.5</span> <span>213352</span> <span>15888</span> ?        S    <span>10</span>:<span>32</span>   <span>0</span>:<span>13</span> php-<span>fpm: pool www
www      </span><span>19657</span>  <span>0.0</span>  <span>1.3</span> <span>212076</span> <span>13964</span> ?        S    <span>18</span>:<span>45</span>   <span>0</span>:<span>02</span> php-<span>fpm: pool www
root     </span><span>20083</span>  <span>0.0</span>  <span>0.0</span> <span>103236</span>   <span>864</span> pts/<span>0</span>    S+   <span>22</span>:<span>40</span>   <span>0</span>:<span>00</span> <span>grep</span> php-fpm
Copy after login

可见,当前PHP-FPM 5.54.8进程的进程号(pid)是2881,注意其使用的配置文件/usr/local/php/etc/php-fpm.conf位于编译安装PHP的目录,证实了这是PHP-FPM 5.54.8进程。其余进程为其子进程,而grep php-fpm是查看进程这个命令的进程

中断PHP-FPM 5.54.8进程:

# <span>kill</span> -TERM <span>2881</span>
Copy after login

再次查看PHP-FPM的进程:

# <span>ps</span> aux | <span>grep</span> php-<span>fpm
root     </span><span>20087</span>  <span>0.0</span>  <span>0.0</span> <span>103236</span>   <span>864</span> pts/<span>0</span>    S+   <span>22</span>:<span>43</span>   <span>0</span>:<span>00</span> <span>grep</span> php-fpm
Copy after login

已经没有PHP-FPM的进程了,唯一剩下的grep php-fpm是查看进程这个命令的进程。

3.5 启动PHP-FPM 5.5.13

PHP-FPM的配置,我遵照的是参考资料[10],这是一个分级结构的配置文件,多个配置文件各司其职,便于更换配置,启用、停止配置的各模块也更容易。

启动php-fpm服务:

# service php-<span>fpm start
Starting php</span>-fpm:                                          [  OK  ]
Copy after login

顺利启动。

再查看其进程:

# <span>ps</span> aux | <span>grep</span> php-<span>fpm
root     </span><span>20099</span>  <span>0.0</span>  <span>0.5</span> <span>313272</span>  <span>5832</span> ?        Ss   <span>22</span>:<span>44</span>   <span>0</span>:<span>00</span> php-fpm: master process (/etc/php-<span>fpm.conf)
apache   </span><span>20100</span>  <span>0.4</span>  <span>1.1</span> <span>317112</span> <span>11876</span> ?        S    <span>22</span>:<span>44</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
apache   </span><span>20101</span>  <span>0.3</span>  <span>1.5</span> <span>319936</span> <span>15316</span> ?        S    <span>22</span>:<span>44</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
apache   </span><span>20102</span>  <span>0.4</span>  <span>1.6</span> <span>322244</span> <span>16892</span> ?        S    <span>22</span>:<span>44</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
apache   </span><span>20103</span>  <span>0.4</span>  <span>1.5</span> <span>320964</span> <span>15636</span> ?        S    <span>22</span>:<span>44</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
apache   </span><span>20104</span>  <span>0.3</span>  <span>1.3</span> <span>319648</span> <span>14256</span> ?        S    <span>22</span>:<span>44</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
apache   </span><span>20106</span>  <span>0.3</span>  <span>1.3</span> <span>319140</span> <span>13696</span> ?        S    <span>22</span>:<span>45</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
apache   </span><span>20107</span>  <span>0.1</span>  <span>0.7</span> <span>313776</span>  <span>8140</span> ?        S    <span>22</span>:<span>46</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
root     </span><span>20109</span>  <span>0.0</span>  <span>0.0</span> <span>103236</span>   <span>864</span> pts/<span>0</span>    S+   <span>22</span>:<span>47</span>   <span>0</span>:<span>00</span> <span>grep</span> php-fpm
Copy after login

可见其进程号为20099,其余进程为其子进程,而grep php-fpm是查看进程这个命令的进程。

3.6 问题:数据库的图像文件没有显示

原因:PHP-FPM子进程的所有者:组是apache,而不是www。而Nginx是运行在www用户下,故应当改为www。

编辑/etc/php-fpm.d/www.conf:

<span>[</span><span>www</span><span>]</span>
<span>;</span><span>user = apache</span>
user =<span> www
</span><span>;</span><span>group = apache</span>
group = www
Copy after login

再重启php-fpm服务:

# service php-<span>fpm stop
Stopping php</span>-<span>fpm:                                          [  OK  ]
# service php</span>-<span>fpm start
Starting php</span>-fpm:                                          [  OK  ]
Copy after login

查看php-fpm进程:

# <span>ps</span> aux | <span>grep</span> php-<span>fpm
root     </span><span>20208</span>  <span>0.0</span>  <span>0.5</span> <span>313272</span>  <span>5832</span> ?        Ss   <span>23</span>:<span>13</span>   <span>0</span>:<span>00</span> php-fpm: master process (/etc/php-<span>fpm.conf)
www      </span><span>20209</span>  <span>0.4</span>  <span>1.0</span> <span>316056</span> <span>10388</span> ?        S    <span>23</span>:<span>13</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
www      </span><span>20210</span>  <span>0.3</span>  <span>0.9</span> <span>315020</span>  <span>9280</span> ?        S    <span>23</span>:<span>13</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
www      </span><span>20211</span>  <span>0.4</span>  <span>1.0</span> <span>316580</span> <span>10764</span> ?        S    <span>23</span>:<span>13</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
www      </span><span>20212</span>  <span>0.4</span>  <span>1.0</span> <span>316056</span> <span>10388</span> ?        S    <span>23</span>:<span>13</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
www      </span><span>20213</span>  <span>0.0</span>  <span>0.4</span> <span>313272</span>  <span>4872</span> ?        S    <span>23</span>:<span>13</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
www      </span><span>20215</span>  <span>0.0</span>  <span>0.4</span> <span>313272</span>  <span>4876</span> ?        S    <span>23</span>:<span>13</span>   <span>0</span>:<span>00</span> php-<span>fpm: pool www
root     </span><span>20217</span>  <span>0.0</span>  <span>0.0</span> <span>103236</span>   <span>860</span> pts/<span>0</span>    S+   <span>23</span>:<span>14</span>   <span>0</span>:<span>00</span> <span>grep</span> php-fpm
Copy after login

可以看到PHP-FPM进程的进程号是20208,其子进程都以www用户身份运行,而grep php-fpm是查看进程这个命令的进程。

3.7 问题:登录总是失败,并重新返回到登录页面

错误日志为:

2014-06-14 23:14:36 Warning: Warning (2): Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in <span>[</span><span>Unknown, line 0</span><span>]</span>
Copy after login

原因:PHP session目录的所有者:组是apache:apache,而不是www:www,与实际进程运行的用户身份不符。

更改PHP session目录的所有者:组为www:www:

# chown -R www:www /var/lib/php/session
Copy after login

从此,王子和公主过着没羞没臊的生活!

A. 参考资料

centos55升级php到53,报如下错误:

问题人家说的很清楚了:

Error: Missing Dependency: php-api = 20041225 is needed by package php-sqlite3-0.4-1.mf.i386 (installed)

建议人家也给你了:
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest

你缺少包:php-api
 

Centos58 怎把php5217升级到php533

centos5源里面php默认最高就是5.2
如果你想用php5.3。又不想自己编译安装在某个普通用户下面(切勿直接在root下编译安装替换系统的,会有很多问题的)
那还有一个选择。就是安装php53不过如果想装好,可能得先把php卸载掉。
在root用户下

yum remove php

然后再安装php53及所有相关组件
yum install php53*
 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/855625.htmlTechArticle在CentOS上把PHP从5.4升级到5.5,centosphp5.45.5 在CentOS上把PHP从5.4升级到5.5 摘要:本文记录了在CentOS 6.3上,把PHP从5.4.8升级到5.5.13的过程。 1. 概...
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template