# recommended way to install php/apache2? SOLVED

## Moriah

There are so many packages that show up when I do emerge -s php that its impossible to know where to begin.  I searched for a php howto, but just found tons of old stuff that was to old and too long to wade thru.  A sticky post in this forum, Networking & Security, says that dev-lang/php is the new way to go, but it is masked, so I am instantly distrustful.  

I need to set up a production server to host phpbb and some custom apps I am working on for a client.  I am learning php in the process, but I am beginning to think that installing and administering is the real hurdle to overcome.  

I am a very experienced programmer with 30+ years of professional software development, 17 years of unix, 13 years of linux, and 2 years of gentoo.  Learning php should not be a big problem.  My problem is not knowing how to get a working php system up and running.  

I had php working last week, but apache2 complained when I started it that my php was not built for threads, and my apache2 was, but it started anyway, and I was able to get the phpinfo() script to work after a little jousting with some configuration files.  Then a few days ago I did an emerge --sync followed by an emerge --update system and it upgraded my apache2 and after that, php would not start -- still complaining about the thread thing.  So I unmerged and re-emerged php (dev-php/mod_php and dev-php/php) and restarted apache.  Now php does not work at all, but apache no longer complains about the thread thing.  So I looked at my configuration files, and everything is changed!?!?!?!?!?!   :Evil or Very Mad: 

I have backups on my backup server, so it is easy to look back a few days and see what was there when it sortof worked, but I am clueless what I am doing.  I did not read the sticky post on php-4 and php-5 until tonight.  When I installed php last week, I just looked over the vast plethora of choices that emerge -s php offered, and decided that based on the stability the listing showed, and my general knowledge of portage, that dev-php/mod_php and dev-php/php must certainly be what I wanted.  Now I really do not know.

Isn't there an up to date howto on how to install a working stable un-masked production php system?  I already have apache2 working, and mysql seems to be working as well.  Now if I could only get php working (again) I would be ready to start this new project.

Can somebody please tell me what to emerge and how to configure it?

Thanks!    :Crying or Very sad: 

----------

## RlC

sorry i didn´t read your whole post   :Smile: 

but have you looked at  Gentoo Wiki?

----------

## Moriah

My problem is too many choices.  I need information that is  up to date, not almost a year old, but using the recomendations in force now.  There are zillions of pages on how to do it -- all different, and written at different times.  What I need is current best practice information on setting up a production php under apache2 under gentoo.

For a package that is supposedly so popular, why is it so hard to get current information on this?    :Mad: 

----------

## d11wtq

Do you know much PHP?   :Smile:   I admin a popular PHP forum... there's loads of stuff you won't need by default.

I know php5 is masked but I've never had issues with it.

emerge apache first, then emerge the latest php5... as for the USE options when installing PHP... I'll attempt to list the most used and keep it simple.

You need to include apache or apache2 depending what HTTP server you used (for the module setup)

You'll almost certainly want mysql including

You'll want GD if you're playing with graphics much

Exif -- same as above

pgsql ... speaks for itself  :Smile:   No harm to include but most people prefer MySQL

CGI ... I'd leave it out... it's less secure

CLI ... useful for CRON scripts but not required

FTP ... if you want to connect to FTP servers in your scripts (needed for EasyMod on phpBB AFAIK)

MSSQL -- *cough*, if you use a M$ SQL server

You can leave out the ncurses and realine unless you'll be writing CLI scripts

SimpleXML... very popular, include it anyway

SOAP

Sockets for doing socket stuff (not needed but fun to play with)

Zip ... for the Gzip functions... include it

That should give you a fairly standard apache/php5 installation.  It should also set up apache's httpd.conf for you so that you don't have to make changes to get it working.

----------

## Moriah

Wow!  Thanks!    :Exclamation:   :Exclamation:   :Exclamation: 

That's the kind of answer I like to see.  

No, I have never used php before, but I am a very experienced programmer.  I was impressed with your obvious approval of pgsql.  I have installed mysql on my web server machine, but I would prefer to use pgsql if it will work as well with php -- if for no other reason that the licensine agreement is better.  Also, pgsql has been full ACID for ages now, and mysql is still on the catch up curve.

I will try your suggestions and see how it goes.  I will post back her after I have had a chance to implement all the above in your post.

I was skeptical of php5 since it was masked, but since I am just starting php, no sense in starting with an almost out of date implementation if the new one is really ready for prime time.

Thanks again!    :Very Happy: 

----------

## d11wtq

I'm just going to make a blatant plug here   :Shocked:   but you might want to check out the forum too:

It's very active and well established and the community work well together.

http://forums.devnetwork.net/  (I'm d11wtq over there too)

----------

## Moriah

I do already have my apache2 server up and running, and it has been for a long time.  Due to some legacy issues, not all the stuff is in the usual place.  I hope your approach will not break my non-standard apache2 config....   :Rolling Eyes: 

----------

## d11wtq

What's in non-standard locations?  Did you fetch it from portage?

If you didn't install it from portage then you'll have to go a slightly different root or portage will try to install it again.

EDIT | I'm off to bed but I'll check this thread in the morning.  If your entire apache2 installation is in a different place than /usr/local then drop the apache2 part and try doing this:

```

USE="

mysql

gd

-apache

-apache2

curl

ftp

exif

imap

mysql

postgres

simplexml

soap

sockets

zip" \

ACCEPT_KEYWORDS="~x86" \

EXTRA_ECONF="--with-apxs2=/path/to/apache2/binary/apxs" \

emerge -pv =dev-lang/php-5.1.1
```

But I don't know what exactly is different with your setup (and EXTRA_ECONF is sometimes ignored).Last edited by d11wtq on Tue Jan 17, 2006 1:42 am; edited 1 time in total

----------

## Moriah

No, its a standard emerge from portage.  The divergent part has to do with where the apache root html directory is, the cgi-bin directory, etc.  This was because of previous installations from older apache, and even the NSCA and CERN web servers way back when.  The thing has evolved over time, and like a rambling ranch house, I just keep adding on to it.  If I had nothing better to do, I would tear it all down and set it up according to the latest recomendations, but the modules and stuff are all in standfard places.

----------

## d11wtq

Ah OK.... I was editting my last post whilst you sent that message  :Smile: 

Ignore my edit in which case and go ahead since the DocumentRoot is nothing that will cause issues.  Providing the binaries are in the correct places, along with the modules and the config file it should be fine  :Smile: 

----------

## Moriah

Great!  I will do the installs hopefully tonight and tomorow, and then post back here.

I will also check out your forum.    :Very Happy: 

----------

## llongi

The recommended way to install Apache+PHP on Gentoo at the moment is to use the stable Apache (latest release 2.0.55) and to use dev-lang/php to provide PHP support. dev-lang/php offers you the possibility to install both PHP4 and PHP5, also please see http://svn.gnqs.org/projects/gentoo-php-overlay/file/docs/php-upgrading.html?format=raw as a guide, it will surely help you in understanding what dev-lang/php does and how PHP in Gentoo works.

Also, when you emerge dev-lang/php, don't forget the "session" and "pcre" USE flags, those are used by 98% of the PHP scripts out there, so it's best to enable them.

----------

## Moriah

If dev-lang/php is the recommended way, then why is it masked?  That doesn't make sense.  If it is the recommended way, then take the mask off.  That is the package I would have started with if it had not been masked.  :Evil or Very Mad: 

----------

## llongi

It's only in the ~ARCH (unstable) tree, just add the correct entries to your package.keywords...

It's still in the unstable tree... Because it's not marked as stable yet!  :Smile:  It's ready to be stabled, but there are a few requirements to be met (X days in Portage, etc.) before a package can be stabled, we plan to open the bugs requesting stable keywording today or tomorrow anyway, so it should be soon.

----------

## Moriah

This is sort of off topic, at least regarding php, but...

What about jsp and tomcat?  What is the recommended setup there?  Can php and jsp co-exist on the same apache installation?  I have another project after the current one that wants to use java-swing on the client side, so it would make esthetic sense to do the server side with jsp instead of php...

----------

