How to: Apache 2 in Linux
The Apache Project makes the Apache 2 Web server available as a free download on the Apache Web site, but do not be fooled by that fact. Apache 2 is feature-laden and robust, stable and when properly configured, secure. Ubuntu Linux is one of the most popular Linux platforms for the Apache 2 Web server.
Instructions
-
Reach global Internet users with the Apache 2 Web server.
-
1
Update Ubuntu Linux with the following command at the command prompt:
sudo apt-get update
This will update Ubuntu Linux, which is always a good idea before installing new software.
-
2
Install Apache 2 with the following command at the command prompt:
sudo apt-get install apache2
This command will install Apache 2 and any required packages on your Linux server.
-
-
3
Create a configuration file for your new site with the following command:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/yourserver
This will make a copy of the default configuration file named "yourserver," which you can update.
-
4
Edit /etc/apache2/apache2.conf and be sure the following line is present:
DocumentRoot /var/www
Be sure to save the file and exit.
-
5
Configure the site configuration file which you created in step three to include the following lines:
ServerAdmin youremail@localhost.com (the default is webmaster@localhost)
Servername yourserver (the fully qualified domain name)
DocumentRoot /var/www/yourserver (where Apache looks for pages)
-
6
Enable your new site and disable the default site with the following commands:
sudo a2ensite yourserver
sudo a2dissite default
sudo /etc/init.d/apache2 restart
-
7
Create a directory for your content, place your content there, and test the new site.
sudo mkdir /var/www/yourserver
Create a webpage named "index.html" with a text editor, and place it in the "yourserver" directory. Start a browser, enter "localhost" and press "Enter." You should see your new site's webpage.
-
1
References
Resources
- Photo Credit Chad Baker/Photodisc/Getty Images