Noob looking for PHP help


#1

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


#2

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.


#3

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


#4

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?


#5

On Sat, Apr 18, 2009 at 10:26 PM, AMP Admin removed_email_address@domain.invalid 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


#6

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!


#7

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


#8

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


#9

Jim you’re a gem. :slight_smile:


#10

На 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


#11

Momchil I. 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


#12

This is a new QA box before we start moving production so there’s no php
yet. :slight_smile:

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


#13

Momchil I. 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 :slight_smile: 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… :slight_smile:

Momchil

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1157,1185#msg-1185


#14

На Sunday 19 April 2009 02:19:03 Jim O. написа:

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 :slight_smile:

/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 :slight_smile: it’s the
freedom
that Unix-like systems give you!

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

Momchil


#15

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


#16

On Sun, Apr 19, 2009 at 10:00 PM, AMP Admin removed_email_address@domain.invalid 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


#17

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


#18

On Sun, Apr 19, 2009 at 11:22 PM, AMP Admin removed_email_address@domain.invalid 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


#19

На Sunday 19 April 2009 18:22:43 AMP Admin написа:

header files: /usr/local/include/php/
PHP CLI man page: /usr/local/man/man1/
To: removed_email_address@domain.invalid
Subject: Re: Noob looking for PHP help

On Sun, Apr 19, 2009 at 10:00 PM, AMP Admin removed_email_address@domain.invalid 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


#20

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!