Install Apache on Ubuntu in two ways: 1. Use the packaging service of the Development Kit, for example, use the apt-get command; 2. Build Apache from the source code. This article describes the two different installation methods in detail. Method 1: Use the packaging service & mdash; apt-get to install apache, enter the command in the command line terminal: $ after the sudoapt-getinstallapache2 is installed, restart the apache service, in the command
Install Apache on Ubuntu in two ways: 1. Use the packaging service of the Development Kit, for example, use the apt-get command; 2. Build Apache from the source code. This article describes the two different installation methods in detail.
Method 1: Use the packaging service of the Development Kit-apt-get
To install apache, enter the following command in the command line terminal:
$ Sudo apt-get install apache2
After the installation is complete, restart the apache service and enter the following command in the command line terminal:
$ Sudo/etc/init. d/apache2 restart
Possible problems 1: NameVirtualHost *: 80 has no VirtualHosts, as shown below
Cause of the above problem: Multiple namevirtualhosts are defined, so comment out NameVirtualHost *: 80 in/etc/apache2/ports. conf.
Possible issues 2: cocould not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
Cause:
As prompted, you cannot reliably determine the valid Domain Name of the server. You can use 127.0.1.1 as the server domain name. In the following test, we should use 127.0.1.1 instead of 127.0.0.1!
Solution:
$ Vim/etc/apache2/httpd. conf:
ServerName localhost: 80. Restart apache2 again to access the web server using 127.0.0.1!
Test:
Enter http: // localhost or http: // 127.0.0.1 in the browser. If It works is displayed !, It means that Apache is successfully installed. By default, Apache will create a directory named www under/var, which is the Web directory, all Web files that can be accessed through a browser must be placed in this directory.
Problems may occur during the test:
Cause: the server address used by apache2 is not 127.0.0.1. According to the previous analysis, the possible ip address is 127.0.1.1. Access http: // 127.0.1.1.
If you no longer need apache, You can uninstall it:
1. Delete apache
Enter:
$ Sudo apt-get -- purge remove apache-common
$ Sudo apt-get -- purge remove apache
2. Find and delete the configuration file that has not been deleted.
Code:
$ Sudo find/etc-name "* apache *" | xargs rm-rf
$ Sudo rm-rf/var/www
$ Sudo rm-rf/etc/libapache2-mod-jk
3. Delete the association so that you can use apt-get install apache2 to reinstall it again.
# Dpkg-l | grep apache2 | awk '{print $2}' | xargs dpkg-P
Method 2: Build Apache from the source
References:
Ubuntu installation Apache + PHP + MySQL: http://www.linuxidc.com/Linux/2012-05/61079.htm
Uninstalling Apache2: http://www.linuxidc.com/Linux/2013-06/85825.htm in Ubuntu
Apache problem solving: httpd: cocould 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
Cause: Multiple namevirtualhosts are defined.
Solution: versions earlier than Ubuntu are defined in/etc/apache2/sites-available/default, and later than 8.04 in/etc/apache2/ports. conf.
Therefore, you can comment out the NameVirtualHost *: 80 in/etc/apache2/ports. conf.
The essence of this problem is that no domain name is defined. A port can only correspond to one virtual host. Changing NameVirtualHost *: 80 to another port can also solve this problem.
If there are multiple domain names, you can use the same port.
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2