Apache2 configuration 2

Source: Internet
Author: User
1. apache2.conf is the main configuration file and the httpd. conf user configuration file.
2. The virtual directory is in httpd. conf.
<Virtualhost *>
DocumentRoot "path"
<Direc × y "path"> allow from all options + indexes </direc × y>

3. The root setting (default main directory) is in /etc/apache2/sites-available/default

4. Restart command
sudo /etc/init.d/apache2 restart
CD/etc/init. d
Sudo apache2-K restart
Stop stop; start

5. log files are stored in/var/log/apache2/<virtualhost *: 80>
Servername [url] www.kimoqi.com [/url]

<Virtualhost *: 80>
Servername [url] www.arwenedu.com [/url]

<Virtualhost *: 80>
Servername [url] www.arwenedu.org.cn [/url]

</Virtualhost> VI/etc/httpd/CONF/httpd. conf in windows, there is usually only one configuration file for Apache, that is, httpd. conf. But I use apt-get in Ubuntu Linux
After The apache2 command is installed with apache2, it turns out that its httpd. conf (located in the/etc/apache2 directory) is empty! Then we can find out
The configuration file of the Apache software package is not as simple as that of windows. It divides the configuration items into different configuration files and looks complicated, but it is reasonable to think about the design carefully. Strictly speaking, the Apache of ubuntu (or the Apache under Linux? I don't know if the configuration file for other Apache software packages is
/Etc/apache2/apache2.conf. Apache automatically reads the configuration information of this file at startup. Other configuration files, such
Httpd. conf, etc.
Yes through include
Command. In apache2.conf, you can find these include rows: Reference # include module configuration:
Include/etc/apache2/mod-enabled/*. Load
Include/etc/apache2/mod-enabled/*. conf # include all the user invocations:
Include/etc/apache2/httpd. conf # include ports listing
Include/etc/apache2/ports. conf
# Include generic snippets of statements
Include/etc/apache2/CONF. d/# include the virtual host configurations:
With Comments, you can clearly see the general functions of each configuration file. Of course, you can put all the settings in apache2.conf, httpd. conf, or any configuration file. This classification of apache2 is just a good habit. The most important thing after installing Apache is to know where the web document root directory is. For Ubuntu, the default value is/var/www. How do you know?
What about it? 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 in/etc
/Apache2/sites-enabled/000-default, which contains the following content: Reference namevirtualhost *
<Virtualhost *>
Serveradmin webmaster @ localhostdocumentroot/var/www/
This is for setting up a VM, Which is meaningless to me. So I put the include in apache2.conf
/Etc/apache2/sites-enabled/comment out a line, and set DocumentRoot to
Directory to facilitate development. Let's take a look at the things in the/etc/apache2 directory. The sites-enabled directory was found in apache2.conf, while
/There Is A sites-available directory under apache2. What is it like? In fact, this is the real configuration file, and the sites-enabled object
You can use the LS
/Etc/apache2/sites-enabled/to confirm. Therefore, if multiple virtual hosts are configured on Apache
In sites-available, it is very convenient to disable and enable a VM: When sites-enabled creates a chain pointing to a VM configuration file
It is enabled when it is connected. To disable a virtual host, you only need to delete the corresponding link and do not need to modify the configuration file. The WordPress-available and Wordpress-enabled directories are similar to the preceding sites-available and sites-enabled directories.
Stores the configuration files and links of the Apache function module. When I use apt-Get install
After the PHP module is installed in PhP5, php5.load, php5.conf, and links to these two files are available in these two directories. This directory result indicates whether to enable or disable
The Apache module is very convenient. 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. Or you may think it is too much.
You can also include
Remove the/etc/apache2/ports. conf line and set the Apache port in httpd. conf. The default directory structure installed in Ubuntu is quite different. In ubuntu, module and virtual
The host configuration has two directories: available and enabled. The available Directory stores valid content, but does not work. Only ln is used.
Connect 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.
  1. <Virtualhost *>
  2. Servername Domain Name
  3. DocumentRoot treats the public in the rails project as the root directory
  4. <Direc × y public root directory>
  5. Options execcgi followsymlinks
  6. AllowOverride all
  7. Allow from all
  8. Order allow, deny
  9. </Direc × y>
  10. Errorlog/var/log/apache2/error-Domain Name. Log
  11. </Virtualhost>

(In fact, the following link is also good, [url] http://bbs.7jiejie.com/t/20/1220426703950.html#/url#. They can complement each other. Paste it as it is:

The apache2 installed in Debian or Ubuntu is not exactly the same as the source code-compiled apache2. It has certain rules for use. This rule is easy to use and well planned. It is especially suitable for SVN management. Therefore, it is a good habit for administrators to follow this rule as much as possible.

Debian is used to describe it. First install apache2 and run the following command:

Apt-Get install apache2

You can install apache2.

Then you can try:

/Etc/init. d/apache2 stop (disable Apache)

/Etc/init. d/apache2 start (start Apache)

/Etc/init. d/apache2 restart (restart Apache)

Debian has made some effort in the startup script. Generally, it is easier to use these commands to control the running of apache2 than apachectl.

Then enter the configuration file of/etc/apache2/and apache2 in this directory. If this is the first installation, you may find that the contents in this directory are unfamiliar. Check the httpd. conf file and find it empty?

Apache is the main configuration file of Apache, but this configuration file does not need to be changed. If you have a configuration file, you can overwrite it as quickly as possible.
Apache2.conf can be used frequently after restart, but this does not comply with the specifications. At this time, it takes some time to split the original configuration document into dismembers and modify the corresponding/etc/apache2.
For some files in the/directory, apache2.conf will include some files in the/etc/apache2/directory so that you can work, and the next Administrator takes over the work.
You can view the configuration at a glance.

The configuration files in apache2.conf include all files in Conf. D, mod-enabled, and sites-enabled, and httpd. conf and ports. conf.

Httpd. conf is an empty file by default. You can add global configurations used by all virtual hosts on the local machine.

The conf. D folder is used to store some common code blocks.

Ports. conf
File is usually set to port 80 by default. Of course, it is inevitable to change it. Then I will talk about one of my usual tips, that is, using httpd. conf and ports. conf
Files mV to the sites-enabled directory, renamed as 00000-httpd.conf and 00000-port.conf, and then in/etc
/Apache2/does the Directory have two soft links: httpd. conf and ports. conf? Finally, let's talk about it.

Then there is the mod-
Available and mod-enabled directories, where the mod-available Directory stores the loading configurations of all modules currently supported by apache2.
If the directory of the WordPress-enabled is set to "Soft link", the module to be loaded is used as a function. You can create a soft link from the directory of the WordPress-available.
You can delete this soft link, but the module configuration still exists.

The two directories sites-available and sites-enabled are used to store virtual hosts. The practice is roughly the same. Available is completely put, and enabled is soft link. When writing the configuration in available, the general file name is the host name of the virtual host, for example, [url] www.163.com [/url] ([url] http://www.163.com [/url])
The file content is [url] www.163.com [/url] ([url] http://www.163.com [/url])
The virtualhost content of the VM. It is worth noting that the namevirtualhost label can be easily written or missed. Currently, I am in conf separately. there is a configuration under the d directory. You do not need to write this configuration When configuring it under sites-available. Then let's talk about how to manage these configurations. If you only have one machine, you can simply go to VI, But I have hundreds of machines. It is too troublesome to change something like this, so we need to do some automation: note that one thing about these automation is that they destroy the rules. Contents
The previous practice is that the sites-available and mod-available directories do not use the soft link mechanism.
The directory is placed in the General Directory of the svn Management System (for example,/Server/0-apache_common/), and sites-enabled is placed on the machine of the svn management system.
Directory (for example,/Server/ /). As mentioned above, I will move httpd. conf and ports. conf
Sites-enabled directory, so these two files are also stored in the sites-enabled directory of SVN. Then, by writing a bash
Shell, regularly remove the configuration from SVN and automatically restart apache2 to achieve the management goal. I think the main problem with this approach is that the module will be loaded to unused modules during loading, but it does not matter if it is used. so, I copied them all to the modules directory under the mod-enabled directory, and then modified them. the path of the Load file. These modifications are all one-time and there is no major problem. If apache2 needs to be upgraded, all machines must be upgraded at one time. The current practice is to compile the. Deb file and then upgrade it in apt-Get upgrade. Then re-compile the module and update SVN again. After submitting the code, the system can automatically update the code, which is very convenient.
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.