There are two ways to install Apache on Ubuntu: 1 Using Package services for development packages, such as using the Apt-get command, and 2 building Apache from the source. This article describes the two different installation methods in detail.
Method One: Use packaged services for the development package--apt-get
To install Apache, enter the command in the command line terminal:
$ sudo apt-get install apache2
After the installation is complete, restart the Apache service and enter the command at the command line terminal:
$ sudo/etc/init.d/apache2 Restart
Problems that may occur 1:namevirtualhost *:80 has no virtualhosts, as follows
The cause of the above problem: Define a number of namevirtualhost, so the/etc/apache2/ports.conf in the Namevirtualhost *:80 comment out.
Problems that may occur 2:could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
Reason:
According to the prompt, can not reliably determine the server's valid domain name, using 127.0.1.1 as the server domain name. In this, in the following test, you should use 127.0.1.1 instead of 127.0.0.1!
Solve:
$ vim/etc/apache2/httpd.conf, add in file:
ServerName localhost:80, restart Apache2 again, you can use 127.0.0.1来 access to the Web server!
Test:
Enter http://localhost or http://127.0.0.1 in the browser, if you see the IT works!, it means that Apache installed successfully, Apache default installation, will be in/var under a directory called WWW, This is the Web directory, all Web files that can be accessed by the browser should be placed in this directory.
You may experience problems during the test:
Cause: The server address used by Apache2 is not 127.0.0.1, according to the previous analysis, the possible IP is 127.0.1.1, access to the http://127.0.1.1.
If you feel you don't need Apache anymore, you can uninstall it:
1. Delete Apache
On the command line, enter:
$ sudo apt-get--purge remove Apache-common
$ sudo apt-get--purge remove Apache
2. Find a profile that is not deleted and delete it.
Code:
$ sudo find/etc-name "*apache*" |xargs RM-RF
$ sudo rm-rf/var/www
$sudo RM-RF/ETC/LIBAPACHE2-MOD-JK
3. Remove the association so that it can be re-installed with the Apt-get install Apache2
#dpkg-L |grep Apache2|awk ' {print $} ' |xargs Dpkg-p
Method Two: Build Apache from the source
Resources:
Install apache+php+mysql:http://www.linuxidc.com/linux/2012-05/61079.htm under Ubuntu
Completely uninstall apache2:http://www.linuxidc.com/linux/2013-06/85825.htm under Ubuntu
Apache Problem Resolution: Httpd:could not reliably determine the server ' s fully qualified domain name link: http://www.linuxidc.com/Linux/ 2012-08/68901.htm
--------------------------------------Split Line--------------------------------------
Apache2 [warn] namevirtualhost *:80 has no virtualhosts solution
Error: [Warn] namevirtualhost *:80 has no virtualhosts
Reason: multiple namevirtualhost are defined
FIX: Ubuntu before version defined in/etc/apache2/sites-available/default, 8.04 after/etc/apache2/ports.conf
The Namevirtualhost *:80 in/etc/apache2/ports.conf can be commented out
The essence of this problem is that the domain name is not defined as a port can only correspond to one virtual host, the Namevirtualhost *:80 to another port can also be resolved
If you have multiple different domain names, you can also use the same port.
For more information about Ubuntu see the Ubuntu feature page http://www.linuxidc.com/topicnews.aspx?tid=2
Ubuntu under Apache installation and configuration