I just installed php7nginx with multiple php versions. How can I choose which one to use?

Source: Internet
Author: User
I just installed php7. I created a new usrlocalphp7 and I used etcinit. dphp-fpmstop and enable etcinit. dphp7-fpmstart are OK I create a new site directly reported 502 error feeling nginx default looking for php-fpm and I have put php-f... I just installed php7. I created a new one, such as/usr/local/php7.

I put/etc/init. d/php-fpm stop

Then enable/etc/init. d/php7-fpm start

I create a new site and directly report the 502 error. I feel that nginx is looking for php-fpm by default, and I have stopped php-fpm.

I don't know how to switch. Does anyone know? Thank you.

Reply content:

I just installed php7. I created a new one, such as/usr/local/php7.

I put/etc/init. d/php-fpm stop

Then enable/etc/init. d/php7-fpm start

I create a new site and directly report the 502 error. I feel that nginx is looking for php-fpm by default, and I have stopped php-fpm.

I don't know how to switch. Does anyone know? Thank you.

Because nginx listens to port 127.0.0.1: 9000 by default, the default port 9000 has been occupied by the previous php. Follow these steps to configure it:
1. cd/usr/local/php7/etc/php-fpm.d/www. conf, find listen 127.0.0.1: 9000, modify 9000 to custom, and change it to 9001, save and exit.
2. cd/usr/local/nginx/conf/nginx. conf. Find fastcgi_pass and change it to fastcgi_pass 127.0.0.1: 9001;
3. Disable earlier versions of php-fpm/etc/init. d/php-fpm stop
4. Enable php-fpm/etc/init. d/php7-fpm start for php7
5. restart nginx service nginx restart

This is all done. Hope to help you! With the phpinfo interface of php7, let's see

1. Set different port numbers for different php-fpm, and use the address and port number as the parameter in fastcgi_pass.
2. Use socket connection directly at fastcgi_pass. You only need to change the path.

1:
: Http://php.net/archive/2015.php#id2015-01-11-6

2:
. /Configure -- prefix =/usr/local/php7 -- with-config-file-path =/usr/local/php7/etc -- enable-fpm -- with-fpm-user = www -- with-fpm-group = www -- with-mysqli -- with-pdo-mysql -- with-iconv-dir -- with-freetype-dir -- with-jpeg-dir -- with-png -dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- disable-rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline- optimization -- with-curl -- enable-mbregex -- enable-mbstring -- with-mcrypt -- enable-ftp -- with-gd -- enable-gd-native-ttf -- with-openssl --- mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-gettext -- disable-fileinfo -- enable-maintainer-zts
3:
Make ZEND_EXTRA_LIBS = '-liconv' & make install

4:
Cp php. ini-production/usr/local/php7/etc/php. ini
Cp sapi/fpm/init. d. php-fpm/etc/init. d/php7-fpm
Chmod + x/etc/init. d/php7-fpm
Cp/usr/local/php7/etc/php-fpm.conf.default/usr/local/php7/etc/php-fpm.conf
Cp/usr/local/php7/etc/php-fpm.d/www. conf. default/usr/local/php7/etc/php-fpm.d/www. conf
5:
Since I previously had a version 5.6 php-fpm.conf with the following content:
[Global]
Pid =/usr/local/php/var/run/php-fpm.pid
Error_log =/usr/local/php/var/log/php-fpm.log
Log_level = notice

[Www]
Listen =/tmp/php-cgi.sock
Listen. backlog =-1
Listen. allowed_clients = 127.0.0.1
Listen. owner = www
Listen. group = www
Listen. mode = 0666
User = www
Group = www
Pm = dynamic
Pm. max_children = 10
Pm. start_servers = 2
Pm. min_spare_servers = 1
Pm. max_spare_servers = 6
Request_terminate_timeout = 100
Request_slowlog_timeout = 0
Slowlog = var/log/slow. log

I copied it directly to/usr/local/php7/etc/and modified the above blue section to the PHP 7 path.

6: directly/etc/init. d/php-fpm stop and then/etc/init. d/php7-fpm start

You can directly switch.

You can also modify the port number of the php-fpm.conf to run php7 in a way that says no sock file method is highly efficient.

Is php. ini loaded? How did you set php. ini?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.