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

How to view the apache configuration file under linux

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

Share

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

This article mainly introduces how to view the apache configuration file under linux, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

The configuration file for Apache under Linux is that / etc/apache2/apache2.conf,Apache automatically reads the configuration information of this file when it starts. Other configuration files, such as httpd.conf, are included through the Include instruction.

There is a sites-enabled directory in apache2.conf and a sites-available directory in / etc/apache2. In fact, this is the real configuration file, and the sites-enabled directory only contains symbolic links to the files here. You can verify it with ls / etc/apache2/sites-enabled/.

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.

Sudo cp / etc/apache2/sites-avaliable/000-default.conf, named test.conf

two。 Modify the configuration file: test.conf

# The ServerName directive sets the request scheme, hostname and port that# the server uses to identify itself. This is used when creating# redirection URLs. In the context of virtual hosts, the ServerName# specifies what hostname must appear in the request's Host: header to# match this virtual host. For the default virtual host (this file) this# value is not decisive as it is used as a last resort host regardless.# However, you must set it for any further virtual host explicitly.ServerName www.test.comServerAdmin webmaster@localhostDocumentRoot / var/www/html/test/ErrorLog / var/www/html/test/error.logCustomLog / var/www/html/test/access.log combined Options FollowSymLinks DirectoryIndex index.php index.html index.htm AllowOverride All # pay attention to the configuration of this place Enable Order deny,allow Allow from All# Available loglevels: trace8,..., trace1, debug, info, notice, warn,# error, crit, alert, emerg.# It is also possible to configure the loglevel for particular# modules, e.g.#LogLevel info ssl:warn# For most configuration files from conf-available/, which are# enabled or disabled at a global level, it is possible to# include a line for only one particular virtual host. For example the# following line enables the CGI configuration for this host only# after it has been globally disabled with "a2disconf". # Include conf-available/serve-cgi-bin.conf

Create a linked file:

Sudo ln-s / etc/apache2/sites-available/test.conf / etc/apache2/sites-enabled/test.conf

Or: sudo a2ensite test.conf

4. Restart the apache server

Sudo / etc/init.d/apache2 restart

Modify hosts (/ etc/hosts)

/ / add a line of 127.0.0.1 www.test.com

Basically, you can visit here normally!

Note: if you also need to support URL rewriting at the directory level here, continue to:

Terminal operation

Sudo a2enmod

The program prompts for the name of the module that can be activated, enter: rewrite

Success will prompt

Rewrite already load

Modify / etc/apache2/sites-enabled/test.conf (the link points to the site profile)

Change the AllowOverride attribute below to All, and save it. (we have configured it as All above)

Reload apache

Sudo / etc/init.d/apache2 restart above how to view all the contents of the apache configuration file under linux, thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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