Now that our slice is set up the way we want it, we can start installing our web server software.
In this article we'll, prepare the system for installing Apache, install it, and see how to make it start automatically every time the Slice is rebooted.
Preparing the System
Log in to your slice as your admin user, the one we created in the Gentoo - Slice Setup articles.
Certain ebuilds (like PHP) have optional support for Apache 2.x integration. Because we're about to install Apache 2.2, we'll want to enable this in all the appropriate packages. We can do this by setting the global USE flag 'apache2'.
Edit the '/etc/make.conf' file ..
sudo nano /etc/make.conf
.. and add 'apache2' into the list of global USE flags. You can get a refresher on how to set a global use flag in the second page of the Gentoo Slice setup articles.
Your 'USE' line in '/etc/make.conf' should now look something like this, with any other USE flags you've added yourself earlier:
USE="apache2 -gnome -kde -alsa -cups -qt3 -qt4"
Save the file and exit the editor.
Install and Startup
Now we'll start the apache installation:
sudo emerge apache
This may take some time. Feel free to go take a coffee break. For me it took about 10 minutes. Remember to run 'sudo etc-update' if asked to, once it's done.
Once apache has installed we should be able to start it up:
sudo /etc/init.d/apache2 start
When you start apache using the default config you'll get a warning like this:
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Although we'll be going into some detail about the options and settings available in the main Apache configuration file in a later article, let's fix that warning right now.
Open the main Apache configuration file:
sudo nano /etc/apache2/httpd.conf
At the bottom of the file add the following:
Change the word 'demo' to your Slice hostname (remember this demo Slice has a hostname of 'demo').
Once done, save httpd.conf and gracefully restart Apache (this method of restarting won't kill open connections):
sudo /etc/init.d/apache2 reload
Now the warning has gone. Nice.
If you navigate in your web browser to your Slice IP address:
You will see the default 'It works!' screen:
Keep it running
At the moment if we reboot the slice, Apache will not automatically start up on boot. We can fix this using the 'rc-update' command which was originally discussed in page 1 of the Gentoo set-up articles.
To make Apache start on boot run, we'll add it to the default run level:
sudo rc-update add apache2 default
To double check that it's there you can run:
sudo rc-update show | grep apache
Well, almost ready to use.
There will be some more configuring to make your web applications work.
The next article will go through installing PHP on the Slice.