Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Restart commands and host configuration files for Ubuntu apache2

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "Ubuntu apache2 restart command and host configuration file". The explanation in this article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "Ubuntu apache2 restart command and host configuration file".

Ubuntu apache2 for the computer players commonly used software, and then I will learn and in-depth study of Ubuntu apache2, here with you to discuss the use of Ubuntu apache2, I hope to be useful to you. Ubuntu apache2 configuration

1.Ubuntu apache2.conf is the main profile, httpd.conf user profile

two。 Virtual directory in httpd.conf

DocumentRoot "path" ServerName name allow from all Options + Indexes

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

4.Ubuntu apache2 restart command

Sudo / etc/init.d/apache2 restart or cd / etc/init.d sudo apache2-k restart stop stops; start starts 5. The log file is in / var/log/apache2/ ServerName www.kimoqi.com DocumentRoot / home/vsftpd/kimoqi ServerName www.arwenedu.com DocumentRoot / home/vsftpd/wangguan/webapps ServerName www.arwenedu.org.cn DocumentRoot / home/vsftpd/wangguan/chem vi / etc/httpd/conf/httpd.conf

Under Windows, there is usually only one configuration file for Apache, which is httpd.conf. But after I installed Apache2 on Ubuntu Linux with the apt-get install apache2 command, I found that its httpd.conf (located in the / etc/apache2 directory) was empty! Furthermore, it is found that the configuration file of Ubuntu's Apache package is not as simple as Windows's. It divides each setting item into different configuration files, which looks complicated, but the design is really reasonable when you think about it.

Strictly speaking, Ubuntu's Apache (or should I say Apache under Linux? I don't know that the configuration file for other distributions of apache packages) is / etc / apache2/apache2.conf,Apache that automatically reads the configuration information of this file at startup. Other configuration files, such as httpd.conf, are included through the Include instruction. You can find these Include lines in apache2.conf:

Quote

# Include module configuration: Include / etc/apache2/mods-enabled/*.load Include / etc/apache2/mods-enabled/*.conf # Include all the user configurations: 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: Include / etc/apache2/sites-enabled/

Combined with comments, you can clearly see the general role of each profile. Of course, you can put all the settings in Ubuntu apache2.conf or httpd.conf or any configuration file. This division of Ubuntu apache2 is just a good habit.

One of the most important things to do after installing Ubuntu apache2 is to know where the root of the Web document is. For Ubuntu apache2, the default is / var/www. How do you know that? 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 there is something like this in / etc / apache2/sites-enabled/000-default:

Quote

NameVirtualHost * ServerAdmin webmaster@localhost DocumentRoot / var/www/

This is to set up a virtual host, which doesn't make any sense to me. So I commented out the Include / etc/apache2/sites-enabled/ line in apache2.conf and set DocumentRoot in httpd.conf to a directory under my user directory, which is convenient for development.

Then take a look at what's in the / etc/apache2 directory. I just found the sites-enabled directory in Ubuntu apache2.conf, and there is also a sites-available directory under / etc / apache2. What's in it? In fact, this is the real configuration file, and the sites-enabled catalog stores only symbolic links to the files here, which you can use ls / etc/apache2/sites-enabled/ to confirm. Therefore, if multiple virtual hosts are configured on the apache, and the configuration files of each virtual host are placed under the sites-available, then it is very convenient to deactivate and enable the virtual host: when a link to a virtual host configuration file is established under sites-enabled, it is enabled; if you want to shut down a virtual host, you only need to delete the corresponding link without changing the configuration file at all.

Mods-available and mods-enabled are similar to sites-available and sites-enabled mentioned above, and these two directories store configuration files and links for apache functional modules. When I install the PHP module with apt-get install php5, I have php5.load, php5.conf, and links to these two files in these two directories. This directory result is very convenient for enabling and deactivating an Apache module.

* one thing to say is ports.conf, which sets the port used by Apache. If you need to adjust the default port settings, it is recommended that you edit this file. Or if you think it's too much, you can first remove the Include / etc/apache2/ports.conf line from apache2.conf and set the Apache port in httpd.conf.

The directory structure of the default installation in Ubuntu apache2 is a little different. In Ubuntu apache2, the configuration of module and virtual host has two directories, one is available, and the other is enabled,available directory, which stores valid content, but does not work. It can only work if you connect to enabled with ln. It is convenient for debugging and use, but if you don't know it in advance, it's a little troublesome to find it.

Thank you for reading, the above is the content of "Ubuntu apache2 restart command and host configuration file". After the study of this article, I believe you have a deeper understanding of the problem of Ubuntu apache2 restart command and host configuration file, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report