UbuntuApache2 restart command and host configuration file

Source: Internet
Author: User
Ubuntuapache2 is a commonly used software for computer gamers. Then I will study and study Ubuntuapache2 in depth. I will discuss with you how to use Ubuntuapache2. Ubuntuapache2 configuration 1. Ubuntuapache2.conf is the main configuration file, and httpd. conf is the user configuration file. 2. The virtual directory is in httpd. conf & lt; VirtualHost & nbs

Ubuntu apache2 is a commonly used software for computer players. Then I will study and study Ubuntu apache2 in depth. Here I will discuss with you how to use Ubuntu apache2, hoping to help you. Ubuntu apache2 Configuration

1. Ubuntu apache2.conf is the main configuration file and the httpd. conf user configuration file.

2. The virtual directory is in httpd. conf.

 
 
  1. <VirtualHost*> 
  2. DocumentRoot "path"
  3. ServerName
  4. <Direc×Y "path">Allow from all Options + Indexes Direc×Y> 
  5. VirtualHost> 

3. Root settings (default main directory) in/etc/apache2/sites-available/default

4. Ubuntu apache2 restart command

 
 
  1. Sudo/etc/init. d/apache2 restart or
  2. Cd/etc/init. d
  3. Sudo apache2-k restart
  4. Stop; start 5. log files in/var/log/apache2/
  5. <VirtualHost*: 80> 
  6. ServerName www.kimoqi.com
  7. DocumentRoot/home/vsftpd/kimoqi
  8. VirtualHost> 
  9. <VirtualHost*: 80> 
  10. ServerName www.arwenedu.com
  11. DocumentRoot/home/vsftpd/wangguan/webapps
  12. VirtualHost> 
  13. <VirtualHost*: 80> 
  14. ServerName www.arwenedu.org.cn
  15. DocumentRoot/home/vsftpd/wangguan/chem
  16. VirtualHost> 
  17.  
  18. Vi/etc/httpd/conf/httpd. conf

In Windows, there is usually only one configuration file for Apache, that is, httpd. conf. However, after I installed apache2 with the apt-get install Apache2 command in Ubuntu Linux, I found that its httpd. conf (in the/etc/apache2 directory) is empty! It is found that the configuration file of the Apache package in Ubuntu is not as simple as that in Windows. It divides the configuration items into different configuration files and looks complicated, but think about the design carefully.

Strictly speaking, the Apache of Ubuntu (or the Apache under Linux? The configuration file of other apache software packages is/etc/apache2/apache2.conf. Apache automatically reads the configuration information of this file at startup. Some other configuration files, such as httpd. conf, are included through the Include command. You can find these Include rows in apache2.conf:

Reference

 
 
  1. # Include module configuration:  
  2. Include /etc/apache2/mods-enabled/*.load  
  3. Include /etc/apache2/mods-enabled/*.conf  
  4.  
  5. # Include all the user configurations:  
  6. Include /etc/apache2/httpd.conf  
  7.  
  8. # Include ports listing  
  9. Include /etc/apache2/ports.conf  
  10. ……  
  11. # Include generic snippets of statements  
  12. Include /etc/apache2/conf.d/  
  13.  
  14. # Include the virtual host configurations:  
  15. Include /etc/apache2/sites-enabled/ 

With Comments, you can clearly see the general functions of each configuration file. Of course, you can put all the settings in Ubuntu apache2.conf, httpd. conf, or any configuration file. This classification of Ubuntu apache2 is just a good habit.

The most important thing after installing Ubuntu apache2 is to know where the Web document root directory is. For Ubuntu apache2, the default value is/var/www. How do you know? There is no DocumentRoot entry in apache2.conf, and httpd. conf is empty, so it must be in other files. After searching, it is found that the content in/etc/apache2/sites-enabled/000-default contains the following content:

Reference

 
 
  1. NameVirtualHost *  
  2. <VirtualHost *> 
  3. ServerAdmin webmaster@localhost  
  4.  
  5. DocumentRoot /var/www/ 

This is for setting up a VM, Which is meaningless to me. So I commented out the Include/etc/apache2/sites-enabled/line in apache2.conf and added it to httpd. in conf, set DocumentRoot to a directory under my user directory to facilitate development.

Let's take a look at the things in the/etc/apache2 directory. I just found the sites-enabled directory in Ubuntu apache2.conf, and there is a sites-available directory under/etc/apache2. What should I put here? In fact, this is the real configuration file, and the sites-enabled directory stores only some symbolic links pointing to the files here, you can use ls/etc/apache2/sites-enabled/to confirm it. Therefore, if multiple virtual hosts are configured on apache and the configuration files of each virtual host are stored in sites-available, it is very convenient to disable and enable the Virtual Host: when a link is established under sites-enabled to a virtual host configuration file, it is enabled. To disable a virtual host, you only need to delete the corresponding link, you do not need to modify the configuration file.

The following two directories are used to store the configuration files and links of the apache function module. After I installed the PHP module with apt-get install php5, php5.load, php5.conf, and links to these two files are available in these two directories. This directory result is very convenient for enabling or disabling an Apache module.

The last one is ports. conf, where the port used by Apache is set. To adjust the default port settings, we recommend that you edit this file. Alternatively, you can remove the Include/etc/apache2/ports. conf line in apache2.conf and set the Apache port in httpd. conf.

The default directory structure installed in Ubuntu apache2 is quite different. In Ubuntu apache2, the module and virtual host configurations both have two directories: available and enabled. The available Directory stores valid content but does not work, it takes effect only when ln is connected to enabled. Debugging is easy to use, but if you do not know it beforehand, it will be a little troublesome to find it.

The/etc/apache2/sites-available file is configured with the link-to-enabled file but does not work. You must link the file to the sites-enabled directory.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.