我做了大约3年的PHP开发人员,我终于把它作为一种爱好,在家里创建了一个Ubuntu 14.04虚拟机,用于开发个人项目和研究新事物
我确实通过apt-get install
一些包配置了Nginx+PHP+PHP-FPM环境,而不是对配置进行一些更改,好吗。。。
但我想走得更远我想编译一个特定的PHP版本,而不是apt-get中php5-fpm附带的版本。。。试了一下,结果让我头疼!由于某些原因,无法使编译后的PHP与PHP-FPM一起工作
我确实遵循了教程并配置了环境,但真的不知道我在做什么,所以现在我正在销毁我的虚拟机,并创建一个仍然使用Ubuntu 14.04的新虚拟机,但这次我想把事情做好
这是我想要的配置:NGINX+PHP-FPM+PHP 5.6.6(我将使用PostgreSQL作为DB,但我可以处理)
步骤我假装如下,除非你教我更好的东西:
- 从apt-get-Install安装nginx
- 我将使用以下
configure.sh
脚本编译PHP 5.6.6:
#!/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
现在我该怎么做才能让PHP-FPM工作呢?!
我在php.net上读到,要在编译php时启用php-FPM,只需要使用--enable-fpm
,但仍然有一些疑问。。。
- 这真的会安装PHP-FPM吗?还是只是启用
- 如果它只是启用,那么我还需要
apt-get install php5-fpm
吗
请给我看看知识!
从PHP 5.3.3开始,PHP fpm与PHP 一起分发
--enable-fpm
只是启用它,因为它是一个内置的sapi模块- 您不需要再次单独安装
$YOUR_PHP_INSTALL_DIR/sbin/php-fpm
是FPM可执行文件,只需运行它,默认配置为侦听127.0.0.1:9000
--enable-fpm
将安装并启用php-fpm- 如果编译成功,则不需要
apt-get install php5-fpm
但我想当你完成编译时,你不能将php-fpm与nginx一起使用,因为默认情况下,它们不会自己配置。
php-fpm是一个守护进程,当请求发送到php-fpm时,它会用php处理器进行响应,php-fpm侦听端口使用TCP/IP,nginx通过fastcgi访问php-fpm,这意味着你可以使用多个版本的php,并使用一个nginx服务器访问它们。
这是我的配置文件,我希望它能帮助你
https://github.com/liujin834/php7-configure/tree/master/etc
您可以使用配置文件启动nginx和php-fpm
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