search
HomeBackend DevelopmentPHP TutorialUpgrade 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

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

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

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

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

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>)

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

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

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)

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>

之后还有一些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>!

3.3 配置PHP-FPM的启动

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

# chkconfig php-fpm on

查看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

正确。

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

可见,当前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>

再次查看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

已经没有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  ]

顺利启动。

再查看其进程:

# <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

可见其进程号为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

再重启php-fpm服务:

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

查看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

可以看到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>

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

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

# chown -R www:www /var/lib/php/session

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

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. 概...
Statement
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
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace("&nbsp;","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft