[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to activate php in apache



François Patte wrote:
> Le 03/12/2013 00:14, Bob Proulx a écrit :
> > François Patte wrote:
> >> I'd like to anable php with apache web server.
> >>
> >> apache2 is installed
> >> php5 is installed.
> >> apache php module is activated
> > 
> > The above is just too vague and ambiguous.  Do you mean this?
> >   apt-get install apache2 libapache2-mod-php5
> 
> Where is the ambiguity?

There are many ways to install PHP and install web servers.  You did
say apache2 and so that part was pretty specific.  But for example
this works quite well too.

  apt-get install apache2 php-fpm

That sets up a FastCGI daemon that handles the PHP interpretation.  An
alternative to having libapache2-mod-php5 handling it.  (This is an
especially popular alternative when coupled with nginx.)  It will
require a small amount of config changes to use it but only a very
small amount.

Also a fully working PHP installation can be had with:

  apt-get install php5-cli

  echo "<?php phpinfo(); ?>" > phpinfo.php
  php ./phpinfo.php
  ...dump from phpinfo...
  php -r 'phpinfo();'
  ...dump from phpinfo...

With that PHP is installed and available for running but that won't
set it up for the web server.  I know PHP programmers who only know
PHP and so use it for everything that others might use Perl, Python,
Ruby, shell or other for doing tasks and cronscripts and everything.

Also because of the modularity of the shared modules it is possible
that someone would install a submodule thinking that it was all that
was needed.  But this will not be enough and would not set it up for
the web.

  apt-get install php5-common

You didn't say therefore I asked so as to be specific about it.

> > If you meant anything else by "activated" please say exactly what you
> > mean.  Because with the above there is no need for 'a2enmod' or any
> > other commands.  It will be available immediately after the above.
> 
> What do you suppose: I am a dumb person trying to run php in an apache
> server without apache and without php?

Now you might tell me that *you* would never do anything like any of
the above.  That is great.  But if you read this mailing list for a
while then you will find that yes people actually will do all kinds of
crazy things!  After a while you find that nothing is safe.  Anything
and everything is possible.  People will do the strangest things.

And so those other people have ruined it for you.  It isn't your
fault.  It is their fault.  But because there are so many other crazy
people doing insane things it means that there is no longer any trust.
Whenever people have told me something but didn't say *exactly* what
they did verbatim and I just plain accepted it at face value I have
almost always found out that I was wrong and that I should have
questioned them further.  I am fifty times burned and therefore twice
shy.  So now I ask.

> I said that because after running a2enmod php5 I got:
> 
> Module php5 already enabled

I suspected that you had run a2enmod/a2dismod because of the
phrasing.  But that meant that it was possible that modules that would
normally be enabled by default would have been disabled.  Because yes
people do that!  So I asked.

Think back...  How many times have someone asked you for help with
something.  And you asked them what did they do?  And they said, "I
didn't do anything!"  And of those times how often did it turn out
that they had actually done something?  I am sure quite often! :-)
I am certain that others reading this will go, yes, many times.

> >> But php is not working...ie.:
> >>
> >> <?

And I see that the problem turned out that you were expecting short
tags to work and those have been discouraged for years.  Glad to see
that the root cause of the problem is solved.  I know you think that
short tags should be on by default but really those are official
"discouraged".

  http://php.net/manual/en/language.basic-syntax.phptags.php
  PHP tags

  When PHP parses a file, it looks for opening and closing tags, which
  are <?php and ?> which tell PHP to start and stop interpreting the
  code between them.  Parsing in this manner allows PHP to be embedded
  in all sorts of different documents, as everything outside of a pair
  of opening and closing tags is ignored by the PHP parser.

  PHP also allows for short open tags <? and ?> (which are discouraged
  because they are only available if enabled with short_open_tag php.ini
  configuration file directive, or if PHP was configured with the
  --enable-short-tags option.

And this is a reasonable discussion of short tags too:

  http://stackoverflow.com/questions/200640/are-php-short-tags-acceptable-to-use

Good stuff in that discussion.

> >> does not work in /var/wwww (with 644 permissions)
> > 
> > How did /var/www get 644 permissions?  That is also incorrect.
> 
> You misunderstood the sentence: the file where the php command is
> written is in /var/www and has 644 permissions... (/var/www has, of
> course, 755 permissions).

Sorry, yes, I misunderstood.

> Re-reading my first message, I can't see any extra w in /var/www !

None the less it is there.  :-)  Here it is in the archive.

  http://lists.debian.org/debian-user/2013/12/msg00076.html

But as I said I assumed it was a typo so didn't comment until the
later discussion.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: