Installing apache, mysql and php on gentoo

Just right now I’m setting up my new home server for various things. It’ll do all of my ranking stuff of course, since it’s very easy for me to get a new ip once G is blocking me. Right now most of the scripts are coded in python, but some essentials are still running on php (though not for long), so i need a running lamp (besides torrentflux and so on…). The last time i set up a clean server on gentoo is quite a few years back now. Eventhough it was a lot of fun and always a good chance to learn some things, I must admit it’s gotten quite easy now. It took me quite some time getting the new php5 running with apache a few years ago. Now theres nothing really special you need to do. Just fire up portage and install it. Before you do, you might wanna edit a few files though. First of all make sure you add mysql and apache2 to your global use flags in /etc/make.conf, then you’ll have to think about some apache options. First of all how will the server process run on your system? Since I’ve loads of RAM and don’t really have any traffic except some requests of my one, no virtual hosts, no nothing, I’ll go with a forked apache. For further information refer to the apache manual. For an forked MPM version of apache just do a quick:

#echo "APACHE2_MPMS="prefork" >> /etc/make.conf

There’s one thing left to do: Define what modules you want your apache to run with. As always gentoo provides a very easy way to do that. If you want to know what modules you can install just do a quick

#emerge --pretend --verbose --oneshot apache

to see all available modules. You’ll at least want those to be installed, since they are kind of needed 🙂

#echo "APACHE2_MODULES="alias auth_basic auth_digest
rewrite authz_host dir mime" >> /etc/make.conf

Not all of them are mandatory, but you’ll at least need to install authz_host, dir and mime for your apache to run. Now you’re ready to go, just fire up portage with a quick

#emerge apache

Now just install php by firing up portage again, but remember to set the use flags you’ll need by updating your /etc/portage/package.use, since there are quite some options… As always you can see available use flags by executing an pretended oneshot emerge of php! When you’re done, just install php by

#echo "dev-lang/php apache2 bzip2 curl exif ftp gd iconv mysql
mysqli nls pcre session simplexml soap spell spl sqlite ssl
tokenizer truetype unicode xml xmlrpc" >> /etc/portage/package.use

#emerge php

and you’re good to go! Just start your apache with the according init script and everything should work out of the box. You’ll probably want your apache to start automatically too, by adding it to your default runlevel:

#/etc/init.d/apache start

#rc-update add apache default

But just remember: This is a very basic installation of lamp on your system, it’ll work as it is, but you might wanna tune your settings. As always just refer to the man pages and online documentations!






One response to “Installing apache, mysql and php on gentoo”

  1. Heshan Peiris Avatar

    Good Article 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *