# Eric's Web Server How-To (For new installs & n00b's)

## elajoie

So, over the past few days I have toyed with a few gentoo installs to get my web server running the way I want it too. Below I will list the step I did to get it working. (I HOPE IT HELPS   :Twisted Evil:  )

NOTE:

1. Every time you edit your /etc/make.conf file type env-update (return) to make your changes take effect!

2. Code is in DARK BLUE

3. File listings are in RED

4. Do a ("-p" for pretend) on each emerge to see what your emerging eg.(emerge -p foobar)

FIRST:

I installed gentoo from stage 1 with these /etc/make.conf file settings and gentoo-sources kernel:

USE="-X -gtk -gnome -qt -kde -alsa -qtmt -pdflib -apache -truetype mysql apache2 pam ssl xml xml2"

Second:

To set the starting point do a sync and update:

emerge sync

emerge -uD world

The D stand for deep (Ill Update when I find the meaning of D is exactly)

Now emerge mysql (If you want!):

emerge mysql

ebuild /var/db/pkg/dev-db/mysql.foo*/mysql.foo*.ebuild config

Important! Replace "foo" in the directly above code to match your installed package by pressing TAB when you have already typed "mysql" which will auto compleate.

rc-update add mysql default

This I got from khel on his post:

emerge netpbm

Now we emerge apache2:

emerge apache

rc-update add apache2 default

Now we emerge PHP:

emerge php

And also the php module:

emerge mod_php

emerge clean

(this gets rid of any extra php modules i think, acording to khel's post)

ebuild /var/db/pkg/dev-php/mod_php-foo*/mod_php-foo*.ebuild config

Again, replace foo with the autocompleated package version

Now edit your /etc/conf.d/apache2 to enable php support:

nano -w /etc/conf.d/apache2

Edit the line APACHE_OPTS to look like this

APACHE_OPTS="-D SSL -D PHP4"

Start you deamons!!:

/etc/init.d/mysql start

/etc/init.d/apache start

Test you page:

BEFORE you try this:

emerge lynx

lynx (your IP or localhost name or 127.0.0.1)

One final thing that stumped me was that SSL comes bundled with apache2 you dont have to emerge it and also if you want phpBB there is no stable ebuild for it to go in combo with apache2. Look at the ebuild howto on the gentoo site for info to check the bug.gontoo.org listing.Last edited by elajoie on Tue Apr 13, 2004 10:26 pm; edited 9 times in total

----------

## elajoie

If you want to make a PHP test page do the fallowing after the sevrer is up and running:

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

Then:

lynx http://localhost/test.php

(note, I think you can put in 127.0.0.1 for your loopback port if our on the server when you try to connect)Last edited by elajoie on Sun Sep 10, 2006 11:14 pm; edited 2 times in total

----------

## elajoie

And if anyone see's important stuff to be added please respond, I would be glad to make an upgrade post for people upgading even though Apache2 dosnt support everything....Last edited by elajoie on Fri Jul 18, 2003 7:37 am; edited 1 time in total

----------

## slartibartfasz

 *elajoie wrote:*   

> and I used the normal settings through out the file along with this:
> 
> ACCEPT_KEYWORDS="~x86"
> 
> (notice this is for my pentium computer.. change to correct arch. if you have other)
> ...

 

why? if this should be for noobs then u should at least mention that this will emerge unstable packages  :Wink: 

 *Quote:*   

> 1. so its back at the top of the stack! 

 

doesnt make a good reason in general....

----------

## elajoie

As you look in the /etc/make.conf file you will see a discription for the entry ACCEPT_KEYWORDS="~arch". Edit this only if you get problems emergeing Apache2. I know I needed it to emerge apache2 but it seems the ebuilds and releases are now officialy released.

Thanks slartibartfasz for the update.. =)

----------

## joshdr77

thyanks for the howto  :Smile:  worked great  :Smile: 

----------

## elajoie

I will be posting my configuration soon and also I will try to get this put into the document forum once its complete.

-elajoie =)

----------

## BxBoy

looking good

----------

## ClippyHater

Does this result in PHP being run as a SAPI module or CGI?  I'm not sure how to find out   :Embarassed: 

Thanks!

Oh, BTW, your line:

```
/etc/conf.d/apache
```

should probably be:

```
/etc/conf.d/apache2
```

----------

## elajoie

Hi,

In one of the most recent PHP releases you could gain access to a server my using CGI to get user privledges in PHP. I hope this is what you were refering to ClippyHater? Check out the link!!! HERE!!!

Thanks for the apache code edit.. I checked and you are right ClippyHater Thanks!

Keep the info comming, This will help in makeing the HOWTO a better source and help....

-elajoie

----------

## epretorious

Hello, Elajoie:

I've just finished merging Apache 1.3.27-r4 and mod_php 4.3.2-r3. Apache works fine except for parsing PHP files.

I've added the directives...

```
Loadmodule php4_module extramodules/libphp4.so

Addmodule mod_php4.c
```

...to /etc/apache/conf/apache.conf and the contents of /etc/apache/conf/addon-modules/mod_php.conf...

```
<IfModule mod_php4.c>

AddType applications/x-httpd-php   .php .php4 .php3 .phtml

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

</IfModule>

```

...to /etc/apache/conf/commonapache.conf.

Before I added the Loadmodule and Addmodule directives, Apache functioned correctly.

Now that I've added these directives, Apache starts without any complaints but won't bind to any ports and won't respond to any requests. 

What's wrong?  :Evil or Very Mad: 

----------

## elajoie

I looked around for your problem and it seems to have a few people stumped... Can you please tell me what PHP install you did also... ?

-elajoie

----------

## epretorious

 *elajoie wrote:*   

> Can you please tell me what PHP install you did also?

 

I did not merge php - only mod_php. There wasn't a dependancy so I didn't merge it. Is it required?   :Shocked: 

----------

## elajoie

Well.... To tell you the truth Im not sure.

I asked around at my office and no one knew the answer.. I looked around the web for info and I did see alot of trubble with apache 1 and php4... ill keep looking....

-elajoie

----------

## elajoie

Well it looks like im going to update this post with security info...

I fallowed the gentoo HOWTO on security and alot of it is outdated including alot of the config entries. Im going to try and make edits directly to the original and port it to gentoo and also to this forum..

Beware of the kernel configs also and the disk quota stuff...

-elajoie

----------

## elajoie

Well I am in Germany for the month of August and during the 24th through the 1st of September I will be in Croasia. If anyone from the Munich area or northern Croatia wants to meet up drop me an email.

-elajoie

ps. its a little off from my normal topic but I will deleate the post when I get back to the states.

----------

## maalth

Eric,

The line: APACHE_OPTS="-D SSL -D PHP4"

Should instead read: APACHE_OPTS="-D SSL -D PHP" 

----------

## ClippyHater

maalth,  I think it needs to be PHP4, not PHP--a note in /etc/conf.d/apache2 explicity said that this is a change in order to make eventual upgrades to PHP version 5 automatic.

----------

## maalth

Actually -D PHP4 does not work.  I've tried it and as you can see by some of the other posts, it didn't work for them either.

----------

## wHAcKer

it DOES work for me  :Smile: 

----------

## elajoie

Hi All, 

I used the PHP4 option on my server and my php test page worked just fine. I found tons of links for php4 being listed on gentoo's docs.

-elajoie

----------

## mog

good post ... unfortunately there are few good howto posts regarding apache that really cover the lot ... well I followed your post exactly, but I am getting the following error on start-up:

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

then apache2 exits ... I noticed that because trying to stop it tells me that it is not running yet ... 

any ideas?

----------

## plate

Very helpful, thanks!  :Cool: 

Moved from Networking & Security.

----------

## epretorious

 *mog wrote:*   

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

 

During start-up, Apache uses the resolver to verify that the name that it's given (using the ServerName directive in /etc/apache/conf/apache.conf) actually corresponds to the name returned by the resolver for the interface that Apache is configured to monitor (using the BindAddress or Listen directives in /etc/apache/conf/apache.conf).

In /etc/apache/conf/apache.conf, set the ServerName to ...The name of the machine as it exists in your name server (if your running BIND) or your ISP's name server (i.e., The internet name of the machine), or

The name of the machine as it exists in /etc/hosts (e.g., localhost).The resolver checks both locations. See man resolv.conf for more information

----------

## bd

Hi!

PHP doesnt work for me. Maybe because of this:

```
FireBird / # ebuild /var/db/pkg/dev-php/mod_php-4.3.2-r4/mod_php-4.3.2-r4.ebuild config

 * Due to some previous bloopers with PHP and slotting, you may have

 * multiple copies of mod_php installed. Please look at the autoclean

 * output at the end of the emerge and unmerge all but relevant

 * copies.

 * Edit /etc/conf.d/apache2 and add "-D PHP4"

 * This is a CHANGE from previous behavior, which was "-D PHP"

 * This is for the upcoming PHP5 support. The ebuild will attempt

 * to make this update between PHP and PHP4 automatically
```

I don't know what to do... Do you?

Thanks in advance...

----------

## freshy98

can you please tell me what output I should see?

I made that file, and when I open I get this:

```
 <? phpinfo() ?>
```

reading the line I guess it should give me some version info about php?

[edit]php does not seem to work at all on my machine. phpsysinfo also gave me the complete listing[/edit]

[edit2]php works nog with the test.php filem but phpsysinfo still gives me it's listing. gonna re-emerge phpsysinfo now[/edit2]

 *elajoie wrote:*   

> If you want to make a PHP test page do the fallowing after the sevrer is up and running:
> 
> echo "<? phpinfo() ?>" > /home/httpd/htdocs/test.php
> 
> Then:
> ...

 

----------

## trentone

i get this issue trying to emerge php on any given system

++++++

configure: error: can not run test program while cross compiling

!!!  ERROR: dev-php/mod_php-4.3.2-r4 failed

!!!  function econf, Line 320 Exitcode 1

!!!  econf failed

++++++

any help?

(and yes happens with any version of PHP, mod_php etc)

----------

## scootersmk

Thanks for the great doc.  Although some of the commands need to be updated to apache2 and the directory needs to be changed to /var/www/localhost/.  Just thought you might want to update it so people can continue to take advantage of your doc.  Thanks again.

----------

## hulk2nd

 *elajoie wrote:*   

> Well I am in Germany for the month of August and during the 24th through the 1st of September I will be in Croasia. If anyone from the Munich area or northern Croatia wants to meet up drop me an email.
> 
> -elajoie
> 
> ps. its a little off from my normal topic but I will deleate the post when I get back to the states.

 

hehe funny i live near munich (ok not really near munich but also in southern germany) and my mother comes from croatia   :Very Happy:  so have nice holidays or whatever you'll do there!!

greets,

hulk

ps. also a little bit off from topic but i hope you'll excuse me   :Razz: 

----------

## elajoie

Hi All,

Ok now after a long dry spell with Gentoo Im back to redo the howto

I am currently forming a Linux User Group and my University and Im going to be making Gentooopne of our Installfest distros! 

Check out our site:

http://www.ecs.umass.edu/umasslug

This posting will hopfully be the source for all the UMass LUG students to install Apache-PHP-Perl

-Eric

----------

## qeldroma

 *elajoie wrote:*   

> 4. Do a ("-p" for practice) on each emerge to see what your emerging eg.(emerge -p foobar)

 

Just for info, "-p" means "pretend". Greets and thanks, qd

----------

## Icer

Thanks for the excellent howto. I'd add instructions howto setup phpmyadmin.

I did just setup it and I did'nt first notice that there's similar install script as there is for mysql. I.e the ebuild blabla config thing. I suppose those install scripts are quite common. I wonder how I've not noticed them before.

----------

## hypercard

Thanks for this great resource!  I've followed this guide on every gentoo box I've installed.  I vote for it's inclusion into the official FAQs.

Thanks again!

----------

## grendelkhan

(Using apache-2.0.49-r1 and mod_php-4.3.6-r2.)

mod_php wasn't loading for me---the test.php script displayed earlier merely spewed out its source. I'd gone to /etc/conf.d/apache2 and edited it to include the text -D PHP as specified above.

In /etc/apache2/conf/modules.d/70_mod_php.conf, the first line read 

```
<IfDefine PHP4>
```

 I changed it to 

```
<IfDefine PHP>
```

 and it now works.

Hope this helps someone else; took me a few minutes to figure this one out.

--grendelkhan

----------

## neonknight

edit: posted in the wrong topic...

----------

## easy_coder

newbie question

What directory does the html files go into?  What directory do the install files go into?  The install directory is /usr/locl/php2 correct?

----------

## magnesium

wow, you revived a thread that was like a year old...

the .php file goes into /var/www/localhost/htdocs/ now

----------

## elajoie

I'm doing a few new install this weekend and I will update this howto with all the new info when I'm done!

-Eric

----------

