Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build php5.6 by centos7

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "centos7 how to build php5.6", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "centos7 how to build php5.6" this article.

Centos7 build php5.6 method: 1, get the PHP download address; 2, configure the installation directory to / usr/local/php/; 3, configure php.ini file; 4, copy php-fpm configuration file and modify startup.

This article operating environment: centos7 system, PHP5.6 version, DELL G3 computer

Detailed explanation of the tutorial on installing PHP5.6.30 Service under CentOS7.0

About php-fpm

Nginx itself cannot handle PHP, it is just a web server. When a request is received, if it is a php request, it will be sent to the php interpreter for processing and the result will be returned to the client.

Nginx generally sends the request to the fastcgi management process for processing, and the fascgi management process selects the processing result of the CGI child process and returns the nginx.

PHP-FPM is a PHP FastCGI manager that is used only for PHP.

PHP has written php-fpm into the php source core since 5.3.3. So there is no need to download another one.

Get the PHP download address

Why choose 5.6.30 this version, because study, not research. Admittedly, 7.0has added a lot of new features of PHP, and there are some improvements in performance, so you can toss about it if you are studying it, and then we'll talk about version 7.0 and how to switch between PHP versions.

Open the official website of php: http://php.net/ to see the list of versions of php

Right-click, copy the link address, log in from the remote host, and download the software (I chose the host mirror of Australia to download it)

# wget http://au1.php.net/get/php-5.6.30.tar.gz/from/this/mirror

What is downloaded is a mirror file, which 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

Configuration and installation

To go to 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 errors may be reported during configuration

Error 1:

Xml2-config not found. Please check your libxml2 installation.

Solution.

Install libxml2 related components

# yum install libxml2#yum install libxml2-devel-y

Error 2:

Please reinstall the libcurl distribution-easy.h should be in / include/curl/

Install curl related components

# yum install curl curl-devel

Error 3:

Configure: error: png.h not found.

Install libpng related 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 related components

# yum install libxslt-devel

OK, when we see the following sentence, it means that your php has been configured!

Then we just need to compile and install to complete the installation of php.

# make & & make install

See this sentence, indicating that the installation is complete!

Just to be on the safe side, let's make test and see if it really succeeds.

Configure related php.ini configuration

The first thing we need to configure is the php.ini file.

The installation directory has two files: php.ini-development and php.ini-production

The online version of php.ini-production uses

Php.ini-development development version uses

We choose 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 enable Fil

# cp-R. / sapi/fpm/php-fpm / etc/init.d/php-fpm (deprecated, see Note 1 for details)

Start

# / etc/init.d/php-fpm

Check to see if php starts successfully

# ps aux | grep php

Seeing these shows that your php has been started successfully!

Restart and shutdown

# kill-9 process number # / etc/init.d/php-fpm

Configure Nginx to support PHP

Enter the nginx home directory, / usr/local/nginx

# cd / usr/local/nginx

Enter the configuration directory

# cd conf

Nginx.conf needs to be modified when Nginx supports PHP

# vim nginx.conf

Replace the following code and let Nginx support PHP, in the server code snippet.

After modification, the code becomes, the red part is our host directory is / usr/www, and 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 exit.

As explained in the Nginx chapter, we restart the Nginx service.

# / etc/init.d/nginx restart

If you do not configure it as we did in Nginx, you can restart the Nginx service as follows

# / usr/local/nginx/sbin/nginx-s reload

Restart successfully! Let's add a new file in the / usr/www directory.

# vim / usr/www/phpinfo.php

Insert the following

Open http:// remote ip/phpinfo.php in a browser

When you see this page, congratulations, your PHP has been installed and configured. You can see all the components that php depends on on this page. I will explain this page in detail in the next section. If you have any questions about this section, please feel free to communicate and discuss with me in the comments section. ^ _ ^

Note

Set the convenient way for php to boot and start php service.

In the above method, I had a problem copying php-fpm 's service. Instead of copying the executable file of php-fpm directly to the / etc/init.d/ directory, I should give php to our prepared init.d.php-fpm.

# cp. / sapi/fpm/init.d.php-fpm / etc/init.d/php-fpm

Add a php-fpm service to the chkconfig list

# chkconfig-add php-fpm

Set Boot self-boot

# chkconfig php-fpm on

The way to restart and stop php later is

# service php-fpm start#service php-fpm stop#service php-fpm restart#service php-fpm reload above is all the content of the article "how to build php5.6 in centos7". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 291

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report