# Web Server How-To (Apache2 + mod_php + mysql)

## khel

I couldn't find any step-by-step instructions on setting up a webserver, so, after lurking on this forum for a while, I decided to share my experience on the subject. Anyway, to make the long story short, that's what I did to make Apache2/mod_php/mysql combo work to suite my needs    :Smile: 

edit /etc/make.conf and add 

ACCEPT_KEYWORDS="~x86" 

USE="-X -gtk -gnome -alsa -qt -qtmt -pdflib mysql apache2 pam ssl"

and don't forget to run env-update after changing the make.conf  :Smile: 

emerge mysql

rc-update add mysqld default

emerge netpbm (image manipulation package required by Gallery)

emerge apache

rc-update add apache2 default

then

emerge mod_php

emerge clean

edit /etc/conf.d/apache2 and add this line 

APACHE_OPTS="-D SSL -D PHP4"

edit /etc/apache2/conf/apache2.conf  and add this line

LoadModule php4_module       /usr/lib/apache2-extramodules/libphp4.so

then restart apache

/etc/init.d/apache2 -k restart

p.s. If you change "DocumentRoot" in apache2.conf, you'll need to change it in commonapahche2.conf as well. 

Look for 

###This should be changed to whatever you set Document root to. 

### 

<Directory /home/httpd/htdocs> 

And in /etc/apache2/conf/modules.d/41_mod_ssl.default-vhost.conf  for SSL to work

So far it works just fine for me, but time will show how stable and bug free it is  :Smile: 

If you have any comment/suggestions - feel free to post  :Smile: 

I hope this will be useful at leas to somebody.Last edited by khel on Tue Apr 08, 2003 2:56 pm; edited 7 times in total

----------

## digitalnick

kind of hard to write a specific guide for a webserver ... for example i just emerge apache dont usually have a mysql backend sometimes emerge php if its needed

----------

## slartibartfasz

i would go without xinetd and emerge mysql before (!) apache - also make sure that the useflags for mysql, apache2, php and the like are correct - its difficult to write a gentoo specific doc for this - as people set up their servers very differently depending on their needs...

----------

## Buzzz

 *khel wrote:*   

> 
> 
> I'm not new to linux but really new to Gentoo  anyway, for example what steps should be taken after finishing with Installation guide?
> 
> 1. emerge xinetd  (any use variables??)
> ...

 

I don't use xinetd, I think it is only confusing. All access control can be done in apache itself or with your firewall. I just like the stand-alone way of doing things.

----------

## khel

Just updated my original post. I hope it makes a little bit more sense now  :Smile:    ... and following your example, decided to try running my system without xinetd (habits are so difficult to change  :Smile:   ).

Thanks

----------

## WarMachine

Thanks I found this useful since I'm considering re-doing my gentoo machine.  It's still on the old GCC 2.9.something...that's another story.  As of now I didn't use emerge to install all these things, this would help a lot.

Would there be anything different if one was to use the latest stable version of apache instead of apache 2?

----------

## slartibartfasz

 *khel wrote:*   

> Though I already had these USE flags in make.conf, mod_php was still showing X as a dependency   , to fix this I ran
> 
> export USE="-X -gtk -gnome -alsa -qt -qtmt -pdflib mysql apache2 pam ssl"
> 
> 

 

perhaps u forgot to run env-update after changing the make.conf...

----------

## WarMachine

I've tried to follow this except using the latest (1.3.27) version of apache.  Here's the result:

My ssl and php are not working, apache (with the exception of those two) is.

 *Quote:*   

> root@localhost sbin # ./apachectl configtest
> 
> [Sun Mar  9 08:05:06 2003] [alert] apache: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
> 
> Syntax OK
> ...

 

Here are my USE flags

 *Quote:*   

> USE="mysql apache mod_ssl mod_php -java"
> 
> 

 

----------

## khel

 *WarMachine wrote:*   

> I've tried to follow this except using the latest (1.3.27) version of apache.  

 

I didn't install apache 1.3.27 on my gentoo box, but you can try following the instructions in  Desktop Configuration Guide

----------

## WarMachine

There's no real difference between that and these instructions except for these 2 lines

# ebuild /var/db/pkg/dev-php/mod_php-4.2.2-r1/mod_php-4.2.2-r1.ebuild config

# ebuild /var/db/pkg/net-www/mod_ssl-2.8.10/mod_ssl-2.8.10.ebuild config

these print and you're instructed to do them after you emerge each mod_php and mod_ssl anyway  :\

----------

## WarMachine

I gave up and decided to use apache 2 

although I can't get ssl working right and when I tried to turn it on in the phpBB (what I'm using the webserver+database for) I totally messed it up, whatever I'll figure it out all in due time

----------

## WarMachine

I've found I need to add -java to my USE to get mod_php to work correctly.  If I don't have it there I get an error on configure.

----------

## tgoodaire

I like using xinetd for everything for several reasons. It starts and stops my servers for me as they are needed, so they're not sitting there taking up my RAM when they're rarely used. Also, there is much better access control and logging than what's in most standalone servers. It's not too hard to configure either. If you can figure out how to configure apache, xinetd should be a breeze.  :Smile: 

----------

## tabascal1

I am an newbie to gentoo.

I want to install apache 2.0.45

I am using 1.4.rc3

Though my USE='apache2"

Whenever I am doing emrge apache it installs apache 1.3.27.r3 

If simply emerge /usr/portage/../apache 2.0.45 then after the installation it says apachectl not found

As a result I have to first installed apache 1.3 and apache 2

After this emerge mod_php and edit apache to -D PHP as perthe instruction on the screen. But PHP does not work.

Please help

----------

## mxc

Hi All,

I have emerged apache2 and php4. I have checked the steps as outlined by khel in the first post and all seems ok.

I have my php .so file in /etc/apache2/extramodules.

When I run apache2 start I get the following error

Syntax error on line 57 of /etc/apache2/conf/apache2.conf:

Cannot load /etc/apache2/extramodules/libphp4.so into server: libpq.so.2: cannot open shared object file: No such file or dir

How do I fix this? I know it may be simple to some of you but I am struggling a bit. I need to get to know php/apache/postgres to get a piece of software I want to evaluate, i.e tutos, working.

Thanks

Mark

Edit ****** Ok I have found a libpq.so.3 on my system. How do I edit php4 to use this instead of the .2 version?

----------

## Pots

I think

APACHE_OPTS="-D SSL -D PHP4" 

should be 

APACHE2_OPTS="-D SSL -D PHP4"

----------

## d0wn_under

I get the same problem with apache  1.3.27-r3...

 * Starting apache...

Syntax error on line 21 of /etc/apache/conf/apache.conf:

Cannot load /etc/apache/extramodules/libphp4.so into server: libpq.so.2: cannot open shared object file: No such file or directory                        [ !! ]

For a similar, but different problem, some people have suggested  doing the following

export LDFLAGS='-lstdc++'

emerge sablotron

but it didn't work for me. apache does work if I take out php4 from the config files, but that doesn't help  :Sad: 

Anyone any ideas? 

Robin

----------

## utabintarbo

 *tabascal1 wrote:*   

> ...
> 
> I want to install apache 2.0.45
> 
> ...
> ...

 

I believe this particular bit might help:

 *khel wrote:*   

> ...
> 
> edit /etc/make.conf and add 
> 
> ACCEPT_KEYWORDS="~x86" 
> ...

 

IIRC, the "~86" keyword allows masked ebuilds to be included. But it has been many moons, so check for yourself.

Bob

----------

## nepenthe

 *Quote:*   

> Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName 

  having same error....

*resolved, to an extent*

strange I edit /etc/hostname change it to nep.servehttp.com

and then do 

```
hostname nep.serve.httpcom
```

 and it works.

But after a restart it have to do 

```
hostname nep.servehttp.com
```

[/code]

again... hmmmLast edited by nepenthe on Fri May 02, 2003 2:17 am; edited 1 time in total

----------

## nepenthe

Anyone know how to setup directory browsing, or indexing with apache2?

----------

## ggelln

thanks for this post it has helped me out  :Smile: 

question, what is the difference between

"-D PHP" and "-D PHP4"

ah see a spatering of both when I search.

Gabriel

----------

## mta

I tried so many combinations of stuff to get apache 1.3 working, with no luck.  used this tutorial for apache2 which helped a lot, thanks  :Smile: 

For me it didn't work first time, I had to make these changes:

-java in USE, otherwise apache wouldn't compile

these 4 lines in /etc/apache2/conf/apache2.conf:

LoadModule php4_module /usr/lib/apache2-extramodules/libphp4.so

LoadModule ssl_module /usr/lib/apache2-extramodules/mod_ssl.so

Include  conf/modules.d/40_mod_ssl.conf

Include  conf/modules.d/41_mod_ssl.default-vhost.conf

----------

## chatgris

 *mxc wrote:*   

> Hi All,
> 
> I have emerged apache2 and php4. I have checked the steps as outlined by khel in the first post and all seems ok.
> 
> I have my php .so file in /etc/apache2/extramodules.
> ...

 

libpq.so.2 is postgres interface..

Either you need to install postgres, or compile php with -postgresql

hope that helps.

----------

## Decode

```
# emerge mysql

# rc-update add mysqld default

* /sbin/rc-update: /etc/init.d/mysqld not found; aborting.
```

I'm not quite sure what to do here.  I recompiled mysql twice and same error.

mysql version: 4.0.13

----------

## nepenthe

what about trying

```
rc-update add mysql defaul
```

I think when I had setup mysql the init script was called mysql not mysqld

Just a thought =]

~nep

----------

## Decode

I just found it...

I guess I should try LOOKING a little.

Thanks nepenthe.

Decode

----------

## nepenthe

Its all good...I've made 5 billion stupid mistakes... Just glad I could help.

----------

## BlackDuck

khel,

Thanks for this How-to. I have been following instructions and started "emerge mysql". Part 1 of 9 has completed successfully but Part 2 of 9 has failed. Part 2 is trying to emerge dev-perl/Net-Daemon-0.37 but can't locate File/Spec.pm in @INC at /usr/lib/perl5/5.8.0/ExtUtils/Liblist.pm line 6.

Compilation aborted at /usr/lib/perl5/5.8.0/ExtUtils/Liblist.pm line 6.

Any thoughts or suggestions what I should do next?

Thanx.  :Confused: 

----------

## nepenthe

just a thought but try re-emerging perl

hope it helps =]

----------

## vulcan_

i found this post a good help .. even tho it is Apache 1.37 that I am installing at the moment.

A few things can be done a little more easily:

the LoadModule lines can take advantage of the fact that that installation that  emerge does puts links into /etc/apache that point to /usr/lib/apache etc.  Thus

```

LoadModule php4_module     extramodules/libphp4.so

LoadModule ssl_module        extramodules/libssl.so

LoadModule gzip_module      extramodules/mod_gzip.so

```

works and is slightly more robust than the absolute paths proposed.

the comments in the apache.conf file warn that you must update the AddModule section that follows the LoadModule items .. and the docs back this up. So I added

```

AddModule mod_php4.c

AddModule mod_ssl.c

AddModule mod_gzip.c

```

but this does not work as Apache cannot find the needed .c files that give the intended module identifiers (as mentioned in the apache docs). So either find the .c files and update these lines or forget it and comment them out.

MTA proposed to put this line into apache.conf

```
Include conf/modules.d/41_mod_ssl.default-vhost.conf
```

but that should be

```
Include conf/ssl/ssl.default-vhost.conf
```

now. I guess the installation has changed since MTA posted.

that is all that I found as of time of writing

----------

## ak

Great HOW-TO! Thanks a lot!

May I suggest adding the following at the end of apache2.conf file:

```

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

```

This way php scripts will be executed properly  :Smile: 

Best Regards,

ak

----------

## ak

Also, the following line is not needed (php 4.3.2 + apache 2.0.47) 

```

LoadModule php4_module /usr/lib/apache2-extramodules/libphp4.so

```

Otherwise, it complains at boot that PHP is already loaded (just a warning msg)

Best Regards,

ak

----------

## WarMachine

 *ak wrote:*   

> Great HOW-TO! Thanks a lot!
> 
> May I suggest adding the following at the end of apache2.conf file:
> 
> ```
> ...

 

Just out of curiosity, without this, how are they executed improperly?  The only php thing on my site is phpBB and I haven't experienced any problem without those lines.

----------

## aridhol

Maybe this should be moved to Documentation Tips and Tricks?

----------

## Decode

Hello;

I've been reading some threads on installing mail system for allowing PHP Mail() to work.

This thread recommends setting up qmail for it's quick/easy config.

https://forums.gentoo.org/viewtopic.php?t=25077&highlight=php+email

And a thread on QMail configuration:

https://forums.gentoo.org/viewtopic.php?t=3622&highlight=setup+qmail

I know there's alternatives (Sendmail, etc) but I'm going to try sendmail for this simple demo-server.  If this was production, I might try something beefier.

Decode

Note:  Let me expound on what I was doing and a frustration I overcame.

The server I am setting up is a simple local webserver so I can run some PHP aps like Achievo and Mantis.  The server shouldn't need a full blown mail server installed, all I wanted was to have this box forward all locally generated emails (PHP::mail()) to our normal M$FT Exchange server for handling.  Anyway, finding out how to do this was a painful hour and a half Google extravaganza. 

Turns out, you can:

```
echo ":mymailserver.mydomain.com" >> /var/qmail/control/smtproutes
```

This will work unless you're dmz, like mine, won't be able to resolve "mymailserver.mydomain.com"  Instead, try

```
echo ":0.0.0.0" >> /var/qmail/control/smtproutes
```

where 0.0.0.0 is the ip address of your mailserver.

Refer to ( http://archives.mandrakelinux.com/firewall/2002-08/msg00022.php ) for the details.

I hope this benefits someone.  Heh, I'm sure it will benefit me in 3 months when I'm setting up another linux server 'cause my boss realizes that free is alot less than an average $7500/cpu.

Rock

----------

## timfreeman

There is some slightly different advice here, too:

https://forums.gentoo.org/viewtopic.php?t=68136&highlight=mysql

(both this thread and the link have helped, thanks!)

----------

## jgrimm73

 *chatgris wrote:*   

>  *mxc wrote:*   Hi All,
> 
> I have emerged apache2 and php4. I have checked the steps as outlined by khel in the first post and all seems ok.
> 
> I have my php .so file in /etc/apache2/extramodules.
> ...

 

Thank you for the post, I had been running postgres and phppgadmin previously on this machine and like you said php was still trying to load support for it.  I unmerged php and mod_php and remerged with this command:

USE="-X -java -qt -postgres mysql apache2 perl" emerge unmerge php mod_php && emerge -u php mod_php

Everything is working just fine now.

Also I've had instances where when emerging the USE variables in make.conf were ignored.  This was mentioned in an earlier post.  I've had better luck doing export on the arch= or use= or including them in the command line.

J

----------

## chrisis

 *Buzzz wrote:*   

>  *khel wrote:*   
> 
> I'm not new to linux but really new to Gentoo  anyway, for example what steps should be taken after finishing with Installation guide?
> 
> 1. emerge xinetd  (any use variables??)
> ...

 

xinetd is useful not only for access control but for saving resources.  xinetd can start and stop services as and when they are needed so that the maximum amount of memory/cpu is available to the system.  In other words, if no-one is making http requests to your server this minute, why have httpd eating up memory/cpu?  If an http request is received, xinetd starts up httpd, which services the request; after a given period of time, if there are no further http requests, xinetd stops httpd, freeing those resources up again.

This is particularly useful when you have a machine doing lots of jobs with less-than-desirable resources (like my Celery 300 with 128mb RAM  :Wink: )

The only disadvantage is a momentary knock in performance while xinetd starts httpd for the first time (remember, it leaves httpd running as long as there are further requests... only when the requests stop coming does it shut down httpd again...).  So for a computer that is ONLY going to be a webserver, you may want to leave out xinetd and start httpd directly.

 *khel wrote:*   

> 
> 
> I'm not new to linux but really new to Gentoo  anyway, for example what steps should be taken after finishing with Installation guide?
> 
> 1. emerge xinetd  (any use variables??)
> ...

 

If you do decide to use xinetd to start/stop services, each service will have to have a config file in /etc/xinetd.d/  Some services are configured to use xinetd, so they will create their own config file in /etc/xinetd.d.  For eg, swat creates a file called /etc/xinetd.d/swat and all you have to do to make swat actually USE xinetd, edit the file and change

```
         disable         = yes

```

to:

```
          disable        = no

```

If you'd like to see code for /etc/xinetd.d/httpd, let me know, I'll post it once I get home (my home server which servers http requests infrequently uses xinetd to listen for http request).

To summarize: xinetd, IMHO, doesn't add confusion -- it adds a level of configurability.  For a server that is sharing web serving with other tasks, it is ideal to use, and not difficult at all to setup.  You just need to spend some time designing your system, and if xinetd fits in with that design, go ahead and emerge it!

 :Smile: 

----------

## Passe-Poil

I would like to see your /etc/xinetd.d/httpd !!

does httpd start on-demand or is the xinetd service configured so it only passes the requests to the server (internal thingy I think ??)

A xinetd HOWTO would be SOOOO appreciated !!!

----------

## St_Andrew

gah, i have no "APACHE2_OPTS="-D SSL -D PHP4"" in my apache2.conf file, what's wrong with me?! tried to add it by myself, but i get an error when tring to start apache then...

```
 * Apache2 has detected a syntax error in your configuration files:

Syntax error on line 17 of /etc/apache2/conf/apache2.conf:

Invalid command 'APACHE2_OPTS="-D', perhaps mis-spelled or defined by a module not included in the server configuration

```

can't get it to work, need to have it until tomorrow though  :Sad: 

thanks in advance...  :Smile: 

----------

## timfreeman

is it in /etc/conf.d/apache2 ? or /etc/apache2/conf/apache2.conf ?  it should be in the first one, does that work?

----------

## St_Andrew

 *timfreeman wrote:*   

> is it in /etc/conf.d/apache2 ? or /etc/apache2/conf/apache2.conf ?  it should be in the first one, does that work?

 

lol thanks... that did the thing, it was in /etc/conf.d/apache2 =)

thanks!

----------

## poonix

I am trying to get php working.  I've followed all these steps, and the error message I get when I restart apache2 is 

* Apache2 has detected a syntax error in your configuration files: 

Syntax error on line 24 of /etc/apache2/conf/apache2.conf: Cannot load /usr/lib/apache-extramodules/libphp4.so into server: /usr/lib/apache-extramodules/libphp4.so: undefined symbol: ap_block_alarms

Anyone know how I can fix this?

teh poo

----------

## tightcode

Hello Poonix,

This may not come as much help, but your path doesn't look like the standard path I have in my gentoo installation. For me the path to libphp4.so is:

/usr/lib/apache2/extramodules/libphp4.so

I do not know if you changed your folder structure and thus intentionally have libphp4.so in a non default folder, resulting in that not being related, or if you have a typo in your config.

In any case I did a google search for "libphp4.so: undefined symbol: ap_block_alarms" (removing the non standard path to increase results) and it found quite a few things (some dating back to 2002?) I didn't take the time to really read through them but the link to the results is here:

http://www.google.com/search?q=libphp4.so%3A+undefined+symbol%3A+ap_block_alarms&btnG=Search&hl=en&lr=&ie=ISO-8859-1

I only offer this because I know if you were searching for your whole error message (including non default paths) it was probably not returning many results.

I hope this helps if not post back and I will keep an eye on this to see if I can be of more help.

TightCode

----------

## _mikec_

a more simple way is this yet very OUTDATED, taken from the GentooX for xbox website:

http://gentoox.shallax.com/modules.php?name=Sections&op=viewarticle&artid=10

 *Quote:*   

> This tutorial guides you in setting up your apache server:
> 
> emerge sync
> 
> emerge apache mod_php php
> ...

 

read before using this guide because i think the installation directory /var/www/localhost is different.

----------

## Rush[ZA]

I followed this guide to the T and get errors

is it outdated?

from here

 *Quote:*   

> hen restart apache
> 
> /etc/init.d/apache2 -k restart 

 

I get these errors

What should I change?

```
* Usage: apache2 { start|stop|restart|reload }

 *        apache2 without arguments for full help

server distfiles # /etc/init.d/apache2 start

 * You don't appear to have the mysql database installed yet.

 * Please run /usr/bin/mysql_install_db to have this done...

 * Apache2 has detected a syntax error in your configuration files:

Syntax error on line 57 of /etc/apache2/conf/apache2.conf:

Cannot load /usr/lib/apache2-extramodules/libphp4.so into server: /usr/lib/apache2-extramodules/libphp4.so: cannot open shared object file: No such file or directory

server distfiles # /usr/bin/mysql_install_db

Preparing db table

Preparing host table

Preparing user table

Preparing func table

Preparing tables_priv table

Preparing columns_priv table

Installing all prepared tables

To start mysqld at boot time you have to copy support-files/mysql.server

to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, issue the following commands to start the server

and change the applicable passwords:

  /etc/init.d/mysql start

  /usr/bin/mysqladmin -u root -h server password 'new-password'

  /usr/bin/mysqladmin -u root password 'new-password'

Depending on your configuration, a -p option may be needed

in the last command. See the manual for more details.

You can start the MySQL daemon with:

cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:

cd sql-bench ; perl run-all-tests

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at https://order.mysql.com
```

then I try and set the passwd and this is what I get

```
server distfiles #  /usr/bin/mysqladmin -u root -h server password *********

/usr/bin/mysqladmin: connect to server at 'server' failed

error: 'Host 'server.bursting' is not allowed to connect to this MySQL server'

server distfiles #

```

----------

## j-m

 *Rush[ZA] wrote:*   

> I followed this guide to the T and get errors
> 
> is it outdated?
> 
> from here
> ...

 

Yes, this guide is very outdated... 

```

APACHE_OPTS="-D SSL -D PHP4" 

```

is basically all you need from the Apache side.

As for the MySQL problem, you are either trying to connect to MySQL from another computer, which is not allowed in default configuration, or you should omit the -h server part completely if you are connecting from localhost.

Don´t run mysql_install_db, run the command as advised after emerging MySQL. Then run mysql_secure_installation and this will set sane permissions, delete guest user, etc.

----------

## Rad

Yes, the guide's quite outdated... you dont get php4 anymore when using ACCEPT_KEYWORDS="~x86", hence "-D PHP4" wont work, I guess that's what caused the first error with php4. EDIT: Sorry, I made a mistake. I think "-D PHP4" should work (at least here it loads php5 anyways), but it has not got the same config - it lacks some entries which are labelled bugfix.

Also, setting said ACCEPT_KEYWORDS is considered bad practice now. If you really want the apache from gentoo unstable (I don't know if you even do), you should set that up in /etc/portage/package.keywords (example: add a line saying "net-www/apache ~x86").

Else you'll get your whole system migrated to gentoo unstable when you next do emerge -u world, which probably is not what you want...

I think best would be to remove the ACCEPT_KEYWORDS - Statement from your make.conf if you don't want to run Gentoo unstable and then refer to this HOWTO to perform all appropriate changes:

http://gentoo-wiki.com/HOWTO_Apache2_with_PHP_MySQL

----------

## orvtech

 *khel wrote:*   

> I couldn't find any step-by-step instructions on setting up a webserver, so, after lurking on this forum for a while, I decided to share my experience on the subject. Anyway, to make the long story short, that's what I did to make Apache2/mod_php/mysql combo work to suite my needs   
> 
> edit /etc/make.conf and add 
> 
> ACCEPT_KEYWORDS="~x86" 
> ...

 

Ohhh thanks a lot dude for this tutorial i have been looking for this for about 2 weeks now, i even desided to run fedora as a web server ( I Know .. Im so  so so Sorry, i will  make it up today with this guide). i will post here my experince.

Thanks again

----------

## zephid

 *khel wrote:*   

> 
> 
> edit /etc/make.conf and add 
> 
> ACCEPT_KEYWORDS="~x86" 
> ...

 

To start with, i'll say your guide looks rather good, but one thing I find very interresting is your ACCEPT_KEYWORDS="~x86" in make.conf? Are you out off your mind?  :Smile:  A global ACCEPT_KEYWORDS could destroy your gentoo installation, so here is what I would have done instead.

Example, we want PHP5 instead of PHP4, this is what we will do:

```
echo "dev-php/php ~x86" >> /etc/portage/packages.keywords

echo "dev-php/mod_php ~x86" >> /etc/portage/packages.keywords
```

That way it's only php and mod_php there will be installed with the ~x86 args.  :Smile: 

Hope you got the point  :Smile: Last edited by zephid on Mon Apr 04, 2005 9:26 am; edited 2 times in total

----------

## Deathwing00

Moved from Networking & Security.

----------

## orvtech

Destroy? dude I allways install ~x86 and never had a problem, of course ... I've never install a web server usin ~x86,  but i dont see why would I have a problem doing so. could you give me any example that had happened to you using ~x86 ?

----------

## arghnoname

 *Quote:*   

> echo "dev-php/php ~x86" >> /etc/portage/packages.keywords
> 
> echo "dev-php/php ~x86" >> /etc/portage/packages.keywords

 

Do you mean for that to say: 

 *Quote:*   

> echo "dev-php/php ~x86" >> /etc/portage/packages.keywords
> 
> echo "dev-php/mod_php ~x86" >> /etc/portage/packages.keywords

 

Anyway, I have to agree about global ~x86. Some people might get away with it, but it isn't anything I would recommend to a n00b like me.

----------

## pwhitt

 *Quote:*   

> Destroy? dude I allways install ~x86 and never had a problem, of course ... I've never install a web server usin ~x86, but i dont see why would I have a problem doing so. could you give me any example that had happened to you using ~x86 ?

 

well, i used to do that, but at some point i ran into problems with some package and stability - i don't remember what.  when trying to downgrade it, portage barfed.  apparently it was a sketchy file needed by other sketchy files, needed by other sketchy files, etc etc etc.  my system was nothing but super sketchy packages.  getting everything straight so i could fix it took days.  now i use my /etc.../package.crap files - and i suggest everyone do the same.  it takes a minute to do, requires at least a little thought and will discourage you from suddenly opening the floodgates of impending sketch.  it's also a very easy way to track what you have done, and a great place to comment regarding your reasons for masking/unmasking a certain package.  this way you can ensure that when you want to downgrade a package, you will have minimal complications.

----------

## easy_coder

Can someone point me to an updated LAMP install guide for gentoo if this guide is out dated?  I've looked around but nothing seams to recent..

----------

## Gentree

 *orvtech wrote:*   

> Destroy? dude I allways install ~x86 and never had a problem, of course ... I've never install a web server usin ~x86,  but i dont see why would I have a problem doing so. could you give me any example that had happened to you using ~x86 ?

 

That's the whole point, if you have a ~x86 installation you probably had that line anyway so the comment does not apply to you.

However , if you just arbitarily add that to make.conf on a system that is built as x86 you can expect some heavy shit to befall you.

That was dumb, ill-founded advice. Anyone posting something under the title of "HOWTO" should be responsible enought to make sure they post valid information.

@Kehl , please correct your original post to avoid ppls  blowing out thier gentoos.

 :Rolling Eyes: 

Otherwise , thanks for some of the other info , it has saved ne a bit of digging.

[EDIT] moderators: any chance of changing that? I see kehl has 79 posts since march2003, I guess he's long gone

 :Cool: 

----------

## mingotta

 *easy_coder wrote:*   

> Can someone point me to an updated LAMP install guide for gentoo if this guide is out dated?  I've looked around but nothing seams to recent..

 I need it bad too!!

 :Embarassed: 

----------

## GoofballJM1

Here it is:

http://gentoo-wiki.com/LAMP_Setup_Step_By_Step

Gentoo Wiki is loaded with howtos.  The documentation isn't too different these days, unless you want to run PHP5.  If you want to run PHP5 instead of PHP4 (which is what I do, it runs very stable now), Do this instead of installing mod_php:

```
#echo dev-lang/php dev-lang/php -X apache2 berkdb bzip2 calendar cli dba kerberos ldap mysql ncurses nls pcre mysqli pear session ssl wddx xml2 xmlrpc xsl >> /etc/portage/package.use
```

Perhaps that's too many use flags, this is my webserver for my company, so I have a lot of apps running on it.  You at least need the apache2, mysql, and xml (wddx, xml, xmlrpc, xsl) use flags enabled.  The apache2 use flag will create the apache module so you don't have to install a separate module after installing the php framework.  It does it all in one shot

And then install PHP 5

```
emerge dev-lang/php
```

Edit your /etc/conf.d/apache2

```
APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5"
```

Notice the PHP5 instead of the PHP4 on that line.

----------

## rdk

So here is the deal, i have written a complete HOW-TO-LAMP but there was a power outage and bye bye to all of my writings...  :Sad: 

Let us start once more...

Setting up LAMP is not all that hard. Emerge it, configure it, start it and offfffffffffff you go... ( while we are going i am going to get some more beer... brb )

Burp... OK. 

LAMP

What is LAMP? It is a acronym for LINUX, Apache, MySQL and PHP / Perl / Python

This is a popular dynamic web server / development environment based on OpenSource.  :Smile: 

Emerge

I guess you already have Gentoo Linux installed, so we'll skip that and move over to Apache2, MySQL and PHP's.

First synchronize portage and install the necessary programs. To do this you need to run following commands.

```
# emerge sync

# emerge --pretend --verbose apache mysql dev-php/php mod_php
```

Take a good look in what USE flags are used by default and configure them to suit your needs.

```
# USE=" add/remove needed flags "  emerge --ask --verbose apache mysql dev-php mod_php
```

NOTE: You should really adjust USE settings in /etc/make.conf and run env-update so when you do an update same flags will be used for emergeing!

Sit back and relax, enjoy in tons of gcc output, get a bottle of beer and so on.... hmm... beeerrrr... brb...

Configuration

First we'll configure Apache2 web server. Gentoo used 2 config files earlier ( apache.conf & commonapache.conf ), but that has been removed in favor of using standard httpd.conf file.

Default Apache2 configuration resides in /etc/apache2 directory.

Open it up in your favorite text editor ( here we use vim ).

```
# cd /etc/apache2/; vim httpd.conf
```

You could change the following lines, although defaults work just fine:

 *Quote:*   

> ServerAdmin root@localhost

 

E-mail address of server administrator 

 *Quote:*   

> ServerName localhost

 

This should be set to DNS name or IP address of your server. I use Dynamic DNS addressing for my server since i don't have a static IP address.

 *Quote:*   

> UseCanonicalName Off

 

As i have said, I don't have a static IP address, so when someone wolud refer to my server by his current IP address and if my IP would change while he is connected to server he would, of course loose a connection. So i set UseCanonicalName to ON. This way when you refer to this server by his IP address, server would "redirect" the client to value set by ServerName directive ( which is my dynamic DNS name, so he would still stay connected after the IP has changed)

Also going throu configuration file you may have notice <IfDefine WHATEVER> </IfDefine> clauses. They are read by the Apache  only if you start Apache with -D WHATEVER options thus defining the WHATEVER option. Now if you don't want run Apache manually all the time you can put those options in /etc/conf.d/apache2 file. 

```
# cd /etc/conf.d; vim apache2
```

Find following line:

 *Quote:*   

> APACHE2_OPTS="-D DEFAULT_VHOST"

 

And change it so Apache gets started with PHP module.

 *Quote:*   

> APACHE2_OPTS="-D DEFAULT_VHOST -D USERDIR -D PHP4"

 

You may have notice that i have added USERDIR to Apache options. This enables serving files from a users home directory, or from elsewhere, depending on configuration setting which can also be found in /etc/apache2/httpd.conf.

 *Quote:*   

> # UserDir: The name of the directory that is appended onto a user's home
> 
> # directory if a ~user request is received.
> 
> # enable by adding -D USERDIR to /etc/conf.d/apache2
> ...

 

Also you need to setup right permmisions on those directories. I think it should be 755 for Apache to be able to serve files, but don't quote me on this one.

More on topic: 

Apache Documentation - Public Html

Apache Documentation - Sections

Apache Documentation - URL Mapping

If you want Apache to serve the files from another root location, then you want to change DocumentRoot directory.  According to current APACHE2_OPTS which use -D DEFAULT_VHOST you should be changing 00_default_vhost.conf located in /etc/apache2/vhosts.d

```
cd /etc/apache2/vhosts.d/; vim 00_default_vhost.conf
```

This should be the default:

 *Quote:*   

> DocumentRoot "/var/www/localhost/htdocs"

 

You can pretty much change it to point anywhere you want.  I won't go deeper in VirtualHost configurations...

mod_php configuration can be found in /etc/apache2/modules.d/ in file 70_mod_php.conf

Next we are going to setup MySQL database. We have allready emerge it so now we only need to run MySQL install program and secure the installation.

```
# mysql_install_db

# mysql_secure_installation
```

That would just about wrap up a minimal configuration procedure.

Start up & testing

You can start apache by isueing following commands:

```
# /etc/init.d/apache2 start

# /etc/init.d/mysql start
```

If all goes well here and you have used same paths as I have, try the following:

```
# echo "<?php phpinfo(); ?>" /var/www/localhost/htdocs/test.php
```

Then with your favorite browser visit: http://127.0.0.1/test.php, of course if you are on the same machine as the web server.

You should then see the configuration settings of your PHP installation. If not something is wrong either in your Apache conf or in PHP / mod_php conf.

Other

You could setup PHPMyAdmin ( web interface for controlling MySQL databases; try emerge -s phpmyadmin ), perhaps SAMBA server so you can share the directories for web services on local network and ftp / sftp server to enable users and yourself to upload stuff to server over networks.

But i don't have anymore time, so i'll leave it for some other day.

More stuff on this:

http://httpd.apache.org/

http://www.mysql.com/

http://www.php.net/

WIKI STEP-BY-STEP LAMP

Apache2 configuration changes discussion

I really hope this helps, and please inform me if something is not correct in this post. THANKS.

I think I'll go buy me self a sandwich now...

----------

## Gentree

 *rdk wrote:*   

> So here is the deal, i have written a complete HOW-TO-LAMP but there was a power outage and bye bye to all of my writings... 
> 
> 

 

Sorry , couldnt help laughing when I read that, you're writing "how to lamp" and you get a power outage! Bet you wish you'd lit the lamp first   :Laughing: 

----------

## rdk

 *Gentree wrote:*   

>  *rdk wrote:*   So here is the deal, i have written a complete HOW-TO-LAMP but there was a power outage and bye bye to all of my writings... 
> 
>  
> 
> Sorry , couldnt help laughing when I read that, you're writing "how to lamp" and you get a power outage! Bet you wish you'd lit the lamp first  

 

That's just my luck...  :Smile:   :Laughing:   ( oh yeah, and my bad english )...

----------

