- No Linux-headers-3.10.0-514.el7.x86_64
- I Need To Enable ' Mod_headers ' - CentOS
- A2enmod Headers
- Cached
- Enable Apache Modules In CentOS By Command Line
.NET Core is supported on CentOS. This article describes how to install .NET Core on CentOS.
Install the SDK (which includes the runtime) if you want to develop .NET apps. Or, if you only need to run apps, install the runtime. If you're installing the runtime, we suggest you install the ASP.NET Core runtime as it includes both .NET Core and ASP.NET Core runtimes.
Next, we’re going to install an SSL certificate on CentOS. Install an SSL certificate on CentOS. Using the method below, you can install an SSL certificate on CentOS 7 & 6. Download the primary and intermediate certificates that you’ve received from your SSL provider; Copy your SSL files to your Apache server. Sep 18, 2019 If your server is based on CentOS/RedHat Linux, run the following command from the console to enable this module: sudo yum install modssl. Note: If you use Apache 2.4 version, the name of the module should be mod24ssl. To enable this module on a Debian-based distributive (i.e., Ubuntu) run the following command: sudo a2enmod ssl.
If you've already installed the SDK or runtime, use the
dotnet --list-sdks
and dotnet --list-runtimes
commands to see which versions are installed. For more information, see How to check that .NET Core is already installed.Package manager installs are only supported on the x64 architecture. Other architectures, such as ARM, must manually install the .NET Core SDK or .NET Core Runtime. For more information, see the manually install section below.
Supported distributions
The following table is a list of currently supported .NET Core releases on both CentOS 7 and CentOS 8. These versions remain supported until either the version of .NET Core reaches end-of-support or the version of CentOS is no longer supported.
- A ✔️ indicates that the version of CentOS or .NET Core is still supported.
- A ❌ indicates that the version of CentOS or .NET Core isn't supported on that CentOS release.
- When both a version of CentOS and a version of .NET Core have ✔️, that OS and .NET combination are supported.
CentOS | .NET Core 2.1 | .NET Core 3.1 | .NET 5 Preview (manual install only) |
---|---|---|---|
✔️ 8 | ✔️ 2.1 | ✔️ 3.1 | ✔️ 5.0 Preview |
✔️ 7 | ✔️ 2.1 | ✔️ 3.1 | ✔️ 5.0 Preview |
The following versions of .NET Core are no longer supported. The downloads for these still remain published:
- 3.0
- 2.2
- 2.0
Package manager installs are only supported on the x64 architecture. Other architectures, such as ARM, must manually install the .NET Core SDK or .NET Core Runtime. For more information, see the manually install section below.
How to install other versions
The packages added to package manager feeds are named in a hackable format:
{product}-{type}-{version}
.- product
The type of .NET product to install. Valid options are:- dotnet
- aspnetcore
- type
Chooses the SDK or the runtime. Valid options are:- sdk
- runtime
- version
The version of the SDK or runtime to install. This article will always give the instructions for the latest supported version. Valid options are any released version, such as:- 3.1
- 3.0
- 2.1
It's possible the SDK/runtime you're trying to download is not available for your Linux distribution. For a list of supported distributions, see .NET Core dependencies and requirements.
Examples
- Install the ASP.NET Core 3.1 runtime:
aspnetcore-runtime-3.1
- Install the .NET Core 2.1 runtime:
dotnet-runtime-2.1
- Install the .NET Core 3.1 SDK:
dotnet-sdk-3.1
Package missing
If the package-version combination doesn't work, it's not available. For example, there isn't an ASP.NET Core SDK, the SDK components are included with the .NET Core SDK. The value
aspnetcore-sdk-2.2
is incorrect and should be dotnet-sdk-2.2
. For a list of Linux distributions supported by .NET Core, see .NET Core dependencies and requirements.CentOS 8 ✔️
.NET Core 3.1 is available in the default package repositories for CentOS 8.
Install the SDK
.NET Core SDK allows you to develop apps with .NET Core. If you install .NET Core SDK, you don't need to install the corresponding runtime. To install .NET Core SDK, run the following commands:
Install the runtime
The .NET Core Runtime allows you to run apps that were made with .NET Core that didn't include the runtime. The commands below install the ASP.NET Core Runtime, which is the most compatible runtime for .NET Core. In your terminal, run the following commands.
As an alternative to the ASP.NET Core Runtime, you can install the .NET Core Runtime that doesn't include ASP.NET Core support: replace
aspnetcore-runtime-3.1
in the command above with dotnet-runtime-3.1
.CentOS 7 ✔️
Before you install .NET, run the following commands to add the Microsoft package signing key to your list of trusted keys and add the Microsoft package repository. Open a terminal and run the following commands:
Install the SDK
.NET Core SDK allows you to develop apps with .NET Core. If you install .NET Core SDK, you don't need to install the corresponding runtime. To install .NET Core SDK, run the following commands:
Install the runtime
The .NET Core Runtime allows you to run apps that were made with .NET Core that didn't include the runtime. The commands below install the ASP.NET Core Runtime, which is the most compatible runtime for .NET Core. In your terminal, run the following commands.
As an alternative to the ASP.NET Core Runtime, you can install the .NET Core Runtime that doesn't include ASP.NET Core support: replace
aspnetcore-runtime-2.1
in the command above with dotnet-runtime-3.1
.Troubleshoot the package manager
This section provides information on common errors you may get while using the package manager to install .NET Core.
Failed to fetch
While installing the .NET Core package, you may see an error similar to
signature verification failed for file 'repomd.xml' from repository 'packages-microsoft-com-prod'
. Generally speaking, this error means that the package feed for .NET Core is being upgraded with newer package versions, and that you should try again later. During an upgrade, the package feed should not be unavailable for more than 2 hours. If you continually receive this error for more than 2 hours, please file an issue at https://github.com/dotnet/core/issues.Snap
A snap is a bundle of an app and its dependencies that works without modification across many different Linux distributions. Snaps are discoverable and installable from the Snap Store. For more information about Snap, see Getting started with Snap.
Only supported versions of .NET Core are available through Snap.
Install the SDK
Snap packages for .NET Core SDK are all published under the same identifier:
dotnet-sdk
. A specific version of the SDK can be installed by specifying the channel. The SDK includes the coresponding runtime. The following table list the channels:.NET Core version | Snap package |
---|---|
3.1 (LTS) | 3.1 or latest/stable |
2.1 (LTS) | 2.1 |
.NET 5.0 preview | 5.0/beta |
Use the
snap install
command to install a .NET Core SDK snap package. Use the --channel
parameter to indicate which version to install. If this parameter is omitted, latest/stable
is used. In this example, 3.1
is specified:Next, register the
dotnet
command for the system with the snap alias
command:This command is formatted as:
sudo snap alias {package}.{command} {alias}
. You can choose any {alias}
name you would like. For example, you could name the command after the specific version installed by snap: sudo snap alias dotnet-sdk.dotnet dotnet31
. When you use the command dotnet31
, you'll invoke this specific version of .NET. But this is incompatible with most tutorials and examples as they expect a dotnet
command to be available.Install the runtime
Snap packages for .NET Core Runtime are each published under their own package identifier. The following table lists the package identifiers:
.NET Core version | Snap package |
---|---|
3.1 (LTS) | dotnet-runtime-31 |
3.0 | dotnet-runtime-30 |
2.2 | dotnet-runtime-22 |
2.1 (LTS) | dotnet-runtime-21 |
Use the
snap install
command to install a .NET Core Runtime snap package. In this example, .NET Core 3.1 is installed:Next, register the
dotnet
command for the system with the snap alias
command:This command is formatted as:
sudo snap alias {package}.{command} {alias}
. You can choose any {alias}
name you would like. For example, you could name the command after the specific version installed by snap: sudo snap alias dotnet-runtime-31.dotnet dotnet31
. When you use the command dotnet31
, you'll invoke this specific version of .NET. But this is incompatible with most tutorials and examples as they expect a dotnet
command to be available.SSL Certificate errors
No Linux-headers-3.10.0-514.el7.x86_64
When .NET is installed through Snap, it's possible that on some distros the .NET SSL certificates may not be found and you may receive an error similar to the following during
restore
:To resolve this issue, set a few enviornment variables:
The certificate location will vary by distro. Here are the locations for the distros where we have experienced the issue.
- Fedora -
/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
- OpenSUSE -
/etc/ssl/ca-bundle.pem
- Solus -
/etc/ssl/certs/ca-certificates.crt
Dependencies
When you install with a package manager, these libraries are installed for you. But, if you manually install .NET Core or you publish a self-contained app, you'll need to make sure these libraries are installed:
- krb5-libs
- libicu
- openssl-libs
If the target runtime environment's OpenSSL version is 1.1 or newer, you'll need to install compat-openssl10.
For more information about the dependencies, see Self-contained Linux apps.
For .NET Core apps that use the System.Drawing.Common assembly, you'll also need the following dependency:
- WarningYou can install a recent version of libgdiplus by adding the Mono repository to your system. For more information, see https://www.mono-project.com/download/stable/.
Scripted install
The dotnet-install scripts are used for automation and non-admin installs of the SDK and Runtime. You can download the script from https://dot.net/v1/dotnet-install.sh.
The script defaults to installing the latest SDK long term support (LTS) version, which is .NET Core 3.1. To install the current release, which may not be an (LTS) version, use the
-c Current
parameter.To install .NET Core Runtime instead of the SDK, use the
--runtime
parameter.You can install a specific version by altering the
-c
parameter to indicate the specific version. The following command installs .NET Core SDK 3.1.For more information, see dotnet-install scripts reference.
Manual install
As an alternative to the package managers, you can download and manually install the SDK and runtime. Manual install is usually performed as part of continuous integration testing or on an unsupported Linux distribution. For a developer or user, it's generally better to use a package manager.
If you install .NET Core SDK, you don't need to install the corresponding runtime. First, download a binary release for either the SDK or the runtime from one of the following sites:
- ✔️ .NET 5.0 preview downloads
- ✔️ .NET Core 3.1 downloads
- ✔️ .NET Core 2.1 downloads
Next, extract the downloaded file and use the
export
command to set variables used by .NET Core and then ensure .NET Core is in PATH.To extract the runtime and make the .NET Core CLI commands available at the terminal, first download a .NET Core binary release. Then, open a terminal and run the following commands from the directory where the file was saved. The archive file name may be different depending on what you downloaded.
Use the following command to extract the runtime:
Use the following command to extract the SDK:
Tip
![Sudo Sudo](/uploads/1/2/6/5/126593349/805645965.jpg)
The preceding
export
commands only make the .NET Core CLI commands available for the terminal session in which it was run.You can edit your shell profile to permanently add the commands. There are a number of different shells available for Linux and each has a different profile. For example:
- Bash Shell: ~/.bash_profile, ~/.bashrc
- Korn Shell: ~/.kshrc or .profile
- Z Shell: ~/.zshrc or .zprofile
Edit the appropriate source file for your shell and add
:$HOME/dotnet
to the end of the existing PATH
statement. If no PATH
statement is included, add a new line with export PATH=$PATH:$HOME/dotnet
.Also, add
export DOTNET_ROOT=$HOME/dotnet
to the end of the file.This approach lets you install different versions into separate locations and choose explicitly which one to use by which application.
Next steps
Table of Contents
Introduction
Apache's
mod_rewrite
can be used to manipulate URLs. It is compiled into the base Apache Web Server.This module provides the ability to manipulate URLs prior to determining the appropriate file or handing off to a script. It can help you, if you want to offer different URLs for the same file. This is most commonly used when a visitor goes to a certain web address, but the server returns a different page.This module uses a rule-based rewriting engine to rewrite requested URLs on the fly. It supports an unlimited number of rules to provide a really flexible and powerful URL manipulation mechanism. It can hide sensitive information, such as query strings, from URL requests. This can potentially enhance website safety.In this tutorial, we will explain how to enable
mod_rewrite
and demonstrate some common ways to use it in Apache on CentOS 7.Requirements
- A server running CentOS 7
Install Apache
Before we begin with the
mod_rewrite
module setup, we need to install the Apache web server.To install Apache, run the following command:
After installing Apache, start the
httpd
service and enable it to start automatically on boot.We can do this using the following commands:
Next, we should allow access to the default Apache port 80 (HTTP) using
firewalld
.We can do this by running the following command:
Now, reload the firewall service for the changes to take effect.
Enable mod_rewrite Module
The
mod_rewrite
module is enabled by default on CentOS 7. If you find it is not enabled on your server, you can enable it by editing 00-base.conf
file located in /etc/httpd/conf.modules.d/
directory.Add or uncomment the following line:
Save and close the file, then restart the
httpd
service:Enable .htaccess File
Once the
mod_rewrite
module has been activated, you can set up your URL rewrites by creating an .htaccess
file in your default document root directory.A .htaccess
file allows us to modify our rewrite rules without accessing server configuration files. For this reason, .htaccess
is critical to your web server.Before we begin, we need to allow Apache to read .htaccess
files located under the /var/www/html
directory.You can do this by editing
httpd.conf
file:Find the section
<directory /var/www/html>
and change AllowOverride None to AllowOverride AllSave and exit.
Now restart Apache to put the change into effect:
Configure Rewrite Module
In this section, we will explain basic mod_rewrite syntax and give some examples.
You can write RewriteRules using the following format:
RewriteRule
: This directive specifies the name of the the mod_rewrite directive that you want to use.Pattern
: This directive specifies a regular expression that matches the desired stringSubstitution
: This directive specifies the path of the actual URL of the page with the information you want to display.Flags
: A flag is a tag at the end of the Rewrite Rule directive that specifies optional parameters that can modify the rule.
Let's discuss RewriteRules with some examples:
Redirect www to non-www
If you want to redirect users from
www
to a plain non-www
domain, you will need to create .htaccess
file in Apache document root directory.Change directories to your Document root:
Create the
.htaccess
file:Add the following content:
Save and exit the file.
We can use
curl
to test that the www
domain redirects to the non-www
domain:You should see the following output:
Above output shows the non-www redirect location http://yourdomain.com/
Redirect non-www to www
If you want to redirect users from a plain
non-www
domain to a www
domain, add the following content to your .htaccess
file:Add the following content:
Save and exit the file.
Now, use
curl
command to ensure that the non-www
domain redirects to the www
domain:You should see the following output:
I Need To Enable ' Mod_headers ' - CentOS
Above output shows the
www
redirect location http://www.yourdomain.com/A2enmod Headers
![Install A2enmod Redhat Install A2enmod Redhat](/uploads/1/2/6/5/126593349/875355674.png)
Redirect All Website Pages
If you want to redirect all pages from 'olddomain.com' to 'newdomain.com', edit the
.htaccess
file:Add the following content:
Save and exit the file.
Now, use
curl
to test that the 'www.olddomain.com' domain redirects to the 'www.newdomain.com' domain:You should get a 301 Moved Permanently response that shows you the new domain redirect location.
Deny File Type Access
If you want to deny users to access specific file types such as:
.pdf
, .css
, .gif
, .png
, or .bmp
then edit your .htacces
file:Add the following content:
Save and exit the file.
Cached
Summary
Enable Apache Modules In CentOS By Command Line
Those are just a few examples of how
mod_rewrite
can be used. If you have questions about these examples please let us know below. You are also welcome to post in the ProfitBricks DevOps Community section of this site.