Forum: NGINX Noob looking for PHP help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fe1cbce6b6b3fa8f72c740c570774ede?d=identicon&s=25 AMP Admin (Guest)
on 2009-04-18 16:08
(Received via mailing list)
i've been trying to wean myself off cpanel/whm and now apache for a long
time. i'm down to just apache so it's time to take the final step... i
hope.

i think i have a basic understanding on how to setup nginx and mysql
after
reading this thread and the nginx wiki but the php stuff is bothering
me.

I really don't have time to baby sit the updates everyday or week so I
just
want to set a crontab to run yum install -y or something.



Can someone help me understand what I need to install to get php to work
with nginx?



i got the following google style. can someone give me a better
understanding
of what i need and don't need here?

yum install php-cgi php-cli php-mysql php-gd php-imap php-ldap php-odbc
php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand
php-magpierss
php-mapserver php-mbstring php-mcrypt php-mhash php-mssql php-shout
php-snmp
php-soap php-tidy
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-04-18 16:56
> Can someone help me understand what I need to install to get php to work
> with nginx?

Most people install php-fpm to work with Nginx. I tried it and got
PhpMyAdmin running, so I guess it's a good solution.
F28f13d5607639b47a8ce7cf9b71a3cf?d=identicon&s=25 Nuno Magalhães (Guest)
on 2009-04-18 17:07
(Received via mailing list)
Hi,

> yum install php-cgi php-cli php-mysql php-gd php-imap php-ldap php-odbc
> php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss
> php-mapserver php-mbstring php-mcrypt php-mhash php-mssql php-shout php-snmp
> php-soap php-tidy

php-cgi oughta be enough (at least on Debian), the trick si to enable
it to start on boot, but if you use update-rc.d on you script it'll
do. Now make sure you fiddle with /etc/nginx/nginx.conf, there's a
part that's comented out about fast-cgi: configure that - pay
attention to the port the cgi server will be lsitening on, then HUP
nginx and give it a try.

HTH,
Nuno Magalhães
Fe1cbce6b6b3fa8f72c740c570774ede?d=identicon&s=25 AMP Admin (Guest)
on 2009-04-18 17:33
(Received via mailing list)
I keep reading that php-fpm is the best for large busy sites.  Have you
heard the same?

If so I think I have to install php and php-fpm manually but I'm not
sure if that's the best option because how would we keep it up to date?
Who has time to babysit new versions and then recompile?

Any suggestions?
96dfd0f0a8399d3b03feba1e6a562e0a?d=identicon&s=25 Edho P Arief (Guest)
on 2009-04-18 17:40
(Received via mailing list)
On Sat, Apr 18, 2009 at 10:26 PM, AMP Admin <admin@ampprod.com> wrote:
> I keep reading that php-fpm is the best for large busy sites.  Have you heard the same?
>
> If so I think I have to install php and php-fpm manually but I'm not sure if that's the 
best option because how would we keep it up to date?  Who has time to babysit new 
versions and then recompile?
>
> Any suggestions?
>
>

it's not like new version of php is released every other months

there's spawn-fcgi if you don't like compiling php from source
Fe1cbce6b6b3fa8f72c740c570774ede?d=identicon&s=25 AMP Admin (Guest)
on 2009-04-19 11:19
(Received via mailing list)
Ouch Jim. Lol

I see your point.  I'm trying to get away from cPanel the best I can.

Ok, I'm going to compile it and give it a go!

One last thing... suggestions on what I should include when compiling
php? Like is ' --enable-fastcgi --enable-fpm' all I need?

Thanks!
2e321cc0efe9422d37165e922298494e?d=identicon&s=25 Cliff Wells (Guest)
on 2009-04-19 11:43
(Received via mailing list)
On Sat, 2009-04-18 at 11:08 -0500, AMP Admin wrote:
> Ouch Jim. Lol
>
> I see your point.  I'm trying to get away from cPanel the best I can.
>
> Ok, I'm going to compile it and give it a go!
>
> One last thing... suggestions on what I should include when compiling
> php? Like is ' --enable-fastcgi --enable-fpm' all I need?

You should probably check to see what options your current version of
php is compiled with (php -i | grep "Configure Command =>") and make
sure you have at least those options enabled.

Cliff
2c6f80fff253635f12c249ef4f116796?d=identicon&s=25 Jim Ohlstein (Guest)
on 2009-04-19 11:46
(Received via mailing list)
First, you need to download php and the patch, then apply the patch.
There is a link to a working patch for php 5.2.9 in the php-fpm section
of http://forum.nginx.org. At least it works for me using both 32 and 64
bit versions of CentOS 5.2.

I'm using my phone right now so I'm not sure, but if I recall correctly
the file is named patch.php-fpm. Assuming it is (and change the name if
it is something else), place it and the php tarball in /usr/local/src.
Unpack the php tarball and you should have a directory called php-5.2.9.

To apply the patch run:

#cat patch.php-fpm | patch -d php-5.2.9 -p1

I use the following configuration options for 32 bit CentOS 5.2:

'--enable-fastcgi' '--enable-fpm' '--enable-force-cgi-redirect'
'--with-mcrypt' '--with-zlib' '--enable-mbstring' '--with-openssl'
'--with-mysql' '--with-mysqli' '--with-mysql-sock' '--with-gd'
'--enable-gd-native-ttf' '--with-bz2' '--with-curl'
'--with-freetype-dir=/usr' '--with-jpeg-dir=/usr' '--with-pspell'
'--with-sqlite' '--enable-pdo' '--enable-reflection' '--with-gettext'
'--enable-soap' '--enable-dom' '--with-png-dir' '--with-mhash'
'--with-mcrypt'

You may not need all of them.

Jim

Sent from my Verizon Wireless BlackBerry
Fe1cbce6b6b3fa8f72c740c570774ede?d=identicon&s=25 AMP Admin (Guest)
on 2009-04-19 12:12
(Received via mailing list)
Jim you're a gem. :)
Fe1cbce6b6b3fa8f72c740c570774ede?d=identicon&s=25 AMP Admin (Guest)
on 2009-04-19 12:22
(Received via mailing list)
This is a new QA box before we start moving production so there's no php
yet. :)

Thanks for your help too, Cliff!

I'm messing with it now so I'm sure you'll see more messages from me
soon.
haha
Dcbfa90cb4fb546e8f076ab1460a9056?d=identicon&s=25 Momchil Ivanov (Guest)
on 2009-04-19 18:36
(Received via mailing list)
На Saturday 18 April 2009 19:02:19 AMP Admin написа:
> To apply the patch run:
>
> #cat patch.php-fpm | patch -d php-5.2.9 -p1

you don't really need cat here:

patch -d php-5.2.9 -p1 < patch.php-fpm

> '--with-mcrypt'
You should also use --prefix=/usr/local/php-fpm-5.2.9 or something else,
just
to have it in a separate directory, otherwise you mess up your system

Momchil
2974d09ac2541e892966b762aad84943?d=identicon&s=25 Jim Ohlstein (Guest)
on 2009-04-19 19:29
(Received via mailing list)
Momchil Ivanov Wrote:
-------------------------------------------------------
> На Saturday 18 April 2009 19:02:19 AMP Admin
> написа:
> > To apply the patch run:
> >
> > #cat patch.php-fpm | patch -d php-5.2.9 -p1
>
> you don't really need cat here:
>
> patch -d php-5.2.9 -p1 < patch.php-fpm

I believe the result is the same.

Correct me if I am wrong.

> '--with-mysql-sock' '--with-gd'
> You should also use
> --prefix=/usr/local/php-fpm-5.2.9 or something
> else, just
> to have it in a separate directory, otherwise you
> mess up your system

I specifically stated the OS for which these instructions were meant
(CentOS 5.2 - 32 bit). Following them to the letter, php and php-cgi
will be installed in /usr/local/bin/ and php-fpm in /usr/local/sbin/.
php-fpm.conf will be in /usr/local/etc/. php.ini will need to be in
/usr/local/lib/.

In a stock CentOS php is in /usr/bin/ and php.ini in /etc/. I have done
it this way now in dozens of servers and it has not "messed up" any
systems. I use different options in 64 bit CenOS but they amount to the
same basic thing.

>
> Momchil

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1157,1180#msg-1180
Dcbfa90cb4fb546e8f076ab1460a9056?d=identicon&s=25 Momchil Ivanov (Guest)
on 2009-04-19 23:12
(Received via mailing list)
На Sunday 19 April 2009 02:19:03 Jim Ohlstein написа:
> > you don't really need cat here:
^^^
> >
> > patch -d php-5.2.9 -p1 < patch.php-fpm
>
> I believe the result is the same.
>
> Correct me if I am wrong.

yes it is the same, but that is not the point, see above :)

> /usr/local/lib/.
>
> In a stock CentOS php is in /usr/bin/ and php.ini in /etc/. I have done it
> this way now in dozens of servers and it has not "messed up" any systems. I
> use different options in 64 bit CenOS but they amount to the same basic
> thing.

The advantage of having php in a separate directory is that you can
delete it
before installing a new version. Instaling everything from source
in /usr/local or /usr or wherever leaves you no chance for
deinstallation,
because you don't know what files were installed and where. When you are
going to upgrade your php installation, the new one will overwrite some
files
(tha files that it installs) but some files from the old installation
might
be left (executables, libs, headers, etc....). At this point your system
is
already messed up and might later need a new installation! Therefore on
most
systems there are facilities called package/port managers that help you
safely install and deinstall stuff without leaving any remains. Remains
might
later break other applications that you want to install. It's a general
practice for maintaining your system clean. Moreover on different
systems
stuffs goes in different places and in new app versions default paths
might
change, therefore if you want to have a maintainable system you must
always
specify a prefix directory when installing from source.

It seems that you need to inform yourself better:
 * CentOS is not an OS, it is a GNU/Linux distribution, which is
explicitly
stated on [1]: "CentOS is an Enterprise-class Linux Distribution derived
from
sources freely provided to the public by a prominent North American
Enterprise Linux vendor."
 * there is no stock php, but php that you might install via a package,
moreover it is common practice from GNU/Linux distros to put apps in
/usr and
confs in /etc


But at the end, you ca do with your systems what you want :) it's the
freedom
that Unix-like systems give you!

1: http://www.centos.org/


Momchil
2974d09ac2541e892966b762aad84943?d=identicon&s=25 Jim Ohlstein (Guest)
on 2009-04-20 09:14
(Received via mailing list)
Momchil Ivanov Wrote:
-------------------------------------------------------
> > > написа:
> >
> you
> > /usr/local/lib/.
> directory is that you can delete it
> be left (executables, libs, headers, etc....). At
> Moreover on different systems
> stated on [1]: "CentOS is an Enterprise-class
>
> But at the end, you ca do with your systems what
> you want :) it's the freedom
> that Unix-like systems give you!
>
> 1: http://www.centos.org/

It's pointless to carry out this discussion. Everything you say is
"technically" correct. However, nothing I have said is "technically"
wrong.

We have an expression in English that goes "There is more than one way
to skin a cat". There is probably something similar in your language.

I will leave this discussion with the following:

I do know the difference between a distribution and an operating system.
I could have been clearer in my choice of terms. So could the people who
created the CentOS project. After all, looking at the link that you
provided, a page that I have visited many times, it occurs to me that
you left out the words at the VERY top of the page, ones that occur
before the section that you quoted. Perhaps this was an oversight on
your part?

"CentOS:
The Community ENTerprise Operating System"

Seems that they are as confused as I am... :)

>
>
> Momchil

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1157,1185#msg-1185
Fe1cbce6b6b3fa8f72c740c570774ede?d=identicon&s=25 AMP Admin (Guest)
on 2009-04-20 10:12
(Received via mailing list)
I don't really know what --prefix=/usr/local/php-fpm-5.2.9 accomplishes.

Will that move the default locating of php.ini or anything?

What's the best practice here.  Right now this is on a QA box but will
eventually move into production and it's a very busy site so maintenance
times have to be minimal when upgrading or making future changes.

I ended up going with the following because we want only what's needed
for our webapp but it's not too late to change it.

./configure --disable-all --enable-fastcgi --enable-fpm --with-mysqli
--with-gd --with-mysql --with-freetype-dir=/usr/include/freetype2
--enable-shmop --enable-sysvsem --enable-sysvshm  --enable-libxml
--with-pcre-regex --enable-spl --enable-session --enable-xml
--enable-mbstring --with-mcrypt --enable-force-cgi-redirect
96dfd0f0a8399d3b03feba1e6a562e0a?d=identicon&s=25 Edho P Arief (Guest)
on 2009-04-20 10:58
(Received via mailing list)
On Sun, Apr 19, 2009 at 10:00 PM, AMP Admin <admin@ampprod.com> wrote:
> I don't really know what --prefix=/usr/local/php-fpm-5.2.9 accomplishes.
>
> Will that move the default locating of php.ini or anything?
>

it'll allow you to remove and update php-fpm with ease. The location
is relative to prefix, iirc
Fe1cbce6b6b3fa8f72c740c570774ede?d=identicon&s=25 AMP Admin (Guest)
on 2009-04-20 11:30
(Received via mailing list)
So is the following what would change?

The default is:
PHP SAPI module:       cgi
PHP CGI binary:    /usr/local/bin/
FPM config:            /usr/local/etc/php-fpm.conf
init.d script:         /usr/local/sbin/php-fpm
PHP CLI binary:        /usr/local/bin/
PHP CLI man page:      /usr/local/man/man1/
build environment:     /usr/local/lib/php/build/
header files:          /usr/local/include/php/
helper programs:       /usr/local/bin/
PHP         /usr/local/lib/php/
PHP.INI      /usr/local/lib/php.ini

If we add --prefix=/usr/local/lib/php-fpm-5.2.9 the new installation
will look like:
PHP SAPI module:       cgi
PHP CGI binary:    /usr/local/bin/
FPM config:            /usr/local/etc/php-fpm.conf
init.d script:         /usr/local/sbin/php-fpm
PHP CLI binary:        /usr/local/bin/
PHP CLI man page:      /usr/local/man/man1/
build environment:     /usr/local/lib/php-fpm-5.2.9/build/
header files:          /usr/local/include/php/
helper programs:       /usr/local/bin/
PHP         /usr/local/lib/php-fpm-5.2.9/
PHP.INI      /usr/local/lib/php.ini
Dcbfa90cb4fb546e8f076ab1460a9056?d=identicon&s=25 Momchil Ivanov (Guest)
on 2009-04-20 11:57
(Received via mailing list)
На Sunday 19 April 2009 18:22:43 AMP Admin написа:
> header files:          /usr/local/include/php/
> PHP CLI man page:      /usr/local/man/man1/
> To: nginx@sysoev.ru
> Subject: Re: Noob looking for PHP help
>
> On Sun, Apr 19, 2009 at 10:00 PM, AMP Admin <admin@ampprod.com> wrote:
> > I don't really know what --prefix=/usr/local/php-fpm-5.2.9 accomplishes.
> >
> > Will that move the default locating of php.ini or anything?
>
> it'll allow you to remove and update php-fpm with ease. The location
> is relative to prefix, iirc

You can execute "./configure --help" to see what options are available
and
what they do. There is a section concerning paths where different parts
of
the program are installed:

Directory and file names:
  --prefix=PREFIX         install architecture-independent files in
PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in
EPREFIX
                          [same as prefix]
  --bindir=DIR            user executables in DIR [EPREFIX/bin]
  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
  --datadir=DIR           read-only architecture-independent data in DIR
                          [PREFIX/share]
  --sysconfdir=DIR        read-only single-machine data in DIR
[PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data in
DIR
                          [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data in DIR
[PREFIX/var]
  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
  --includedir=DIR        C header files in DIR [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc in DIR
[/usr/include]
  --infodir=DIR           info documentation in DIR [PREFIX/info]
  --mandir=DIR            man documentation in DIR [PREFIX/man]
  --srcdir=DIR            find the sources in DIR [configure dir or ..]
  --program-prefix=PREFIX prepend PREFIX to installed program names
  --program-suffix=SUFFIX append SUFFIX to installed program names
  --program-transform-name=PROGRAM
                          run sed PROGRAM on installed program names

If you are using --prefix=/foo, all the files that your software
installs will
be installed under /foo, which in most cases gives you the following
structure /foo/bin /foo/etc /foo/lib .............., so your php.ini
will go
in /foo/lib/ if you don't change that with some of the options above.
You can
also see the defaults (prefix=/usr/local for the example above). You
must
also consider that these defaults might change with new versions, so you
must
check what is changed in every new version or be on the safe side
specifying
the options yourself and have it allways installed where and as you
wish.

This is common for all software that comes with some kind of "configure"
script.

Momchil
96dfd0f0a8399d3b03feba1e6a562e0a?d=identicon&s=25 Edho P Arief (Guest)
on 2009-04-20 13:19
(Received via mailing list)
On Sun, Apr 19, 2009 at 11:22 PM, AMP Admin <admin@ampprod.com> wrote:
> header files:          /usr/local/include/php/
> PHP CLI man page:      /usr/local/man/man1/
> build environment:     /usr/local/lib/php-fpm-5.2.9/build/
> header files:          /usr/local/include/php/
> helper programs:       /usr/local/bin/
> PHP                             /usr/local/lib/php-fpm-5.2.9/
> PHP.INI                 /usr/local/lib/php.ini
>

prefix will replace all /usr/local to $prefix
Fe1cbce6b6b3fa8f72c740c570774ede?d=identicon&s=25 AMP Admin (Guest)
on 2009-04-20 15:05
(Received via mailing list)
I got it up and running.  Our QA box is now cPanel/WHM & Apache free!
We'll be testing this week and hopefully be moving to production soon.

Thanks everyone for your help!
This topic is locked and can not be replied to.