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:

  1. Anonymous8:46 AM

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

    ReplyDelete
  2. uh you're too kind :-)

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

    happy hacking!

    ReplyDelete
  3. Anonymous7:51 AM

    I try and be Nice :)

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

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


    bb

    ReplyDelete
  5. Anonymous3:28 PM

    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.

    ReplyDelete
  6. 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?

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

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

    Thanks a lot.

    ReplyDelete
  9. This is a ggreat post

    ReplyDelete