SHARE
Follow this article on Twitter Facebook LinkedIn Bookmark and Share
Home >> Integrating IT

How to install Apache on Linux

How to install Apache on Linux

By:  Paul Venezia  On: 13 Jul 2012 For: InfoWorld (U.S.) 
 

An easy step-by-step guide to setting up an Apache Web server on Fedora, CentOS, or Ubuntu

SAN FRANCISCO-- The installation, care, and feeding of an Apache Web server is not terribly difficult, but can seem so if you haven't ventured into those particular waters before. This quick-start guide will help you get your feet wet with Apache on a Linux server. You'll find it's relatively simple to get the Web server set up and running on your Linux of choice. We'll also install PHP and MySQL, though we won't be digging into MySQL configurations, as that deserves a quick start all its own.

The method of installing the Apache packages on a Linux server varies from distribution to distribution. We'll cover how to do this on Fedora and CentOS, as well as on Ubuntu. This is a server-centric walkthrough, so we'll use the command line exclusively. Naturally, you'll need root-level privileges. Open the terminal window and type:

su -

Then enter the root password. Now we can get started.

First we'll install the packages themselves. For Fedora and CentOS, this is a simple step involving Yum, the package installer and updater. To install the basic Apache and PHP packages, run the following command:

yum install httpd php mysql mysql-server

Follow the prompts, as this tool will locate and install a base set of Apache and PHP packages.

For Ubuntu 10.04 servers and newer, you can install the whole LAMP (Apache, MySQL, and PHP) stack with two commands:
 

sudo apt-get install tasksel
sudo tasksel install lamp-server

While this guide does not cover MySQL, the above commands are a quick way to get all the necessary packages required for LAMP applications. Once the installation is complete, we can begin configuring the server.

For all file editing, on Fedora, CentOS, or Ubuntu, you may want to use nano:

nano /etc/httpd/conf/httpd.conf

This command will open the Apache configuration file in a basic editor. You can save the file with Ctrl-O and exit the editor with Ctrl-X.

Apache on Linux: Initial configuration
While the Apache and PHP packages are essentially the same across the different distributions, there are differences in how they are actually installed on the file system. We'll start with Fedora and CentOS.

Fedora and CentOS. After installation, you'll find a new directory: /etc/httpd. Within this directory are all the Apache configuration files. The important subdirectories for our purposes are /etc/httpd/conf and /etc/httpd/conf.d. Within /etc/httpd you'll find the main Apache configuration file, httpd.conf. In /etc/httpd/conf.d you will find includes, or supplemental files that are included in the main configuration file.

Includes are a way to break out complex configurations into separate files for easy organization and management. For instance, if you have an Apache server that has 20 virtual hosts, then each virtual host should have a separate file in /etc/httpd/conf.d/ that contains its specific configuration parameters. In this way, you can easily add or remove virtual hosts without editing the main Apache configuration file.


Sign up for our Newsletters

 












Print |  Views: 3892   |   Rating:offoffoffoffoff  (0 votes)
Rate this article on a scale of
1 to 5 stars,5 being the best.




paul venezia Paul Venezia is a contributor to the International Data Group (IDG) News Service, which publishes global technology stories from bureaus around the world to more than 300 publications in more than 60 countries.

Recent Canadian IT Jobs




blog comments powered by Disqus