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 compile and install php-fpm in php5.6

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Xiaobian to share with you how to compile and install php-fpm in php5.6, I believe most people still do not know how, so share this article for everyone's reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!

php5.6 php-fpm compilation and installation methods: 1. Install php dependency packages and download php5.6.36 version;2. Specify the software installation directory as "/usr/local/php";3. Nginx configuration parsing php.

Operating environment: ubuntu 16.04 system, php version 5.6.36, Dell G3 computer.

Today I found a website based on php version, and then try to install it again after collecting information online.

First, install PHP dependency packages.

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN pcre-devel II. Download PHP 5.6.36

http://php.net/get/php-5.6.36.tar.gz/from/a/mirrorphp-fpm Component Description

Nginx in the LNMP environment does not support php, and needs to process php requests through the fastcgi plugin. Php requires php-fpm to provide this functionality. Before php 5.3.3 php-fpm existed as a patch package, but after php 5.3.3 you just need to load the module with--enable-fpm during compilation and installation, no separate installation is required.

3. Install PHP

Create the directory where php needs to be installed

cd /etc/mkdir phpcd /usr/local/mkdir phptar -xzvf php-5.6.36.tar.gzcd php-5.6.36 In the configuration below, specify the software installation directory as/usr/local/php and the configuration file installation directory as

/etc/php./ configure --prefix=/usr/local/php --with-config-file-path=/etc/php --enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --enable-zip --enable-ftp --enable-soap --enable-xml --enable-mbstring --disable-rpath --disable-debug --disable-fileinfo --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pcre-regex --with-iconv --with-zlib --with-gd --with-openssl --with-mhash --with-xmlrpc --with-curl --with-imap-sslThank you for using PHP.config.status: creating php5.specconfig.status: creating main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/man1/phpize.1config.status: creating scripts/php-configconfig.status: creating scripts/man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/fpm/php-fpm.confconfig.status: creating sapi/fpm/init.d.php-fpmconfig.status: creating sapi/fpm/php-fpm.serviceconfig.status: creating sapi/fpm/php-fpm.8config.status: creating sapi/fpm/status.htmlconfig.status: creating sapi/cgi/php-cgi.1config.status: creating ext/phar/phar.1config.status: creating ext/phar/phar.phar.1config.status: creating main/php_config.hconfig.status: executing default commands[root@localhost php-5.6.36]# make[root@localhost php-5.6.36]# make install

View the contents of the software installation directory

[root@localhost php-5.6.30]# ls /usr/local/phpbin etc include lib php sbin var

Copy the profile template to the profile directory

[root@localhost php-5.6.30]# cp php.ini-development /etc/php/php.ini

Create a soft connection

[root@localhost ~]# ln -s /usr/local/php/bin/php /usr/bin/php[root@localhost ~]# ln -s /usr/local/php/bin/phpize /usr/bin/phpize[root@localhost ~]# ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm

View installed version

[root@localhost ~]# /usr/local/php/bin/php --version[root@localhost ~]# cd /usr/local/php/etc/[root@localhost ~]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf[root@localhost ~]# ln -s /usr/local/php/etc/php-fpm.conf /etc/php/php-fpm.conf #Add soft link to/php directory [root@localhost ~]# vim /usr/local/php/etc/php-fpm.confpid = run/php-fpm.pid #Remove the preceding semicolon [root@localhost ~]# cp source directory/php-5.6.36/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #Copy php-fpm to boot directory [root@localhost ~]# chmod +x /etc/rc.d/init.d/php-fpm #Add execution permissions [root@localhost ~]# chkconfig php-fpm on #Set boot

Check whether the port is occupied

[root@localhost ~]# netstat -tunlp |grep 9000

start the service

[root@localhost ~]# cd /etc/rc.d/init.d/[root@localhost ~]# ./ php-fpm start[root@localhost ~]# netstat -tunlp |grep 9000[root@localhost ~]# ps -ef|grep fpm

Nginx configuration analysis php

1. Enter nginx directory

[root@localhost ~]# cd /usr/local/nginx/conf

2. Edit configuration files

[root@localhost ~]# vim nginx.conf

Found on server.

location / { root html; index index.html index.htm index.php; #Add index.php, make nginx server default support index.php for home page}

The configuration.php request is sent to the php-fpm module on the backend. By default, the php configuration block is commented. In this case, remove the comment and modify it to the following:

location ~ \.php$ { root /usr/local/nginx/html; #Modify html path fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #Here is/scripts, need to change to $document_root include fastcgi_params; }

Reload nginx after saving

[root@localhost ~]# /usr/local/nginx/nginx -s t[root@localhost ~]# /usr/local/nginx/nginx -s reloadhttp://192.168.1.11/index.php

V. Related inquiries

1. See how many php-cgi processes are open on the server by commanding

ps -fe |grep "php-fpm"|grep "pool"|wc -l

2. See how many php-cgi processes are already processing tcp requests

netstat -anp|grep "php-fpm"|grep "tcp"|grep "pool"|wc -l

3.Linux+nginx+php environment, each php-fpm process memory limit

Setting method:

Edit the php-fpm.conf configuration file

php_admin_value[memory_limit] = 128M (the configuration file on my server is in/etc/php5/fpm/pool.d/www.conf This file is included in php-fpm.conf) The following numbers can be changed at will: 32M,64M,128M,256M,512M. This setting can be written according to your server memory size and your needs. After modification, load the php-fpm service.

The above is "php-fpm in php5.6 how to compile and install" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to 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: 0

*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