Wednesday, February 14, 2007

Apache2, PHP, MySql (Gentoo Linux)

I've just installed Apache, Php and MySql in my Gentoo box; I've always used these programs and servers only under Debian since they looked easier to install (or probably they looked harder to install in Gentoo :-). I actually found out that it's quite easy to install them in Gentoo either!

I followed some documents found on the web, but basically the installation procedure was even faster than that found on the web:

I put these lines in /etc/make.conf:

USE="apache2 mysql php pam ssl xml xml2 berkdb innodb jpeg png"


If you want to install also phpmyadmin, then you should also add pcre session unicode:

USE="apache2 mysql php pam ssl xml xml2 berkdb innodb jpeg png pcre session unicode"


then I simply ran:

emerge dev-db/mysql apache php

after few minutes (well... half an hour would be more appropriate) the installation terminated successfully.

I then changed the file /etc/init.d/apache2, in order to enable public_html folders for users (corresponding to the ~ directory), setting -D USERDIR:

APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5 -D USERDIR"

Before starting mysql, you must create (once and for all) the mysql main database, and this can be done simply by running:

/usr/bin/mysql_install_db

then you're ready to start apache and mysql.

9 comments:

Anonymous said...

Thanks!!! this is the best guide i've found! :) I'm now loving Gentoo :P

betto said...

uh you're too kind :-)

glad you found that useful and that you started loving Gentoo!

happy hacking!

Anonymous said...

I try and be Nice :)

bendily.com said...

Instead of editing:
/etc/init.d/apache2

it should be:
/etc/conf.d/apache2


bb

Anonymous said...

Good info. I am trying to get LAMP working on gentoo, since new to gentoo emerge thing, i just removed the php and installing it from source.

Japan Shah said...

I was checking out Gentoo, and just installed php and apache, but my PHP files are not working with apache so when I tried to open http://localhost/test.php it shows the contents of PHP file instead of executing it on apache web server.

any idea?

Japan Shah said...

sorry it has taken a lot time, but it works perfect :-)

Unknown said...

Excellent, adding the USE flags did the job...without them only frustration invaded me!

Thanks a lot.

Lee V said...

This is a ggreat post