# help me setup my web server....

## cool

I have couple questions b4 the setup. 

Is it possible to tell portage to emerge a program and put the binary files into a specific directory(just like ./configure --prefix=/directory) ??

Explain steps if its possible.

Here is what i want to setup for my web server : apache 1.3, php4, MySQL,Mod_SSL.

Can someone show me how to emerge them all together?? (so they can work together)

Well, i know to have Apache support ssl and php; in compiling i have to put 

--enable-module=ssl / --enable-module=php4 ....etc

I'm interested in emerging all them cause it is fast and easier than compiling them all from scratch. But i'm really nervous about how all the bin files are stored, especially for the db of MySQL. So pleaseclear thing out for me.

If i have to compile all from scratch here is my setup steps

CFLAGS = -march=pentium3 -O3 -pipe CXX=gcc CXXFLAGS={$CFLAGS}

1. MySQL:

./configure --prefix=/usr/local/mysql 

make

make install

scripts/mysql_install_db

...testing the database after installation

2. PHP4:

./configure --with-mysql=/usr/local/mysql \

                --with-apache=../apache1.3.x \

                --with-curl........

                --with-xml.......

                --enable-shared-pdflib --enable-track-vars

make 

make install

3. mod_ssl:

./configure --with-apache=../apache1.3.x

4. Apache1.3.x:

SSL_BASE=.../openssl-0.9.x \ 

./configure --enable-module=ssl \

                 --activate-module=src/modules/php4/libphp4.a \

                 --enable-module=php4 \

                 --enable-shared=ssl \

                 --prefix=/usr/local/apache 

Will these steps work?? But i really how to emerge them so that it will produce the same result and suit what i want. (details would be great, as i'm just a noob)

THankx everyone,

-cool-

----------

## xedx

You can check out the ebuild of the appropriate app u want to configure or you can perform yourself the ./configure ; make 

steps. read the faq

----------

## cool

uh... are you saying i have to write my own ebuild?? would that take lots of time?? 

I was thinking about doing something like 

emerge apache mysql php mod_ssl mod_php

But i have no clue if that will do kind of the same as compiling like i show above. Moreover i want to know more about how they interact. Well such as where will the db be stored ..etc So yes i'm worried about the directories as you may see that in the compiling i have to show the path between them. 

I really need help for this.

Thank in advance

-cool-

----------

## dolbz

look at the ebuild files for the versions that you are building. They are relatively self explanatory. What I did for my apache install was change some of the directories for config files and stuff. Just save your ebuild file and dont emerge sync until after you've installed. If you do an emerge sync the old ebuild will be restored (i think). It works well. Oh yeah not sure bout this but I think having php and mysql and apache(2?) in your use variable means that if you emerge apache then php and mysql will be installed. if that's not the case then emerge mysql then php then apache.

Also take a look at the desktop install guide in the gentoo docs it has a good little guide for installing apache.

Dolbz

----------

## cool

Thankx for your input. But i'm still confused that how emerge them like that would make them work together. Like if i emerge apache then emerge mysql, they willl just work together?? kuz in compiling from scratch i have to specify --with-mysql in ./configure.

Anything more detail to clear this out?

ALso other questions about how to config portage to install a program in a direcory i want, plz help.....

If thats not possible, then where will my db(database) be??  

-cool-

----------

## ggelln

Haven't done this for apache specifically, but don't be afraid of making the ebuilds (in your case tweaking them) as you have basically written out the steps which is all the ebuild is . . .

to overcome the emerge sync overwrite problem,

open your: /etc/make.conf file and edit the line (that is uncomment)

```
 #PORTDIR_OVERLAY=/usr/local/portage 
```

and then work out of this folder so your custom ebuilds will not be clobbered.

for example if I want to adjust apache I would do:

```
 

mkdir /usr/local/portage/net-www

cp -r /usr/portage/net-www/apache /usr/local/portage/net-www

```

then open the file and edit.

a quick look shows that the apache ebuild has a

#setup the filesystem layout config

section which looks like:

```

        <Layout Gentoo>

        prefix:          ${prefix}

        exec_prefix:     ${prefix}

        bindir:          ${prefix}/bin

        sbindir:         ${prefix}/sbin

        libdir:          ${prefix}/lib

        libexecdir:      ${prefix}/lib/apache2

        mandir:          ${prefix}/share/man

        infodir:         ${prefix}/share/info

        includedir:      ${prefix}/include/apache2

        installbuilddir: ${prefix}/lib/apache2/build

        datadir:         ${datadir}

        errordir:        ${datadir}/error

        iconsdir:        ${datadir}/icons

        htdocsdir:       ${datadir}/htdocs

        cgidir:          ${datadir}/cgi-bin

        manualdir:       /usr/share/doc/${PF}/manual

        sysconfdir:      /etc/apache2/conf

        localstatedir:   /var

        runtimedir:      /var/run

        logfiledir:      /var/log/apache2

        proxycachedir:   /var/cache/apache2

        </Layout>

```

so just edit the file and then when you do emerge apache all will be well  :Smile: 

glancing at the aforementioned desktop setup guide,

php etc work nicely if you just do what you said in your post, ie the mod_php etc

Gabriel

----------

## cool

wow thankx a lot Gabriel 

I will certainly do that for mySQL, because i just need to control all my db and dont have to change director to look for it. 

However about apche and php, can i just emerge them to make them work?? kuz i dont need to specify any directory, defaul will work fine for me.

So will "emerge apche mod_ssl php mod_php" work like the steps i showed above??

Hmm.. thankx to everyone, sorry about my english, i'm from Singapore but my grand parents are japanese. :p and i'm 15, so my english is terrible

Oh this is my frist linux too, i had it for a month so thats why i'm so noob and scared to screw things up.

-cool-

----------

## ggelln

again, my reasoning is based off of the desktop guide . . .

the relevent section reads :

```

# emerge apache php mod_php mod_ssl

# 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

```

and then all should be well ( given the apache config files are to your liking etc).

Tell me how it goes . . .  I think I am going to set this up myself  :Smile: 

it is about time I learned php . . .

Your english is absolutly fine . . . I would never have known . . . can't say as much more my japanese etc  :Smile: 

Gabriel

----------

## st. anger

 *cool wrote:*   

> Thankx for your input. But i'm still confused that how emerge them like that would make them work together. Like if i emerge apache then emerge mysql, they willl just work together?? kuz in compiling from scratch i have to specify --with-mysql in ./configure.
> 
> Anything more detail to clear this out?
> 
> ALso other questions about how to config portage to install a program in a direcory i want, plz help.....
> ...

 

the way i thought it worked is having something in your USE flags is equivalent to using those compile time options(ex. USE="mysql" == --with-mysql) .  am i right?

----------

## cool

OK i got little time to look at the ebuild how-tos, however i didnt have time to finish, but i did scan thro it and get most of the ideas(just not detail). well i liked to finish the docs but the light in my room bother my parents so they ordered me to go to bed  :Sad: 

Anyway, i got mysql-4.0.12.ebuild edited and yes after i copied the whole folder over to someplace i want. I also or Portdir_overlay changed. 

But a noob question come to my mind, how to emerge my new edited ebuild?? I didnt have time to look at cause i got to work. 

There is also a difficulty... my server is not at my place. Its hosted at my best friend's place as he has better connection (mine is a crappy cable)

SO everything i have done is thro ssh, except the installation of gentoo.

In the mean while i will follow the instruction on the site to install apche, php, mod_php and mod_ssl.

thankx,

-cool-

*edit* oh when i do emerge -p apache php mod_php mod_ssl

i see there is java in there, why jave has anything to do with this?? ALso it will compile blackdown jdk and i really  dont want it. I just want the server as light as i can and serve only what i need. There are lots of stuff that will be compiled that i dont need. I checked my USE flags and call emerge -pv but have no clue how it effect the function of my web server stuff. especially like java stuff, i dont see what USE flag that turn it on. I'm a bit pissed at the emerge  :Sad: 

-cool-

----------

## ggelln

post the output of your emerge -pv and we might be able to help you find the offending java line!

secondly what are your USE variables do you have -java to show that you don't want java (if you just leave it out, it might be added by default).

as for the emerging the new ebuild it should take precedence over the file in 

/usr/portage tree, unless the one in the standard tree is newer, so just emerge away  :Smile: 

Gabriel

----------

## cool

```

Calculating dependencies ...done!

[ebuild  N   ] dev-libs/mm-1.2.1

[ebuild  N   ] net-www/apache-1.3.27-r3

[ebuild  N   ] app-text/aspell-0.50.3

[ebuild  N   ] app-crypt/mhash-0.8.18-r1

[ebuild  N   ] media-libs/freetype-2.1.4  -doc +zlib -prebuilt

[ebuild  N   ] media-libs/libpng-1.2.5-r4

[ebuild  N   ] media-libs/jpeg-6b-r3

[ebuild  N   ] media-libs/tiff-3.5.7-r1

[ebuild  N   ] media-libs/lcms-1.09

[ebuild  N   ] media-libs/libmng-1.0.4

[ebuild  N   ] x11-misc/ttmkfdir-3.0.9

[ebuild  N   ] x11-base/opengl-update-1.5

[ebuild  N   ] media-libs/fontconfig-2.2.0-r2  -doc

[ebuild  N   ] app-arch/unzip-5.50-r1

[ebuild  N   ] app-arch/cabextract-0.6

[ebuild  N   ] x11-base/xfree-4.3.0-r2  -3dfx +sse +mmx -3dnow +xml +truetype +nls -cjk -doc

[ebuild  N   ] dev-db/mysql-3.23.56  -static +readline -innodb +berkdb +tcpd +ssl

[ebuild  N   ] x11-libs/qt-3.1.2-r3  +cups -nas -postgres -opengl +mysql -odbc +gif

[ebuild  N   ] dev-perl/Net-Daemon-0.36-r1

[ebuild  N   ] dev-perl/Test-Harness-2.24-r1

[ebuild  N   ] dev-perl/Test-Simple-0.47

[ebuild  N   ] dev-perl/Storable-2.04-r1

[ebuild  N   ] dev-perl/PlRPC-0.2016-r1

[ebuild  N   ] dev-perl/DBI-1.32

[ebuild  N   ] dev-perl/DBD-mysql-2.1013-r1

[ebuild  N   ] media-libs/pdflib-4.0.3-r1  -tcltk +perl +python -java

[ebuild  N   ] dev-perl/XML-Parser-2.31-r1

[ebuild  N   ] app-text/sablotron-0.97

[ebuild  N   ] dev-libs/libmcrypt-2.5.5

[ebuild  N   ] media-libs/freetype-1.3.1-r3  +nls

[ebuild  N   ] net-ftp/curl-7.10.2  +ssl -ipv6 -ldap

[ebuild  N   ] dev-libs/libxml2-2.5.6  +python +readline

[ebuild  N   ] media-libs/t1lib-1.3.1  -X -tetex

[ebuild  N   ] net-libs/libwww-5.4.0-r1  +ssl +mysql

[ebuild  N   ] dev-php/php-4.3.1  +truetype -postgres +tiff +libwww +nls +jpeg +readline +ssl -oci8 +mysql -X +gdbm +curl -imap +xml2 +xml -cjk +pdflib +qt -snmp +crypt -flash -odbc -ldap +berkdb -freetds -firebird +pam +spell

[ebuild  N   ] dev-php/mod_php-4.3.1  -java +spell +png -apache2 +truetype -postgres +tiff +libwww +nls -gd +jpeg +ssl -oci8 +mysql -X +gdbm +curl -imap +xml2 +xml -cjk +pdflib +qt -snmp +crypt -flash -odbc -ldap +berkdb -freetds -firebird +pam

[ebuild  N   ] net-www/mod_ssl-2.8.14

```

So i did put -java in USE flag. I read thro but dont know what else to take out from the Use flag to i just leave it.

About the ebuild that i edited, its so weird. I copied mysql from standard portage tree to usr/local/portage/dev-db then i edited mysql-4.0.12.ebuild there. After that i uncomment Portdir_overlay in make.conf.

Then i call emerge apache php mod_php mod_ssl mysql

BUt it emerged the old mysql in the standard portage which is mysql-3.23.x

Anyideas??

-cool-

*edit*  after i emerge everything, mysql is still not the one i want i may have to unmerge it later, i found xfree-4.3.0.x is totally unecessary. What flag has activated it??

here is my flags:

```

USE="xv slang readline gpm berkdb mmx -3dnow gdbm tcpd pam libwww ssl sse nls -arts perl python -esd gif imlib sdl -oggvorbis  -X -gtk -gnome qt -kde motif -opengl avi png tiff apache icc samba mysql php mod_ssl curl mod_php pspell xml -java"

```

----------

## ggelln

okay . . .

have you already installed X.

Getting rid of it is sometimes a chore, you must be careful of your world file which will try to reinstall anything that you haven't loaded if you have another package loaded that depends on it . . . we will deal with this later!

as for the mysql problem . . .

is the mysql ebuild in /usr/local/portage/deb-db/mysql/

or just /usr/local/portage/deb-db it will not work if it is (I wasn't clear on this from your post)

and I have realized I have made a glaring omission in the edited ebuild process . . .

you must make a digest for your new ebuild:

```

cd /usr/local/portage/dev-db/mysql

ebuilld mysql-4.0.12.ebuild digest

```

if you want to be sure to use your new ebuild you can specify it manually:

```

emerge -pv /usr/local/portage/dev-db/mysql/mysql-4.0.12.ebuild

```

hopefully this helps.

now onto the annoying X11 cleaning:

run:

```

emerge -p depclean

```

and post the output,

it might show us the packages in your worldfile that are causing java, and X11 to be built

ENSURE you do the pretend flag -- you can mess up your system doing this the wrong way (mind you it can me fixed by re-emerging, but this is not much fun.

Hope I'm helping . . . 

Gabriel

----------

## cool

Thank a bunch Gabriel... you have helped me alot. I'm learning linux now :p. 

Here is the output i got from emerge -p depclean:

```

*** WARNING *** : DEPCLEAN CAN  SERIOUSLY  IMPAIR YOUR SYSTEM. USE CAUTION.

*** WARNING *** : (Cancel: CONTROL-C) -- ALWAYS VERIFY ALL PACKAGES IN THE

*** WARNING *** : CANDIDATE LIST FOR  SANITY  BEFORE  ALLOWING DEPCLEAN TO

*** WARNING *** : UNMERGE ANY PACKAGES.

*** WARNING *** :

*** WARNING *** : USE FLAGS MAY HAVE AN EXTREME EFFECT ON THE OUTPUT.

*** WARNING *** : SOME LIBRARIES MAY BE USED BY PACKAGES BUT ARE NOT

*** WARNING *** : CONSIDERED TO BE A DEPEND DUE TO USE FLAG SETTINGS.

*** WARNING *** :

*** WARNING *** : Packages  in the list  that are  desired  may be added

*** WARNING *** : directly to the world file to cause them to be ignored

*** WARNING *** : by declean and maintained in the future. BREAKAGES DUE

*** WARNING *** : TO UNMERGING AN  IN-USE  LIBRARIES  MAY BE REPAIRED BY

*** WARNING *** : MERGING  *** THE PACKAGE THAT COMPLAINS ***  ABOUT THE

*** WARNING *** : MISSING LIBRARY.

Calculating depclean dependencies ... done!

Packages installed:   132

Packages in world:    12

Packages in system:   73

Unique package names: 132

Required packages:    134

Number to remove:     0

```

The edited mysql ebuild is placed in usr/local/portage/dev-db/mysql as i copied the whole mysql folder over there.

X has been installed..., so now i'm really worried about how to remove it without screw other packages i have installed.

i will keep you updated...

-cool-

----------

## ggelln

Don't worry about screwing anything up . . .

at worst you must just emerge the complaining package again . . .

I recomend installing ccache if you have not already !

When I removed X11 from my system I first did:

```

emerge unmerge xfree

```

this will remove the package

I then issue:

```

emerge -p dep-clean

```

which given your useflags should hopefully now try to remove some unused packages

if not then some judicious use of

```

emerge -pv world

```

to see what is trying to reinstall X11 and then I did

```

emerge unmerge {the package that was doing so}

```

I'm sorry this is so guess and test,

a more extreme way might be to edit your world file, but I had the fear of really borking my system this way (this fear might be missplaced . . . I am still learning as well!)

after each stage I would run the emerge -p dep-clean in hopes that it will fix stuff.

getting rid of X is a pain, but it is possible, and once you have done it you feel nice a clean!

keep me posted

(I will try to remove X from one of my boxes tommorrow, it will be good practice)

can you post the edited mysql file, I will try the install with you

Gabriel

----------

## ggelln

okay disregard the above solution . . . it was ugly:

to find out what depends on java or xfree run:

```

qpkg -q java

qpkg -q xfree

```

to find out what depends on java that you have installed run:

```

qpkg -I -q java

```

it should then be a simple matter to unmerge all offending packages (after a quick check to ensure that it isn't something that you need for something else (that is use the qpkg -q again!))

another tool to use is dep-clean which if you read the man page has an interactive world file editor  :Smile: 

so I would use the qpkg to cut down the system then use the dep-clean package to ensure that my world file will not cause anything to be rebuilt.

I will do this tommorow to see if it works in practice.

Gabriel

----------

## cool

NIce! thankx alot Gabriel

OK so here is what i change in mysql-4.0.13.ebuild

```

#the compiler flags are as per their "official" spec ;)

        CFLAGS="${CFLAGS/-O?/} -O3" \

        CXXFLAGS="${CXXFLAGS/-O?/} -O3 -felide-constructors -fno-exceptions -fn$

        econf \

                --prefix=/usr/local/mysql \

                --with-raid \

                --with-low-memory \

                  ..........................

```

Yup thats all i chaged :p cause i think that will intalling all the binaried into /usr/local/mysql But like i mentioned above it emerge the one in standard tree. 

Hmm i dont know what digest do tho, i read the manual but its some what compliacted to me as my english level is too low. Can you explain me what it does in this specific case??

Also about qpkg where can i find it from?? and what it does also :p, heh i'm so noob. I tried to look in the manual but its not there. I dont know i just called "man qpkg" and i got no entry.

Thankx again, i'm still wonder where is my db i made :p. Since its ermeged noramally so mysql is everywhere now :p

-cool-

----------

## ggelln

okay I have been successful  :Smile: 

(though the changed ebuild needs some work . . . as different parts of the ebuild are hardcoded to the given directory structure . . . you will have to do the configure and add the new directory to your path by hand -- this will come from the mysql site (or whatever book you are using) as yours is the default options)

I renamed the ebuild to mysql-4.0.13-r1.ebuild and remade the digest as I did in the previous directions. (the digest is just a simple security measure built into portage . . . it does simple md5 checksums on the files you specify in the ebuild to try and ensure that the ebuild is not some evil pretender  :Smile: 

when you goto emerge -p just ensure that you see mysql-4.0.13-r1 I do, so if not we will figure out what is going on  :Smile: 

when you do the emerge the DBD-mysql package will fail, as mysql is not in your path, so to fix this just make sure that you export the updated path before the build.

As for qpkg it is a tool in 'gentoolkit' a great collection of tools,

another tool you might like is ufed a nice use variable selector just do:

```

emerge gentoolkit ufed

```

I was able to rid myself of X with no prob. (I'm happy you brought this up so that I would realize how silly I had been before!)

I just use ufed to set the use variables in such a way that it is a lean mean server machine, no X no java, etc if you have problems tell me I will post you the USE variables I used.

I then did:

```

qpkg -I -q xfree

qpkg -I -q java

```

which gave me a list of installed packages that depend on X and java

I then did some liberal unmerging. Followed by an emerge -p depclean to see if gentoo would help me out.

In my case I didn't have that many matches so I just did it by hand -- if you have problems we can make a simple bash script to automate this a bit.

I then did:

```

qpkg -I | less

```

to see a master list of what was left on my machine. Anything I didn't like I checked with qpkg -I -q to ensure it wasn't needed by something I wanted (given that I might be able to remove this dependency with my USE variables) and unmerged it.

I then did a quick

```

emerge -pv mod_php

```

just to see if any of the unmerged packages tried to come back.

Tell me how it goes.

Gabriel

----------

