They apply to the whole Virtual Host. The 'ServerAdmin' option specifies a contact email that should be used when there are server problems.
If we were using this as a template for other Virtual Host definitions, we would want to add a 'ServerName' definition that specifies the domain name or IP address that this request should handle. This is the option that would add specificity to the Virtual Host, allowing it to trump the default definition if it matches the ServerName value.
You can also make the Virtual Host apply to more than one name by using the 'ServerAlias' definition. This provides alternate paths to get to the same content. A good use-case for this is adding the same domain, preceded by 'www'. The 'DocumentRoot' option specifies where the content that is requested for this Virtual Host will be located. Within the Virtual Host definition, there are definitions for how the server handles different directories within the file system.
Apache will apply all of these directions in order from shortest to longest, so there is again a chance to override previous options. This will provide the baseline configuration for your Virtual Host, as it applies to all files served on the file system. By default, Ubuntu does not set up any access restrictions to the filesystem. Apache recommends that you add some default access restrictions. You can modify this like so:. This will deny access to all content unless specified otherwise in subsequent directory definitions.
The 'AllowOverride' option is used to decide whether an '. This is not allowed by default, but can be useful to enable in a variety of circumstances. Directory definitions are sometimes preceded by 'Alias' or 'ScriptAlias' statements. Alias maps a url path to a directory path.
ScriptAlias operates in the same way, but is used to define directories that will have executable components in them. For instance, this line in a Virtual Host that handles request to 'example. Following the alias, you should remember to define the directory with access privileges as discussed in the previous section. Once you have a Virtual Host file that meets your requirements, you can use the tools included with Apache to transition them into live sites.
To automatically create a symbolic link in the 'sites-enabled' directory to an existing file in the 'sites-available' directory, issue the following command:. After enabling a site, issue the following command to tell Apache to re-read its configuration files, allowing the change to propagate:. There is also a companion command for disabling a Virtual Host.
One of the great advantages of the Apache web server is its modular architecture. You can add or remove functionality as dictated by your requirements. In the default Apache build, you would find a section near the top of your httpd. This arrangement can be tricky from the perspective of a system administrator who may need to install or uninstall various Apache modules.
Identifying the configuration changes that are required by a module or that require a specific module can be difficult to do by hand and even harder to automate with a script. To make things easier on the server administrator, Debian takes advantage of the fact that Apache configuration files may contain an Include directive which pulls in additional configuration files. Whenever you install an Apache module from a Debian package, the module will drop one or two files into the mods-available directory.
Installing a module from a Debian package makes it available to your server, but does not necessarily automatically activate the module in your server. To activate the module, use the a2enmod command:. To force a running Apache to re-read its configuration files and thus load the module, you must then send it the force-reload signal. Alias maps a url path to a directory path. ScriptAlias operates in the same way, but is used to define directories that will have executable components in them.
For instance, this line in a Virtual Host that handles request to "example. Following the alias, you should remember to define the directory with access privileges as discussed in the previous section.
Once you have a Virtual Host file that meets your requirements, you can use the tools included with Apache to transition them into live sites. To automatically create a symbolic link in the "sites-enabled" directory to an existing file in the "sites-available" directory, issue the following command:.
After enabling a site, issue the following command to tell Apache to re-read its configuration files, allowing the change to propagate:. There is also a companion command for disabling a Virtual Host. It operates by removing the symbolic link from the "sites-enabled" directory:.
Modules can be enabled or disabled by using the "a2enmod" and "a2dismod" commands respectively. They work in the same way as the "site" versions of these commands. Remember to reload your configuration changes after modules have been enabled or disabled as well.
We have gone over some basic Apache configuration files. Apache is versatile and very modular, so configuration needs will be different depending on your setup. You should have a good understanding of what the main configuration files are used for and how they interact with each other.
If you need to know about specific configuration options, the provided files are well commented and Apache provides excellent documentation. Hopefully, the configuration files will not be as intimidating now, and you feel more comfortable experimenting and modifying to suit your needs. Where would you like to share this to? Twitter Reddit Hacker News Facebook. Share link Tutorial share link.
DigitalOcean home. Community Control Panel. Hacktoberfest Contribute to Open Source. By Justin Ellingwood Published on August 7, What is Apache? How to Install Apache on Ubuntu and Debian If you do not already have Apache installed, you can do so now by issuing the following commands: sudo apt-get update sudo apt-get install apache2 This is all that is necessary to have a working web server.
This is the default web page for this server. The web server software is running but no content has been added, yet. Read more. How To Install Rocket. Chat with Ubuntu This post is about How To Install Rocket. Here are the top five chat apps for Ubuntu users. Having a decent chat application could help team members to collaborate in an effective way.
Team members can collaborate effectively with a decent chat app. Although there are many applications available in the market, we will About Us. Popular Category.
0コメント