简体   繁体   中英

Can't get Nginx + PHP-FPM + compiled PHP to work

I'm a PHP Developer for about 3 years and I finally got it as a hobby too, created a Ubuntu 14.04 VM at home for developing personal projects and studying new things.
I did configure a Nginx + PHP + PHP-FPM environment just by apt-get install some packages and than making a few changes to configuration, ok that works...

But I wanna go further! I want to compile a specific PHP version, not that one that comes with php5-fpm from apt-get... tried it and that gave me headaches! Couldn't make the compiled PHP work with PHP-FPM for some reason...
I did follow tutorials and configure the environment but don't really know what I'm doing, so now I'm destroing my VM and creating a new one still with Ubuntu 14.04, but this time I want to make things right!

This is the config I want: NGINX + PHP-FPM + PHP 5.6.16 (I'll use PostgreSQL as DB but I can handle that)

Steps I pretend following unless you teach me something better:

  • Install nginx from apt-get install;
  • I'll compile PHP 5.6.16 with the following configure.sh script:

#!/bin/bash

./configure \
    --prefix=/opt/php
    --enable-intl \
    --enable-opcache \
    --enable-mbstring \
    --enable-bcmath \
    --enable-soap \
    --enable-zip \
    --enable-pdo \
    --enable-ftp \
    --enable-cli \
    --enable-inline-optimization \
    --enable-exif \
    --enable-gd-native-ttf \
    --enable-libxml \
    --enable-sockets \
    --enable-calendar \
    --enable-wddx \
    --enable-pcntl \
    --enable-pthreads \
    --with-config-file-path=/etc/php/ \
    --with-config-file-scan-dir=/etc/php/conf.d/ \
    --with-curl \
    --with-pdo-mysql \
    --with-pdo-pgsql \
    --with-pdo-sqlite \
    --with-mcrypt \
    --with-pear \
    --with-openssl \
    --with-iconv \
    --with-mysql \
    --with-mysqli \
    --with-pgsql \
    --with-mssql \
    --with-zlib \
    --with-gd \
    --with-jpeg-dir=/usr \
    --with-gettext \
    --with-xmlrpc \
    --with-xsl \
    --with-tidy \
    --with-pcre-regex \
    --with-mhash \
    --with-kerberos \
    --with-pspell \
    --with-bz2 \
    --with-ldap \
    --with-libdir=lib/i386-linux-gnu \
    --enable-fpm \
    --with-fpm-user=www-data \
    --with-fpm-group=www-data

And now what do I do to make PHP-FPM work?!

I read at php.net that to enable PHP-FPM while compiling PHP you just need to use --enable-fpm , but still got some doubts...

  • Will that actually install PHP-FPM or just enable it?
  • If it just enables , do I still have to apt-get install php5-fpm then?

Show me some knowledge, please!

From PHP 5.3.3,php-fpm is distributed with PHP

  1. --enable-fpm just enable it,because it's a built-in sapi module
  2. you don't need to install it separately again
  3. $YOUR_PHP_INSTALL_DIR/sbin/php-fpm is the FPM executable, just run it,default configuration is listen 127.0.0.1:9000
  1. --enable-fpm will install and enable php-fpm
  2. if you compiled success,don't need apt-get install php5-fpm

but I guess you can't use php-fpm with nginx when you finish your compile,because by default they will not configure by themselves.

php-fpm is a daemon,when a request send to php-fpm,it will response with php processor, and php-fpm listen port use TCP/IP, nginx access php-fpm by fastcgi, that's means you can use multiple version php, and use one nginx server access them.

this is my config files,I hope it can help you

https://github.com/liujin834/php7-configure/tree/master/etc

you can start nginx and php-fpm use a config file

nginx -c /opt/server/etc/nginx/nginx.conf
php-fpm -y /opt/server/etc/php/php-fpm.conf -c /opt/server/etc/php/php.ini

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM