[CNMP series] install PHP5.6.30 service under CentOS7.0, cnmpphp5.6.30
In the previous section, we talked about how to install the MySql service under CentOS7.0. If you do not see a friend on the welcome page, you can add my personal chat: litao514148204
Attached to previous Section Address: http://www.cnblogs.com/riverdubu/p/6426852.html
About php-fpm
Nginx itself cannot process PHP. It is only a web server. After receiving the request, if it is a php request, it is sent to the php interpreter for processing and the result is returned to the client.
Nginx generally sends a request to the fastcgi management process for processing. The fascgi management process selects the cgi sub-process for processing the result and returns nginx.
The PHP-FPM is a PHP FastCGI manager and is only for PHP.
PHP has talked about writing php-fpm to the php source code core after 5.3.3. So no additional download is required.
Get PHP
Why choose 5.6.30, because learning is not a research. It is true that 7.0 has added many new PHP features, and the performance has also been improved. If it is research, it can be a bit complicated, later, let's talk about version 7.0 and how to switch between different PHP versions.
Go to the php Official Website: http://php.net/,?php= list
Right-click, copy the link address, log on to the remote host, and download the software (I selected mirror from the host in Australia)
# wget http://au1.php.net/get/php-5.6.30.tar.gz/from/this/mirror
The downloaded mirror file is changed to the file name we need.
#mv mirror php-5.6.30.tar.gz#tar zxvf php-5.6.30.tar.gz#cd php-5.6.30
Configure and install
To enter the directory, We need to configure the installation directory to/usr/local/php/during installation.
#./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-MySQL --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
The following error may be reported during configuration
Error 1:
xml2-config not found. Please check your libxml2 installation.
Solution
Install libxml2 Components
#yum install libxml2#yum install libxml2-devel -y
Error 2:
Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
Install curl Components
#yum install curl curl-devel
Error 3:
configure: error: png.h not found.
Install libpng Components
#yum install libpng#yum install libpng-devel
Error 4:
freetype-config not found.
Install freetype related components
#yum install freetype-devel
Error 5:
xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
Install libxslt Components
#yum install libxslt-devel
Okay. When we see the following sentence, it indicates that your php configuration has been completed!
Next, we only need to compile and install the php installation.
#make && make install
The installation is complete!
For the sake of insurance, let's make test to see if it is successful.
Configure related php. ini configurations
First, we need to configure the php. ini file.
The installation directory contains two files: php. ini-development and php. ini-production.
Php. ini-production version used online
Php. ini-development version used
We chose development for configuration.
# cp php.ini-development /usr/local/php/lib/php.ini
Php-fpm Configuration
Copy the php-fpm configuration file
#cp -R ./sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf
Copy enabled files
# Cp-R./sapi/fpm/php-fpm/etc/init. d/php-fpm (Deprecated. For details, see note 1)
Start
#/etc/init.d/php-fpm
Check if php is started successfully
#ps aux | grep php
Seeing this shows that your php has been started successfully!
Restart and close
# Kill-9 process #/etc/init. d/php-fpm
Configure Nginx to support PHP
Go to the nginx home directory,/usr/local/nginx;
#cd /usr/local/nginx
Enter the configuration directory
#cd conf
Nginx must be modified to support PHP.
#vim nginx.conf
On behalf of the following code, let Nginx support PHP, in the server code segment.
After modification, the code changes to the red part of the Code. The red part indicates that the host directory is/usr/www. You need to modify fastcgi_param SCRIPT_FILENAME to point to the corresponding directory:
Set the home directory to/usr/www.
Comment out the root line and add a new line: root/usr/www;
Save and exit.
According to the Nginx chapter, restart the Nginx service.
#/etc/init.d/nginx restart
If you do not configure Nginx as follows, restart the Nginx Service as follows:
# /usr/local/nginx/sbin/nginx -s reload
Reboot successful! Next we will add a new file under the/usr/www directory.
#vim /usr/www/phpinfo.php
Insert the following content
<?php phpinfo(); ?>
Open http: // remote ip/phpinfo. php In the browser
On this page, congratulations, Your PHP installation and configuration have been completed. You can see all the components on which php depends. I will explain this page in detail in the next section. If you have any questions about this section, you are welcome to discuss with me in the comments area. If you have any comments, you must return them. Pai_^
Note
Set the php auto-start mode and the convenient mode for enabling the php Service
In the above method, I encountered a problem when copying the php-fpm service. I should not directly copy the executable file of php-fpm to/etc/init. d/directory, the init. php should be prepared for us. d. php-fpm.
#cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
Add the php-fpm service to the chkconfig list
#chkconfig --add php-fpm
Set auto-start
#chkconfig php-fpm on
The method for restarting and stopping php later is
#service php-fpm start#service php-fpm stop#service php-fpm restart#service php-fpm reload
The above is my problem. Please correct it in time.