How to Configure Apache Web Server in Linux
According the March, 2009 Netcraft Web Server Survey (Reference 2), Apache is the most widely used web server in the world. It is used on over 104 million sites. Apache is Open Source software that can be installed on Windows, Linux and Unix operating systems. It is the "A" in the LAMP (Linux Apache MySQL PHP/Perl/Python) acronym. It is possible to install on Linux via source code, .rpm packages and .deb packages. Once installed, there are a few configuration files that must be edited in order to access your website.
Instructions
-
-
1
Create a user and group for the administration of the Apache Web Server. It is not a good idea to run it as root.
sudo groupadd www-apache
sudo useradd -c "Apache" -g www-apache -p Password1 www-apache -
2
Download and install the Apache2 packages. You can download them directly from the Apache website or through your distribution's package manager.
-
-
3
Stop the Apache service.
sudo /etc/init.d/apache2 stop -
4
Edit the /etc/apache2/envvars file.
gedit /etc/apache2/envvars -
5
Change the following two lines to reflect your Apache user:
export APACHE_RUN_USER=www-apache
export APACHE_RUN_GROUP=www-apache -
6
Make a directory where you want to keep your websites.
mkdir /public_html -
7
Create a configuration file for your website in /etc/apache2/sites-available by copying the default configuration file. For this example, the website will be called navaja.
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/navaja -
8
Edit the navaja configuration file.
gedit /etc/apache2/sites-availabe navaja -
9
Change the following lines to reflect your configuration:
Under "<VirtualHost *:80>":
ServerAdmin user@lyouremail.com
DocumentRoot /public_html
<Directory /public_html/navaja>
The above line is the second "<Directory>" section. -
10
Disable the default site.
sudo a2dissite default -
11
Enable the new site.
sudo a2ensite navaja -
12
Restart Apache.
sudo /etc/init.d/apache2 restart -
13
Create an index.html file in the /public_html/ directory.
-
14
Test the configuration by opening a web browser and typing http://localhost in the address bar.
-
1